Go to the documentation of this file.
30 #ifndef EXOTICA_CORE_FACTORY_H_
31 #define EXOTICA_CORE_FACTORY_H_
47 #define EXOTICA_CORE_REGISTER(BASE, TYPE, DERIV) \
48 static exotica::Registrar<BASE> EX_UNIQ(object_registrar_, __LINE__)("exotica/" TYPE, []() -> BASE* { return new DERIV(); }, #BASE); \
49 PLUGINLIB_EXPORT_CLASS(DERIV, BASE)
51 #define EXOTICA_CORE_REGISTER_CORE(BASE, TYPE, DERIV) static exotica::Registrar<BASE> EX_UNIQ(object_registrar_, __LINE__)("exotica/" TYPE, []() -> BASE* { return new DERIV(); }, #BASE);
55 template <
typename BaseClass>
60 template <
class BaseClass>
84 ThrowPretty(
"Trying to register already existing type '" <<
type <<
"'!");
93 return std::shared_ptr<BaseClass>(it->second());
104 std::vector<std::string> DeclaredClasses;
107 DeclaredClasses.push_back(it->first);
109 return DeclaredClasses;
126 template <
typename BaseClass>
133 Registrar(
const std::string& name, BaseClass* (*creator)(),
const std::string& base_type)
141 #endif // EXOTICA_CORE_FACTORY_H_
virtual std::string type() const
Type Information wrapper: must be virtual so that it is polymorphic...
void RegisterType(const std::string &type, BaseClass *(*creator_function)())
Registers a new derived class type.
Templated Object factory for Default-constructible classes. The Factory is itself a singleton.
static Factory< BaseClass > & Instance(void)
Singleton implementation: returns a reference to a singleton instance of the instantiated class.
Registration Class for the object type: Also templated:
Registrar(const std::string &name, BaseClass *(*creator)(), const std::string &base_type)
Public Constructor which is only used to register the new task type.
std::map< std::string, BaseClass *(*)()> type_registry_
The Map containing the register of the different types of classes.
std::shared_ptr< BaseClass > CreateInstance(const std::string &type)
std::vector< std::string > GetDeclaredClasses()
Lists the valid implementations which are available and registered.
exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Fri Aug 2 2024 08:43:02