CModuleFactory

Name

CModuuleFactory -- Creates specific slow control drivers

Synopsis


            class CModuleFactory {
           
  static  CModuleFactory*  instance();
                void  addCreator(std::string  type,  CModuleCreator*  pCreator);
              CControlHardware* create(std::string  type, std::string  name);
   
};
        

DESCRIPTION

This class provides a factory that allows the Module create slow control server command to instantiate driver objects from the name of the class. The factory operates by matching a driver type with a creator object. The creator object then instantiates the actual object.

Note that CModuleFactory is a singleton. See instance in METHODS below for information about how to get a pointer to the singleton instance of this class,.

METHODS

static CModuleFactory* instance();

Returns a pointer to the singleton instance of this class. The class constructor and destructor are private to the class so this is the only clean C++ mechanism to gain access to a CModuleFactory object.

void addCreator(std::string type, CModuleCreator* pCreator);

Associates a new creator object with a module type. type is the name of the module type. When this type is used in a Module create command, the creator specified by pCreator is used to generate the module object.

Note that the object pointed to by pCreator must live for the duration of the program.

CControlHardware* create(std::string type, std::string name);

Creates a specific type of slow control driver named name. The driver object is dynamically created. If it is necessary to destroy it that must be done with delete.