Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

CConfigurableObject Class Reference

#include <CConfigurableObject.h>

Inheritance diagram for CConfigurableObject:

Inheritance graph
[legend]
List of all members.

Public Types

typedef list< CConfigurationParameter * > ConfigArray
typedef ConfigArray::iterator ParameterIterator
typedef list< CConfigurationParameter * > ConfigArray
typedef ConfigArray::iterator ParameterIterator

Public Member Functions

 CConfigurableObject (const string &rName, CTCLInterpreter &rInterp)
virtual ~CConfigurableObject ()
string getName () const
 Retrieve a copy of the name:.

virtual int operator() (CTCLInterpreter &rInterp, CTCLResult &rResult, int nArgs, char **pArgs)
 Process commands.

virtual int Configure (CTCLInterpreter &rInterp, CTCLResult &rResult, int nArgs, char **pArgs)
 config subcommand

virtual int ListConfiguration (CTCLInterpreter &rInterp, CTCLResult &rResult, int nArgs, char **pArgs)
 list subcommand

ParameterIterator AddIntParam (const string &sParamName, int nDefault=0)
 Create an int.

ParameterIterator AddBoolParam (const string &rName, bool fDefault)
 Create a boolean.

ParameterIterator AddStringParam (const string &rName)
 Create string param.

ParameterIterator AddIntArrayParam (const string &rParameterName, int nArraySize, int nDefault=0)
 Create array of ints.

ParameterIterator AddStringArrayParam (const string &rName, int nArraySize)
 Create array of strings.

ParameterIterator Find (const string &rKeyword)
 Find a param.

ParameterIterator begin ()
 Config param start iterator.

ParameterIterator end ()
 Config param end iterator.

int size ()
 Config param number of items.

string ListParameters (const string &rPattern)
 List configuration.

string ListKeywords ()
 List keyword/type pairs.

 CConfigurableObject (const string &rName, CTCLInterpreter &rInterp)
virtual ~CConfigurableObject ()
virtual int operator() (CTCLInterpreter &rInterp, CTCLResult &rResult, int nArgs, char **pArgs)
 Process commands.

int Configure (CTCLInterpreter &rInterp, CTCLResult &rResult, int nArgs, char **pArgs)
 config subcommand

int ListConfiguration (CTCLInterpreter &rInterp, CTCLResult &rResult, int nArgs, char **pArgs)
 list subcommand

ParameterIterator AddIntParam (const string &sParamName, int nDefault=0)
 Create an int.

ParameterIterator AddBoolParam ()
 Create a boolean.

ParameterIterator AddStringParam (const string &rName)
 Create string param.

ParameterIterator AddIntArrayParam (const string &rParameterName, int nArraySize, int nDefault=0)
 Create array of ints.

ParameterIterator AddStringArrayParam (const string &rName, int nArraySize)
 Create array of strings.

void DeleteParameters ()
 Delete all parameters.

ParameterIterator Find (const string &rKeyword)
 Find a param.

ParameterIterator begin ()
 Config param start iterator.

ParameterIterator end ()
 Config param end iterator.

int size ()
 Config param number of items.

string ListParameters (CTCLInterpreter &rInterp, const string &rPattern)
 List configuration.

string ListKeywords ()
 List keyword/type pairs.

virtual bool isMySubcommand (const string &rKeyword)
 Valid subcomand?


Protected Member Functions

string Usage ()

Private Member Functions

 CConfigurableObject (const CConfigurableObject &aCConfigurableObject)
CConfigurableObjectoperator= (const CConfigurableObject &aCConfigurableObject)
int operator== (const CConfigurableObject &aCConfigurableObject) const
void DeleteParameters ()
 Delete all parameters.

 CConfigurableObject (const CConfigurableObject &aCConfigurableObject)
CConfigurableObjectoperator= (const CConfigurableObject &aCConfigurableObject)
int operator== (const CConfigurableObject &aCConfigurableObject) const

Private Attributes

string m_sName
 Name of the command associated with the object.

ConfigArray m_Configuration
 The configuration.


Detailed Description

Base class of all objects that have a TCL configurable configuration. The configuration object autonomously processes the config an cget subcommands to maintain a configuration parameter database. Configuration consists of a set of configuration parameter objects.

