#pragma once #include #include #include "log.h" #include "micros.h" namespace oh_my_slam { class Config { public: void SetConfigFile(const std::string& file) { config_.reset(new YAML::Node); *config_ = YAML::LoadFile(file); } template const T& Get(const std::string& key) const { AFATAL_IF(!config_) << "No config exists: please call SetConfigFile."; return (*config_)[key].as(); } const YAML::Node& config() const { AFATAL_IF(!config_) << "No config exists: please call SetConfigFile."; return *config_; } private: std::shared_ptr config_{nullptr}; DECLARE_SINGLETON(Config); }; } // namespace oh_my_slam