11 #include <mc_rtc/config.h>
33 template<
typename... Args>
34 static std::shared_ptr<mc_observers::Observer>
get_observer(
const std::string & name,
const Args &... args)
36 std::lock_guard<std::mutex> guard{mtx};
38 return observer_loader->create_object(name, args...);
50 std::lock_guard<std::mutex> guard{mtx};
52 return observer_loader->get_object_runtime_directory(name);
55 template<
typename RetT,
typename... Args>
56 static void register_object(
const std::string & name, std::function<RetT *(
const Args &...)> callback)
58 std::unique_lock<std::mutex> guard{mtx};
60 observer_loader->register_object(name, callback);
68 std::lock_guard<std::mutex> guard{mtx};
70 observer_loader->load_libraries(paths);
76 std::lock_guard<std::mutex> guard{mtx};
78 observer_loader->clear();
86 std::lock_guard<std::mutex> guard{mtx};
88 return observer_loader->has_object(name);
93 std::lock_guard<std::mutex> guard{mtx};
95 if(observer_loader) { observer_loader->set_verbosity(verbose); }
101 std::lock_guard<std::mutex> guard{mtx};
103 return observer_loader->objects();
107 static inline void init(
bool skip_default_path =
false)
113 std::vector<std::string> default_path = {};
114 if(!skip_default_path) { default_path.push_back(mc_rtc::MC_OBSERVERS_INSTALL_PREFIX); }
115 observer_loader.reset(
125 static std::unique_ptr<mc_rtc::ObjectLoader<mc_observers::Observer>> observer_loader;
126 static bool verbose_;
127 static std::mutex mtx;