14 #include <mc_rtc/config.h>
27 template<
typename... Args>
37 template<
typename T,
typename... Args>
38 struct are_strings<T, Args...> : std::integral_constant<bool, are_strings<T>::value && are_strings<Args...>::value>
51 typename std::conditional<std::is_same<std::string, T>::value,
const std::string &, std::string>::type
to_string(
54 static_assert(!std::is_integral<T>::value,
55 "Passing integral value here would create empty strings of the provided size");
74 template<
typename... Args>
78 std::unique_lock<std::mutex> guard{mtx};
84 if(rm->_canonicalParameters.empty()) { rm->_canonicalParameters = rm->_parameters; }
85 if(!rm->controlToCanonicalPostProcess)
90 if(aliases.count(name))
92 const auto & params = aliases[name];
93 if(params.size() == 1) { rm = get_robot_module_from_lib(params[0]); }
94 else if(params.size() == 2) { rm = get_robot_module_from_lib(params[0], params[1]); }
95 else if(params.size() == 3) { rm = get_robot_module_from_lib(params[0], params[1], params[2]); }
98 mc_rtc::log::error_and_throw<mc_rtc::LoaderException>(
99 "Aliases can only handle 1 to 3 parameters, {} provided ({})", params.size(),
102 rm->_parameters.resize(1);
103 rm->_parameters[0] = name;
105 else { rm = get_robot_module_from_lib(name, args...); }
114 static RobotModulePtr get_robot_module(
const std::vector<std::string> & args);
116 template<
typename RetT,
typename... Args>
117 static void register_object(
const std::string & name, std::function<RetT *(
const Args &...)> callback)
119 std::unique_lock<std::mutex> guard{mtx};
121 robot_loader->register_object(name, callback);
127 static void update_robot_module_path(
const std::vector<std::string> & paths);
132 std::lock_guard<std::mutex> guard{mtx};
134 robot_loader->clear();
143 std::lock_guard<std::mutex> guard{mtx};
145 return robot_loader->has_object(name) || aliases.count(name) != 0;
150 std::lock_guard<std::mutex> guard{mtx};
152 if(robot_loader) { robot_loader->set_verbosity(verbose); }
156 static std::vector<std::string> available_robots();
165 static void load_aliases(
const std::string & fname);
168 static void init(
bool skip_default_path =
false);
170 template<
typename... Args>
173 rm->_parameters.push_back(arg0);
174 fill_rm_parameters(rm, args...);
179 template<
typename... Args>
182 if(!robot_loader->has_object(name))
184 mc_rtc::log::error(
"Cannot load the requested robot: {}\nIt is neither a valid alias nor a known exported robot",
189 mc_rtc::log::error_and_throw<mc_rtc::LoaderException>(
"Cannot load the requested robot: {}", name);
193 rm->_parameters = {name};
194 fill_rm_parameters(rm, args...);
198 static std::unique_ptr<mc_rtc::ObjectLoader<mc_rbdyn::RobotModule>> robot_loader;
199 static bool verbose_;
200 static std::mutex mtx;
201 static std::map<std::string, std::vector<std::string>> aliases;