3 #ifndef VISR_OBJECTMODEL_OBJECT_FACTORY_HPP_INCLUDED 4 #define VISR_OBJECTMODEL_OBJECT_FACTORY_HPP_INCLUDED 12 #include <boost/function.hpp> 29 template<
class ObjectType,
class ParserType >
35 using CreateFunction = boost::function< Object* ( ObjectId id )>;
37 explicit Creator( CreateFunction fcn,
ObjectParser * parser );
43 CreateFunction mCreateFunction;
45 std::shared_ptr<ObjectParser> mParser;
48 template<
class ObjectType,
class ParserType >
49 class TCreator:
public Creator
53 : Creator( &TCreator<ObjectType,ParserType>::construct,
new ParserType() )
59 return new ObjectType( objectId );
63 using CreatorTable = std::map<ObjectTypeId, Creator >;
65 static CreatorTable & creatorTable();
68 template<
class ObjectType,
class ParserType >
71 creatorTable().insert( std::make_pair( typeId, TCreator<ObjectType, ParserType>() ) );
77 #endif // #ifndef VISR_OBJECTMODEL_OBJECT_FACTORY_HPP_INCLUDED Definition: object_factory.hpp:22
unsigned int ObjectId
Definition: object.hpp:23
static void registerObjectType(ObjectTypeId typeId)
Definition: object_factory.hpp:69
ObjectTypeId
Definition: object_type.hpp:26
Definition: options.cpp:10
Definition: object_parser.hpp:21
Definition: object.hpp:36