//////////////////////////////////////////////////////////////////////// /// \class RAT::Classifiers::ClassifierFactory /// /// \brief Factory for Just In Time creation of methods /// /// \author Phil G Jones \n /// \author Matt Mottram -- contact person /// /// REVISION HISTORY:\n /// 27/04/2012 : P G Jones - New file \n /// 2014-07-17 : P G Jones - Add register method.\n /// 2015/02/24 : E Beier - Added Isotropy classifier.\n /// /// \details Allows classifiers to be newed by string name, when required. /// This is a singleton class. /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_Classifier_ClassifierFactory_ #define __RAT_Classifier_ClassifierFactory_ #include #include #include namespace RAT { namespace Classifiers { class ClassifierFactory { public: /// Returns the only instance of the class static ClassifierFactory* GetInstance() { return Get(); } inline static ClassifierFactory* Get(); /// Register a classifier in the factory /// /// An example call is Register( MyClassifier::GetName(), new Alloc()) /// /// @param[in] name of the classifier /// @param[in] allocator instance of an Alloc with the correct classifier type void Register( std::string name, AllocBase* allocator ); /// Returns the method by name Classifier* GetClassifier( const std::string name ); ///< Classifier name or name-init, init will be passed to the method private: /// Private constructor to prevent instantiation ClassifierFactory(); Factory fFactory; ///< Classifier factory, contains allocators for Classifiers }; inline ClassifierFactory* ClassifierFactory::Get() { static ClassifierFactory classifierFactory; return &classifierFactory; } } //::Classifier } //::RAT #endif