36#include "g2o/config.h"
57 static void destroy();
62 void registerType(
const std::string& tag,
63 const std::shared_ptr<AbstractHyperGraphElementCreator>& c);
68 void unregisterType(
const std::string& tag);
81 const std::string& tag,
87 bool knowsTag(
const std::string& tag,
int* elementType = 0)
const;
95 void fillKnownTypes(std::vector<std::string>& types)
const;
100 void printRegisteredTypes(std::ostream& os,
bool comment =
false)
const;
105 std::shared_ptr<AbstractHyperGraphElementCreator>
creator;
106 int elementTypeBit = -1;
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);
create vertices and edges based on TAGs in, for example, a file
Factory & operator=(Factory const &)=delete
CreatorMap _creator
look-up map for the existing creators
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
std::map< std::string, std::string > TagLookup
Factory(Factory const &)=delete
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