36#include "g2o/config.h"
63 const std::shared_ptr<AbstractHyperGraphElementCreator>& c);
81 const std::string&
tag,
87 bool knowsTag(
const std::string&
tag,
int* elementType = 0)
const;
105 std::shared_ptr<AbstractHyperGraphElementCreator>
creator;
109 typedef std::map<std::string, std::unique_ptr<CreatorInformation>>
CreatorMap;
124#ifdef G2O_DEBUG_FACTORY
125 std::cout << __FUNCTION__ <<
": Registering " <<
_name <<
" of type "
126 <<
typeid(T).name() << std::endl;
134 std::shared_ptr<AbstractHyperGraphElementCreator>
_creator;
139#if defined _MSC_VER && defined G2O_SHARED_LIBS
140#define G2O_FACTORY_EXPORT __declspec(dllexport)
141#define G2O_FACTORY_IMPORT __declspec(dllimport)
143#define G2O_FACTORY_EXPORT
144#define G2O_FACTORY_IMPORT
148#define G2O_REGISTER_TYPE(name, classname) \
149 extern "C" void G2O_FACTORY_EXPORT g2o_type_##classname(void) {} \
150 static g2o::RegisterTypeProxy<classname> g_type_proxy_##classname(#name);
152#define G2O_USE_TYPE_BY_CLASS_NAME(classname) \
153 extern "C" void G2O_FACTORY_IMPORT g2o_type_##classname(void); \
154 static g2o::ForceLinker proxy_##classname(g2o_type_##classname);
156#define G2O_REGISTER_TYPE_GROUP(typeGroupName) \
157 extern "C" void G2O_FACTORY_EXPORT g2o_type_group_##typeGroupName(void) {}
159#define G2O_USE_TYPE_GROUP(typeGroupName) \
160 extern "C" void G2O_FACTORY_IMPORT g2o_type_group_##typeGroupName(void); \
161 static g2o::ForceLinker g2o_force_type_link_##typeGroupName( \
162 g2o_type_group_##typeGroupName);
void unregisterType(const std::string &tag)
bool knowsTag(const std::string &tag, int *elementType=0) const
Factory & operator=(Factory const &)=delete
CreatorMap _creator
look-up map for the existing creators
void printRegisteredTypes(std::ostream &os, bool comment=false) const
static std::unique_ptr< Factory > factoryInstance
static Factory * instance()
return the instance
std::map< std::string, std::unique_ptr< CreatorInformation > > CreatorMap
TagLookup _tagLookup
reverse look-up, class name to tag
HyperGraph::HyperGraphElement * construct(const std::string &tag) const
static void destroy()
free the instance
std::map< std::string, std::string > TagLookup
Factory(Factory const &)=delete
const std::string & tag(const HyperGraph::HyperGraphElement *v) const
return the TAG given a vertex
void fillKnownTypes(std::vector< std::string > &types) const
void registerType(const std::string &tag, const std::shared_ptr< AbstractHyperGraphElementCreator > &c)
templatized creator class which creates graph elements
std::bitset< HyperGraph::HGET_NUM_ELEMS > GraphElemBitset
RegisterTypeProxy(const std::string &name)
std::shared_ptr< AbstractHyperGraphElementCreator > _creator
some general case utility functions