Each of these represents a keyword/value pair.

Definition at line 336 of file CConfigurableObject.h.


Member Typedef Documentation

typedef list<CConfigurationParameter*> CConfigurableObject::ConfigArray
 

Reimplemented in CDigitizerModule.

Definition at line 339 of file include/CConfigurableObject.h.

typedef list<CConfigurationParameter*> CConfigurableObject::ConfigArray
 

Reimplemented in CDigitizerModule.

Definition at line 340 of file CConfigurableObject.h.

typedef ConfigArray::iterator CConfigurableObject::ParameterIterator
 

Reimplemented in CDigitizerModule.

Definition at line 340 of file include/CConfigurableObject.h.

typedef ConfigArray::iterator CConfigurableObject::ParameterIterator
 

Reimplemented in CDigitizerModule.

Definition at line 341 of file CConfigurableObject.h.

Referenced by Configure(), CReadOrder::CReadOrder(), DeleteParameters(), Find(), ListKeywords(), and ListParameters().


Constructor & Destructor Documentation

CConfigurableObject::CConfigurableObject const string &  rName,
CTCLInterpreter &  rInterp
 

Construct a Configurable object:

  • The name is saved in m_sName.
  • The base class is initialized to create a command that is the same as the name.
  • The command is registered with the interpreter.
    Parameters:
    rName (const string&): The string that identifies this object as well as the name of the command that will be created.
    rInterp (CTCLInterpreter): The TCL Interpreter on which this command will be registered.

Definition at line 303 of file CConfigurableObject.cpp.

CConfigurableObject::~CConfigurableObject  )  [virtual]
 

Destructor: The configuration parmaters pointed to by the elements of the list are assumed to be dynamically allocated (as they will be if they are created with our convenience functions. They must be deleted. The list elements themselves are assumed to be destroyed by the list destructors.

Definition at line 320 of file CConfigurableObject.cpp.

References DeleteParameters().

CConfigurableObject::CConfigurableObject const CConfigurableObject aCConfigurableObject  )  [private]
 

CConfigurableObject::CConfigurableObject const string &  rName,
CTCLInterpreter &  rInterp
 

virtual CConfigurableObject::~CConfigurableObject  )  [virtual]
 

CConfigurableObject::CConfigurableObject const CConfigurableObject aCConfigurableObject  )  [private]
 


Member Function Documentation

ParameterIterator CConfigurableObject::AddBoolParam  ) 
 

Create a boolean.

Referenced by CCAENModule::CCAENModule(), CCAENV775::CCAENV775(), CCAENV830Module::CCAENV830Module(), and CReadOrder::CReadOrder().

CConfigurableObject::ParameterIterator CConfigurableObject::AddBoolParam const string &  rName,
bool  fDefault
 

Create a boolean.

Function:

Adds a boolean parameter to the set of parameters that are recognized by the default Configure parser.

Parameters:
rName const string& [in] Name of the parameter to create.
fDefault bool [in] = false Defaults value of the parameter.

Reimplemented in CDigitizerModule.

Definition at line 587 of file CConfigurableObject.cpp.

References Find(), and m_Configuration.

ParameterIterator CConfigurableObject::AddIntArrayParam const string &  rParameterName,
int  nArraySize,
int  nDefault = 0
 

Create array of ints.

Reimplemented in CDigitizerModule.

CConfigurableObject::ParameterIterator CConfigurableObject::AddIntArrayParam const string &  rParamName,
int  nArraySize,
int  nDefault = 0
 

Create array of ints.

Adds an array of parameters to the set of configuration parameter that are parsed by the default Configure function.

Parameters:
rParamName const string& [in] Name of the parameter to add.
nArraySize int [in] Size of the parameter array expected.
nDefault int [in] = 0 Default value of the array elements.

Reimplemented in CDigitizerModule.

Definition at line 563 of file CConfigurableObject.cpp.

References Find(), and m_Configuration.

ParameterIterator CConfigurableObject::AddIntParam const string &  sParamName,
int  nDefault = 0
 

Create an int.

Reimplemented in CDigitizerModule.

CConfigurableObject::ParameterIterator CConfigurableObject::AddIntParam const string &  sParamName,
int  nDefault = 0
 

Create an int.

Adds an integer configuration parameter to the set recognized by the default configuration parser.

