31 #ifndef OPENCV_FLANN_OBJECT_FACTORY_H_
32 #define OPENCV_FLANN_OBJECT_FACTORY_H_
45 template<
typename BaseClass,
46 typename UniqueIdType,
47 typename ObjectCreator = BaseClass* (*)()>
50 typedef ObjectFactory<BaseClass,UniqueIdType,ObjectCreator> ThisClass;
58 bool subscribe(UniqueIdType
id, ObjectCreator creator)
60 if (object_registry.find(
id) != object_registry.end())
return false;
62 object_registry[id] = creator;
66 bool unregister(UniqueIdType
id)
68 return object_registry.
erase(
id) == 1;
71 ObjectCreator create(UniqueIdType
id)
73 typename ObjectRegistry::const_iterator iter = object_registry.find(
id);
75 if (iter == object_registry.end()) {
76 throw CreatorNotFound();
82 static ThisClass& instance()
84 static ThisClass the_factory;
88 ObjectRegistry object_registry;