////////////////////////////////////////////////////////////////////////
/// \class RAT::PMTSelectors::PMTSelectorFactory
///
/// \brief Factory for Just In Time creation of selectors
///
/// \author Phil G Jones
/// \author Matt Mottram < m.mottram@qmul.ac.uk> -- contact person
///
/// REVISION HISTORY:\n
/// 05/06/2011 : P G Jones - New file \n
/// 2014-07-17 : P G Jones - Add register method.\n
///
/// \details Allows selectors to be newed by string name, when required.
/// This is a singleton class.
///
////////////////////////////////////////////////////////////////////////
#ifndef __RAT_PMTSelector_PMTSelectorFactory__
#define __RAT_PMTSelector_PMTSelectorFactory__
#include
#include
#include
namespace RAT
{
namespace DS
{
class EV;
class Run;
}
namespace PMTSelectors
{
class PMTSelectorFactory
{
public:
/// Returns the only instance of the class
inline static PMTSelectorFactory* Get();
/// Register a selector in the factory
///
/// An example call is Register( MyPMTSelector::GetName(), new Alloc())
///
/// @param[in] name of the selector
/// @param[in] allocator instance of an Alloc with the correct selector type
void Register( std::string name, AllocBase* allocator );
/// Returns the method by name
PMTSelector* GetPMTSelector( const std::string name ); ///< PMTSelector name or name-init, init will be passed to the method
private:
/// Private constructor to prevent instantiation
PMTSelectorFactory();
Factory fFactory; ///< PMTSelector factory, contains allocators for PMTSelectors
};
inline PMTSelectorFactory*
PMTSelectorFactory::Get()
{
static PMTSelectorFactory selectorFactory;
return &selectorFactory;
}
} //::PMTSelector
} //::RAT
#endif