///////////////////////////////////////////////////////////////////////
//
// Factory for Just In Time creation of methods
//
// Author: Phil G Jones
// Author: Matt Mottram -- contact person
//
// REVISION HISTORY:
// 26/04/2011 : P G Jones - New file
// 2014-07-17 : P G Jones - Add register method.
// 2015-04-15 : J Walker - Add EnergyPromptLookup method.
// 2015-05-06 : M Mottram - Added PartialEnergy method.
// 2015-09-28 : J Walker - Add EnergyRSP method.
// 2016-06-08 : J Walker - Add EnergyPromptHits method.
// 2019-09-06 : Yang Zhang - Added QPartialEnergy method.
//
// Allows methods to be newed by string name, when required.
// This is a singleton class.
//
///////////////////////////////////////////////////////////////////////
#ifndef __RAT_Method_MethodFactory_
#define __RAT_Method_MethodFactory_
#include
#include
#include
namespace RAT
{
namespace Methods
{
class MethodFactory
{
public:
// Returns the only instance of the class
static MethodFactory* GetInstance() { return Get(); }
inline static MethodFactory* Get();
// Register a method in the factory
//
// An example call is Register( MyMethod::GetName(), new Alloc())
//
// "name" is the name of the method
// "allocator" is an instance of an Alloc with the correct method type
void Register( std::string name, AllocBase* allocator );
// Returns the method by name
Method* GetMethod( const std::string name ); // Method name or name-init, init will be passed to the method
private:
// Private constructor to prevent instantiation
MethodFactory();
Factory fFactory; // Method factory, contains allocators for Methods
};
inline MethodFactory*
MethodFactory::Get()
{
static MethodFactory methodFactory;
return &methodFactory;
}
} //::Method
} //::RAT
#endif