Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

CStateVariable Class Reference

#include <CStateVariable.h>

List of all members.

Public Methods

 CStateVariable (CTCLInterpreter *pInterp, const string &rName)
 constructor.

 CStateVariable (const CStateVariable &rhs)
 Copy constructor.

 ~CStateVariable ()
 Destructor.

CStateVariable & operator= (const CStateVariable &rhs)
 Assignment.

int operator== (const CStateVariable &rhs) const
 Comparison for equality.

int operator!= (const CStateVariable &rhs) const
CRunStategetState ()
string getScalarValue () const
map< string, string > getArrayValues () const
string FormatForBuffer ()
 Format for output.

virtual char * operator() (char *pName, char *pIndex, int flags)
 trace writes.


Private Attributes

string m_ScalarValue
 Holds the last value of the variable if it is a scalar.

map< string, string > m_ArrayValues
 Last value of indexed element of an array.


Static Private Attributes

CRunStatem_pState = 0
 Refers to the current run state.


Constructor & Destructor Documentation

CStateVariable::CStateVariable CTCLInterpreter *    pInterp,
const string &    rName
 

constructor.

Constructs a state variable. State variables are Tcl variable which are dumped to the event stream at key points in the run. State Variables are also protected against writes and unsets when the run is not halted. State variables are intended to hold 'constants of a run'.

Parameters:
pInterp  - The TCL interpreter on which the state variable will be defined.
rName  - The name of the variable.
Note:
Run State variables can represent arrays. Since traces are set the set of array elements defined can and will be built up in the m_ArrayValues map.

Definition at line 310 of file CStateVariable.cpp.

References CReadoutMain::getInstance(), CReadoutMain::getRunState(), and m_pState.

CStateVariable::CStateVariable const CStateVariable &    rhs
 

Copy constructor.

Copy construction. This is invoked when e.g. an object is passed by value to a function. The copy constructor makes a clone of the rhs object.

Note:
THis is only possible because multiple traces can be set and fired on a single variable/array.

Definition at line 326 of file CStateVariable.cpp.

CStateVariable::~CStateVariable   [inline]
 

Destructor.

Definition at line 314 of file CStateVariable.h.


Member Function Documentation

string CStateVariable::FormatForBuffer  
 

Format for output.

Called to format the state variable for inclusion in an event buffer. There are two possibilities:

  • The state variable is a scalar (m_ArrayValues.empty() == true). In this case a single entry is created containing the string: "set name value
    "
  • The state variable represents an array (m_ArrayValues.empty() == false). in this case we produce a series of lines of text in the string of the form "set name(index) value
    ". This can cause a problem which for now we ignore. If the total size of the returned string is larger than the buffersize-headersize, it's not possible to fit this into a single buffer.
Bug:
  • Large arrays may be impossible to fit into single buffers. In the future, it will be necessary to fix this in the caller or in the functional interface.

Definition at line 379 of file CStateVariable.cpp.

References arrayiterator, and m_ArrayValues.

Referenced by CExperiment::EmitStateVariableBuffer().

map<string,string> CStateVariable::getArrayValues   const [inline]
 

Definition at line 332 of file CStateVariable.h.

References m_ArrayValues.

string CStateVariable::getScalarValue   const [inline]
 

Definition at line 328 of file CStateVariable.h.

References m_ScalarValue.

CRunState* CStateVariable::getState   [inline]
 

Definition at line 324 of file CStateVariable.h.

int CStateVariable::operator!= const CStateVariable &    rhs const [inline]
 

Definition at line 317 of file CStateVariable.h.

References operator==().

char * CStateVariable::operator() char *    pName,
char *    pIndex,
int    flags
[virtual]
 

trace writes.

Called when the state variable trace fires. Two possible traces can fire:

  • TCL_TRACE_WRITES - A write is being attempted. If the run state is halted, the write is allowed. If not, the old value is rolled back and a failure string is returned.
  • TCL_TRACE_UNSETS This breaks down into subcases: # If TCL_TRACE_INTERP_DESTROYED, this is a no-op. We have to allow the unset if the interpreter is getting yanked out from underneath us. # If TCL_TRACE_DESTROYED, this is also a no-op since it probably means we are running from the destructor. # If the run is not halted, then the variable is re-created. # If the run is halted, we disable traces. Unfortunately, we don't have the technology to support self immolation, however if the unset is done on an array element, we can remove it's entry from m_ArrayValues.

Definition at line 439 of file CStateVariable.cpp.

References CRunState::getState(), CRunState::Inactive, m_ArrayValues, m_pState, and m_ScalarValue.

CStateVariable & CStateVariable::operator= const CStateVariable &    rhs
 

Assignment.

Assignment operation. This member function supports assignment of an object of this class to an object of the same class.

Definition at line 338 of file CStateVariable.cpp.

References m_ArrayValues, and m_ScalarValue.

int CStateVariable::operator== const CStateVariable &    rhs const
 

Comparison for equality.

Compare for equality:

Definition at line 354 of file CStateVariable.cpp.

References m_ArrayValues, and m_ScalarValue.

Referenced by operator!=().


Member Data Documentation

map<string,string> CStateVariable::m_ArrayValues [private]
 

Last value of indexed element of an array.

Definition at line 306 of file CStateVariable.h.

Referenced by FormatForBuffer(), getArrayValues(), operator()(), operator=(), and operator==().

CRunState * CStateVariable::m_pState = 0 [static, private]
 

Refers to the current run state.

Definition at line 287 of file CStateVariable.cpp.

Referenced by CStateVariable(), and operator()().

string CStateVariable::m_ScalarValue [private]
 

Holds the last value of the variable if it is a scalar.

Definition at line 305 of file CStateVariable.h.

Referenced by getScalarValue(), operator()(), operator=(), and operator==().


The documentation for this class was generated from the following files:
Generated on Fri Nov 8 13:37:24 2002 for Event Readout system. by doxygen1.2.16