31 #ifndef RTABMAP_FLANN_OBJECT_FACTORY_H_ 32 #define RTABMAP_FLANN_OBJECT_FACTORY_H_ 43 template<
typename BaseClass,
44 typename UniqueIdType,
45 typename ObjectCreator = BaseClass* (*)()>
56 bool subscribe(UniqueIdType
id, ObjectCreator creator)
58 if (object_registry.find(
id) != object_registry.end())
return false;
60 object_registry[id] = creator;
66 return object_registry.erase(
id) == 1;
69 ObjectCreator
create(UniqueIdType
id)
71 typename ObjectRegistry::const_iterator iter = object_registry.find(
id);
73 if (iter == object_registry.end()) {
82 static ThisClass the_factory;
bool unregister(UniqueIdType id)
ObjectCreator create(UniqueIdType id)
std::map< UniqueIdType, ObjectCreator > ObjectRegistry
ObjectFactory< BaseClass, UniqueIdType, ObjectCreator > ThisClass
static ThisClass & instance()
bool subscribe(UniqueIdType id, ObjectCreator creator)
ObjectRegistry object_registry