Parameters:
sParamName const string& [in] Name of parameter to add.
nDefault int [in] = 0 The default value of the parameter.

Reimplemented in CDigitizerModule.

Definition at line 540 of file CConfigurableObject.cpp.

References Find(), and m_Configuration.

Referenced by CReadOrder::CReadOrder().

ParameterIterator CConfigurableObject::AddStringArrayParam const string &  rName,
int  nArraySize
 

Create array of strings.

Reimplemented in CDigitizerModule.

CConfigurableObject::ParameterIterator CConfigurableObject::AddStringArrayParam const string &  rName,
int  nArraySize
 

Create array of strings.

Adds a string array parameter to the set of parameters recognized by this module. A string array parameter has a parameter that is a tcl formatted list where each list element is an arbitrary string.

Parameters:
rName (const string & [in]): The name of the configuration parameter.
nArrayAzie (int [in]): The number of elements in the array.

Reimplemented in CDigitizerModule.

Definition at line 625 of file CConfigurableObject.cpp.

References Find(), and m_Configuration.

ParameterIterator CConfigurableObject::AddStringParam const string &  rName  ) 
 

Create string param.

Reimplemented in CDigitizerModule.

CConfigurableObject::ParameterIterator CConfigurableObject::AddStringParam const string &  rName  ) 
 

Create string param.

Adds a string parameter to the set of parameters recognized by this module. A string parameter is a parameter with a single string valued value.

Parameters:
rName (const string& [in]): Name of the new parameter.

Reimplemented in CDigitizerModule.

Definition at line 606 of file CConfigurableObject.cpp.

References Find(), and m_Configuration.

ParameterIterator CConfigurableObject::begin  ) 
 

Config param start iterator.

Reimplemented in CDigitizerModule, and CReadOrder.

CConfigurableObject::ParameterIterator CConfigurableObject::begin  ) 
 

Config param start iterator.

Returns:
CConfigurableObject::ParameterIterator Returns a begin of loop iterator that 'points' to the first configuration parameter.

Reimplemented in CDigitizerModule, and CReadOrder.

Definition at line 680 of file CConfigurableObject.cpp.

References m_Configuration.

Referenced by DeleteParameters().

int CConfigurableObject::Configure CTCLInterpreter &  rInterp,
CTCLResult &  rResult,
int  nArgs,
char **  pArgs
 

config subcommand

Reimplemented in CDigitizerModule.

int CConfigurableObject::Configure CTCLInterpreter &  rInterp,
CTCLResult &  rResult,
int  nArgs,
char **  pArgs
[virtual]
 

config subcommand

Function: int Configure(CTCLInterpreter& rInterp, CTCLResult& rResult, int nArgs, char** pArgs) Operation Type:

Purpose:

Handles the "configure" command. The default implementation is to assume configuration is a set of keyword value pairs. e.g:

  • -threshold 5
  • -pedestals {1 2, 3 4 5 6 7 8 9}
  • -subtraction enable

Each keyword is matched against the parameters in the following order. Naturally duplicate command keys are not a good thing.

  • m_IntParameters keys that accept single integer parameters
  • m_ArrayParameters keys that accept a fixed size list of integers
  • m_BoolParameters keys that accept a boolean flag.

See CConfigurationParameter CIntConfigParam CIntArrayParam CBoolConfigParam As many configuration options as can be performed get done. Any failures are reported by returning TCL_ERROR and placing stuff in the results string.

Parameters:
rInterp CTCLInterpreter& [in] Interpreter running the command.
rResult CTCLResult [in] Result string that is filled in either by us or by the configuration dudes.
nArgs int [in] Count of remaining parameters. the first one should be the first configuration keyword.
pArgs char** [in] The text of the parameters.

Reimplemented in CDigitizerModule.

Definition at line 435 of file CConfigurableObject.cpp.

References Find(), m_Configuration, ParameterIterator, and Usage().

Referenced by CPacketCreator::Create(), CCAENV830Creator::Create(), CCAENV785Creator::Create(), and operator()().

void CConfigurableObject::DeleteParameters  ) 
 

Delete all parameters.

Reimplemented in CDigitizerModule.

void CConfigurableObject::DeleteParameters  )  [private]
 

Delete all parameters.

