CModuleCreator

Name

CModuleCreator  -- Scripted readout base class for module creators

Synopsis


             CModuleCreator 
           
  CModuleCreator (const std::string& rType)
          throws ;
           
  const std::string  getModuleType ()
          throws ;
              const bool     Match (const  std::string& rType)
          throws ;
  
              virtual   = 0 CReadableObject*  Create (CTCLInterpreter&  rInterp, CTCLResult&  rResult, int  nArgs, char**  pArgs)
          throws ;
  
              virtual  = 0 std::string   Help   ()
          throws ;
  
    
        

DESCRIPTION

The scripted readout module create command relies on a set of CModuleCreator objects to do the actual creation. The application registers these with the CModuleCommand. This is the key to the extensibility of this framework, as it implies that the module create command can create an extensible set of module objects.

To build a module creator, the application programmer needs to derive an object from CModuleCommand and implement that object's Create and Help methods.

METHODS

CModuleCreator (const std::string& rType) throws ;

The rType parameter of the constructor defines the keyword that must be matched for this creator to be used to create a module. For example, the command:


module create amodule mymoduletype
                        

Will use the module creator that was constructed with the rType set to mymoduletype

const std::string getModuleType () throws ;

This method just returns the value of rValue as passed into the constructor. In the example in the constructor documentation, the creator would return mymoduletype.

const bool Match (const std::string& rType) throws ;

Returns true if rType is the same as the string passed in to the contructor. To continue the example above, if rType were mymoduletype this method would return true, otherwise false is returned.

This mmethod is used by the module command to determine which creator can handle a specific module type.

virtual = 0 CReadableObject* Create (CTCLInterpreter& rInterp, CTCLResult& rResult, int nArgs, char** pArgs) throws ;

Must be defined by concrete subclasses. This method is expected to create the CReadableObject expected by the module command registering it on the rInterp. In practice note that CReadableObject constructors self register the object.

The nArgs and pArgs parameters are the number and pointers to the words in the command tail. Specifically, *pArgs is a pointer to the module name and *(pArgs+1) is a pointer to the module type.

By convention, if there are any additional command parameter words after the module type, these are passed to the Configure method of the newly created module. This allows for one-step creation and configuration.

virtual = 0 std::string Help () throws ;

Returns a string that is used by the module command when describing the set of modules that can be created. This is used in pseudo code like:


std::string helpstring
foreach modulecreator
    helpstring += modulecreator.getModuleType()
               +  " " + modulecreator.Help() + "\n";