/////////////////////////////////////////////////////////////////// // // Abstract base class for factory that construct a Processor. See // ProcAllocatorTmpl for an explanation of what this is for. // // Author: Stan Seibert // /////////////////////////////////////////////////////////////////// #ifndef __RAT_ProcAllocator__ #define __RAT_ProcAllocator__ namespace RAT { class Processor; class ProcAllocator { public: /* Returns new instance of a Processor. * * This must be overridden by subclass to return a particular kind * of processor. */ virtual Processor *operator() ()=0; virtual ~ProcAllocator() { }; }; /* * Template for creating Processor factories. * * Author: Stan Seibert * * This class exists because there is no notion of a "virtual * constructor" in C++. In particular, it is used in * ProcBlockManager::ProcBlockManager() to create a map which * lets you take a string and construct a particular processor. The * usage in that class is: * * procAllocators["frontend"]= new ProcAllocatorTmpl; * procAllocators["trigger"]= new ProcAllocatorTmpl; * procAllocators["eventbuilder"]= new ProcAllocatorTmpl; * procAllocators["simpledaq"]= new ProcAllocatorTmpl; * etc, etc... * * And later, it can then create an instance of FrontEndProc by * doing this: * * proc = (*procAllocators[procname])(); * * * If this does not quite make sense, don't worry, you probably don't * need this class. * * T: Processor class instantiated by this factory. Must be * subclass of Processor. */ template class ProcAllocatorTmpl : public ProcAllocator { public: /* Create new instance of processor subclass T */ virtual Processor *operator() () { return new T; }; virtual ~ProcAllocatorTmpl() { }; }; } // namespace RAT #endif