Delete the parameter arrays.

Reimplemented in CDigitizerModule.

Definition at line 784 of file CConfigurableObject.cpp.

References begin(), end(), m_Configuration, and ParameterIterator.

Referenced by ~CConfigurableObject().

ParameterIterator CConfigurableObject::end  ) 
 

Config param end iterator.

Reimplemented in CDigitizerModule, and CReadOrder.

CConfigurableObject::ParameterIterator CConfigurableObject::end  ) 
 

Config param end iterator.

Returns:
CConfigurableObject::ParameterIterator Returns an end of loop iterator that points just off the end of the m_Configuration collection.

Reimplemented in CDigitizerModule, and CReadOrder.

Definition at line 691 of file CConfigurableObject.cpp.

References m_Configuration.

Referenced by DeleteParameters().

ParameterIterator CConfigurableObject::Find const string &  rKeyword  ) 
 

Find a param.

Reimplemented in CDigitizerModule.

CConfigurableObject::ParameterIterator CConfigurableObject::Find const string &  rKeyword  ) 
 

Find a param.

Locate a parameter matching the configuration parameter test string.

Parameters:
rKeyword The keyword to check.

Reimplemented in CDigitizerModule.

Definition at line 764 of file CConfigurableObject.cpp.

References m_Configuration, CConfigurationParameter::Match(), and ParameterIterator.

Referenced by AddBoolParam(), AddIntArrayParam(), AddIntParam(), AddStringArrayParam(), AddStringParam(), and Configure().

string CConfigurableObject::getName  )  const [inline]
 

Retrieve a copy of the name:.

Reimplemented in CDigitizerModule.

Definition at line 366 of file CConfigurableObject.h.

References m_sName.

Referenced by CDigitizerDictionary::DigitizerAdd(), CReadOrder::Lister::operator()(), and CReadOrder::CompareName::operator()().

virtual bool CConfigurableObject::isMySubcommand const string &  rKeyword  )  [virtual]
 

Valid subcomand?

int CConfigurableObject::ListConfiguration CTCLInterpreter &  rInterp,
CTCLResult &  rResult,
int  nArgs,
char **  pArgs
 

list subcommand

Reimplemented in CDigitizerModule.

int CConfigurableObject::ListConfiguration CTCLInterpreter &  rInterp,
CTCLResult &  rResult,
int  nArgs,
char **  pArgs
[virtual]
 

list subcommand

Lists the current module configuration. The default implementation iterates through the set of m_IntParameters, m_ArrayParameters and m_BoolParameters producing pairs of {parametername values} such as:

  • {threshold 5}
  • {pedestals {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 }}
  • {subtraction on}

Note:
In the list, no distinction is made between the types of parameter values.

The string representationi is used, so the value of the bool will not be standardized, but will be whatever was used (e.g. on, 1 are both possible values.

Parameters:
rInterp CTCLInterpreter& [in] The interpreter that is running the command.
rResult CTCLResult& [in] The result string that will contain the configuration information.
nArgs int [in] Number of parameters, should be 0.
pArgs char** [in] text of parameters.
Note:
There should be at most 1 parameter. If present it is a glob pattern that will be used to filter the output. (essentially no parameter results in a pattern of *).
Returns:
Any of:
  • TCL_OK the configuraton was listed
  • TCL_ERROR the configuration could not be listed and rResult is an error string.

Reimplemented in CDigitizerModule.

Definition at line 508 of file CConfigurableObject.cpp.

References ListParameters(), and Usage().

Referenced by operator()().

string CConfigurableObject::ListKeywords  ) 
 

List keyword/type pairs.

Reimplemented in CDigitizerModule.

string CConfigurableObject::ListKeywords  ) 
 

List keyword/type pairs.

List the allowed configuration keywords. The words are returned as a string of pairs. The pairs are not a bracketed list, but just a pair of words. the first word of each pair is the command keyword. the second word is the parameter format as returned from CConfigurationParameter::GetParameterFormat()

Returns:
string - the results of the list.

Reimplemented in CDigitizerModule.

Definition at line 742 of file CConfigurableObject.cpp.

References m_Configuration, and ParameterIterator.

Referenced by Usage().

string CConfigurableObject::ListParameters CTCLInterpreter &  rInterp,
const string &  rPattern
 

