knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
DataSourceHandler.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_DATA_SOURCE_HANDLER_H_
7 #define KNOWROB_DATA_SOURCE_HANDLER_H_
8 
9 #include "map"
10 #include "string"
11 #include "functional"
12 #include "DataSource.h"
13 
14 namespace knowrob {
15  using DataSourceLoader = std::function<bool(const DataSourcePtr &)>;
16 
20  class DataSourceHandler {
21  public:
22  DataSourceHandler() = default;
23 
24  virtual ~DataSourceHandler() = default;
25 
31  void addDataHandler(const std::string &format, const DataSourceLoader &fn);
32 
39  bool loadDataSource(const DataSourcePtr &dataSource);
40 
46  bool hasDataHandler(const DataSourcePtr &dataSource) const;
47 
48 
49  protected:
50  std::map<std::string, DataSourceLoader> dataSourceHandler_;
51 
52  virtual bool loadDataSourceWithUnknownFormat(const DataSourcePtr &) { return false; }
53  };
54 }
55 
56 #endif //KNOWROB_DATA_SOURCE_HANDLER_H_
void addDataHandler(const std::string &format, const DataSourceLoader &fn)
virtual ~DataSourceHandler()=default
virtual bool loadDataSourceWithUnknownFormat(const DataSourcePtr &)
std::map< std::string, DataSourceLoader > dataSourceHandler_
bool hasDataHandler(const DataSourcePtr &dataSource) const
bool loadDataSource(const DataSourcePtr &dataSource)
FunctionRule & function()
Definition: terms.cpp:140
TermRule & string()
Definition: terms.cpp:63
std::function< bool(const DataSourcePtr &)> DataSourceLoader
std::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:107