#ifndef USATA_OBJECT_REGISTRY #define USATA_OBJECT_REGISTRY #include namespace usata { class Object; typedef Object* (*BIOCF)(void);// BIOCF; struct ObjectRegistryImpl; class ObjectRegistry { static std::auto_ptr mInstance; std::auto_ptr mImpl; ObjectRegistry(); public: static ObjectRegistry* instance(); void add(const char*, BIOCF) throw(); }; /** \brief Helper macro to automaticaly register Object types **/ #define USATA_OBJECT_REGISTER(O) \ namespace { \ Object *O##Factory(){ return dynamic_cast(new O); } \ struct O##FactoryHelper_{ \ O##FactoryHelper_() \ { \ ::usata::ObjectRegistry::instance()-> \ add(#O,&O##Factory); \ } \ }; \ static O##FactoryHelper_ O##FactoryHelpStatic; \ } } #endif