33 #ifndef GSLAM_DATASET_H 34 #define GSLAM_DATASET_H 37 #include "Messenger.h" 44 typedef std::shared_ptr<Dataset> DatasetPtr;
104 typedef std::vector<std::string> StrVec;
106 Dataset(
const std::string& dataset){open(dataset);}
109 std::string name()
const{
if(_impl)
return _impl->type();
else return _name;}
110 virtual std::string type()
const{
if(_impl)
return _impl->type();
else return "Dataset";}
111 virtual bool isOpened(){
if(_impl)
return _impl->isOpened();
else return false;}
112 virtual FramePtr grabFrame(){
if(_impl)
return _impl->grabFrame();
else return FramePtr();}
114 virtual bool open(
const std::string& dataset);
115 virtual bool isLive()
const{
116 if(_impl)
return _impl->isLive();
124 inline bool Dataset::open(
const std::string& dataset){
126 std::string extension;
128 size_t dotPosition=dataset.find_last_of(
'.');
129 if(dotPosition!=std::string::npos)
131 extension=dataset.substr(dotPosition+1);
133 if(extension.empty()) {
134 LOG(ERROR)<<
"Can't open dataset without extension.";
138 Svar localImpl=svar[
"gslam"][
"datasets"][extension];
139 if(localImpl.isFunction()){
140 impl=DatasetPtr(localImpl().castAs<Dataset*>());
145 Svar plugin=Registry::load(
"gslamDB_"+extension);
146 if(plugin.isUndefined()){
147 LOG(ERROR)<<
"Can't load plugin gslamDB_"<<extension<<
".";
150 Svar pluginImpl=plugin[
"gslam"][
"datasets"][extension];
151 if(!pluginImpl.isFunction())
153 LOG(ERROR)<<
"Plugin gslamDB_"<<extension
154 <<
" has no function gslam.datasets."<<extension;
157 impl=DatasetPtr(pluginImpl().castAs<Dataset*>());
160 if(impl) {_impl=impl;
return _impl->open(dataset);}
166 #endif // VIDEOREADER_H
The Svar class, A Tiny Modern C++ Header Brings Unified Interface for Different Languages.
Definition: Svar.h:561
The Dataset class.
Definition: Dataset.h:101