c++ automatic factory registration of derived types
I use a singleton with a member for registration, basically: template< typename KeyType, typename ProductCreatorType > class Factory { typedef boost::unordered_map< KeyType, ProductCreatorType > CreatorMap; … }; Using Loki I then have something along these lines: typedef Loki::SingletonHolder< Factory< StringHash, boost::function< boost::shared_ptr< SomeBase >( const SomeSource& ) > >, Loki::CreateStatic > SomeFactory; Registration is usually … Read more