List configuration.

Reimplemented in CDigitizerModule.

string CConfigurableObject::ListParameters const string &  rPattern  ) 
 

List configuration.

Produces a list of the configuration parameters that match the input pattern.

Parameters:
sPattern const string& [in] The glob string pattern.

Definition at line 715 of file CConfigurableObject.cpp.

References m_Configuration, and ParameterIterator.

Referenced by ListConfiguration().

virtual int CConfigurableObject::operator() CTCLInterpreter &  rInterp,
CTCLResult &  rResult,
int  nArgs,
char **  pArgs
[virtual]
 

Process commands.

Reimplemented in CReadOrder, CDigitizerModule, and CReadOrder.

int CConfigurableObject::operator() CTCLInterpreter &  rInterp,
CTCLResult &  rResult,
int  nArgs,
char **  pArgs
[virtual]
 

Process commands.

Processes the module's command. The default implementation is to look for matches of the pArgs[1] with:

  • "config" calls the module's Configure member. member function.
  • "cget" calls the module's ListConfiguration member function.
  • "help" calls the module's Usage member function.

Parameters:
rInterp CTCLInterpreter& [in] Interpreter running the command.
rResult CTCLResult& [in] The result string that will be returned to the caller.
nArgs int [in] The number of parameters on the command line. Note that the first one should be m_sName.
pArgs char** [in] The command parameters.
Returns:
Either of:
  • TCL_OK if the command completed properly or
  • TCL_ERROR if the command failed. If the command fails, rResult will be a descriptive error followed by the usage information for what we know:
Note:
To extend functionaly to support additional keyword, override this, check for your own keywords and if you don't find them, call the base class member with the unaltered parameters.

Reimplemented in CReadOrder, CDigitizerModule, and CReadOrder.

Definition at line 359 of file CConfigurableObject.cpp.

References Configure(), ListConfiguration(), m_sName, and Usage().

Referenced by CReadOrder::operator()().

CConfigurableObject& CConfigurableObject::operator= const CConfigurableObject aCConfigurableObject  )  [private]
 

CConfigurableObject& CConfigurableObject::operator= const CConfigurableObject aCConfigurableObject  )  [private]
 

int CConfigurableObject::operator== const CConfigurableObject aCConfigurableObject  )  const [private]
 

int CConfigurableObject::operator== const CConfigurableObject aCConfigurableObject  )  const [private]
 

int CConfigurableObject::size  ) 
 

Config param number of items.

Reimplemented in CReadOrder.

int CConfigurableObject::size  ) 
 

Config param number of items.

Returns:
int Returns the number of configuration parameters that are in the m_Configuration collection.

Reimplemented in CReadOrder.

Definition at line 702 of file CConfigurableObject.cpp.

References m_Configuration.

string CConfigurableObject::Usage  )  [protected]
 

Returns a string describing the command usage. The defafult implementation produces a string of the form:


m_sName config Paramdescription
m_sName cget
m_sName help

Paramdescription is produced by iterating through the set of configuration parameter descriptions and for each of them listing the name and the type expected e.g.:

  • theshold int
  • pedestal {int[16]}
  • subtraction on|off|enable|disable

Reimplemented in CReadOrder, CDigitizerModule, and CReadOrder.

Definition at line 658 of file CConfigurableObject.cpp.

References ListKeywords(), and m_sName.

Referenced by Configure(), ListConfiguration(), operator()(), and CReadOrder::Usage().


Member Data Documentation

ConfigArray CConfigurableObject::m_Configuration [private]
 

The configuration.

Reimplemented in CDigitizerModule.

Definition at line 344 of file include/CConfigurableObject.h.

Referenced by AddBoolParam(), AddIntArrayParam(), AddIntParam(), AddStringArrayParam(), AddStringParam(), begin(), Configure(), DeleteParameters(), end(), Find(), ListKeywords(), ListParameters(), and size().

string CConfigurableObject::m_sName [private]
 

Name of the command associated with the object.

Reimplemented in CDigitizerModule.

Definition at line 344 of file CConfigurableObject.h.

Referenced by getName(), operator()(), and Usage().


The documentation for this class was generated from the following files:
Generated on Fri Mar 12 13:04:34 2004 for Scripted Readout by doxygen 1.3.4