FRIBParallelanalysis
1.0
FrameworkforMPIParalleldataanalysisatFRIB
|
#include <TreeVariableArray.h>
Public Member Functions | |
CTreeVariableArray () | |
CTreeVariableArray (std::string baseName, double initialValue, std::string units, unsigned size, int firstIndex=0) | |
CTreeVariableArray (std::string baseName, unsigned size, int firstIndex=0) | |
CTreeVariableArray (const CTreeVariableArray &rhs) | |
~CTreeVariableArray () | |
void | Initialize (std::string baseName, double initialValue, std::string units, unsigned size, int firstElement) |
CTreeVariable & | operator[] (int index) |
const CTreeVariable & | operator[] (int index) const |
CTreeVariableArray & | operator= (const CTreeVariableArray &rhs) |
unsigned | size () const |
int | firstIndex () const |
Protected Member Functions | |
void | BuildArray (std::string basename, unsigned int size, const CTreeVariable::Definition &example) |
void | CopyArray (const CTreeVariableArray &rhs) |
This class wraps a vector of tree variables in a nice convenient package. The treevariables are named given a base name, one more level of hierarchy and individual names like nn where nn is a number with enough digits to ensure a good sort order. For example, if I have 16 pads in some detector named somedetector.fp, the individual variables might have names like: somedetector.fp.00, somedetector.fp.01 .. somedetector.fp.10 .. somedetector.fp. 15
The vector wrapping also allows for a first index specification much like in Fortran where you can do dimension a(firstdim:lastdim) .. although for 'traditional' reasons tree prameters express this as firstdim,size. The original implementation required firstdim positive. Fortran and this implementation make no such restrictions, allowing negative indices if this is appropriate to the application.. in the example above, if the first index was given as -1, the names might be e.g.: somedetector.fp.-01, somedetector.fp.00 .. somedetector.fp.14
frib::analysis::CTreeVariableArray::CTreeVariableArray | ( | ) |
Default constructor... Creates a tree variable array that has an empty vector, and therefore no elements.
frib::analysis::CTreeVariableArray::CTreeVariableArray | ( | const CTreeVariableArray & | rhs | ) |
Copy constructor. The array of variables is deep copied to produce a duplicate set, bound to the same underlying variables... unless the vector is empty in which case we have duplicated an empty variable.
rhs | The source of the copy construction |
frib::analysis::CTreeVariableArray::~CTreeVariableArray | ( | ) |
Destroys the tree variable and its contents. Note that while the binding to the underlying TCLVariables is obviously undone, the variables themselves are left alone.
|
protected |
Builds up the new array.
basename | Base name used to construct the individual names. |
size | Number of elements in the array. |
example | Sample properties that will be used to construct the individual elements. |
|
protected |
Copys the member elements from a rhs CTreeVariableArray into the current object. This utility is used both by assignment and copy construction.
rhs | The source of the copy. |
int frib::analysis::CTreeVariableArray::firstIndex | ( | ) | const |
Return the value of the lowest index (could be negative).
void frib::analysis::CTreeVariableArray::Initialize | ( | std::string | baseName, |
double | initialValue, | ||
std::string | units, | ||
unsigned | size, | ||
int | firstElement | ||
) |
Intended for use with a variable array that was default constructed.Any existing array is destroyed, and a new one built.
baseName | Name used to construct element names. |
initialValue | The value to be assigned to the elements. |
units | The units of measure of the elements of the array. |
size | number of array elements. |
firstElement | Lowest numbered index. |
CTreeVariableArray & frib::analysis::CTreeVariableArray::operator= | ( | const CTreeVariableArray & | rhs | ) |
Values in the rhs are copied to the values of the LHS.
rhs |
CTreeVariable & frib::analysis::CTreeVariableArray::operator[] | ( | int | index | ) |
Indexes in to the array of tree variables and returns the selected element (throw on range errors).
index | Index into the array. |
unsigned frib::analysis::CTreeVariableArray::size | ( | ) | const |
return the number of elements in the array (could be 0).