FRIBParallelanalysis
1.0
FrameworkforMPIParalleldataanalysisatFRIB
|
#include <TreeVariable.h>
Classes | |
struct | _Definition |
Public Types | |
typedef struct frib::analysis::CTreeVariable::_Definition | Definition |
typedef struct frib::analysis::CTreeVariable::_Definition * | pDefinition |
typedef std::map< std::string, Definition >::iterator | TreeVariableIterator |
Public Member Functions | |
CTreeVariable () | |
CTreeVariable (std::string name) | |
CTreeVariable (std::string name, std::string units) | |
CTreeVariable (std::string name, double value, std::string units) | |
CTreeVariable (std::string name, const Definition &properties) | |
CTreeVariable (const CTreeVariable &rhs) | |
~CTreeVariable () | |
void | Initialize (std::string name, double value, std::string units) |
void | Bind () |
operator double () const | |
CTreeVariable & | operator= (double rhs) |
CTreeVariable & | operator= (const CTreeVariable &rhs) |
CTreeVariable & | operator+= (double rhs) |
CTreeVariable & | operator-= (double rhs) |
CTreeVariable & | operator*= (double rhs) |
CTreeVariable & | operator/= (double rhs) |
double | operator++ (int dummy) |
CTreeVariable & | operator++ () |
double | operator-- (int dummy) |
CTreeVariable & | operator-- () |
std::string | getName () const |
double | getValue () const |
void | setValue (double newValue) |
std::string | getUnit () const |
void | setUnit (const char *pUnits) |
bool | hasChanged () const |
bool | valueChanged () const |
void | resetChanged () |
Static Public Member Functions | |
static pDefinition | lookupDefinition (const char *name) |
static std::vector< std::string > | getNames () |
static std::vector< std::pair< std::string, const Definition * > > | getDefinitions () |
static TreeVariableIterator | begin () |
static TreeVariableIterator | end () |
static TreeVariableIterator | find (std::string name) |
static size_t | size () |
A tree variable is something that looks like a double value. It has additional metadata including:
In normal computational use, the values of treevariables wold get established via an exteranl mechanism, such as a script and the computation would then use the value of these variables to steer computation. An example use case might be the production of a calibrated parameter from a raw parameter and some calibration coefficients that represent the fit of an estimate of the calibration function to some polynomial.
As they like to say, the use of Tree variables is limited only by your imagination but, if you find yourself coding constants of creating variables that you change from run to run, consider replacing those constants/variables with a tree paramter whose values are set at run time.
frib::analysis::CTreeVariable::CTreeVariable | ( | ) |
constructor Default constructor is unbound from a data block. Initialize must be called prior to use:
frib::analysis::CTreeVariable::CTreeVariable | ( | std::string | name | ) |
constructor
name | - name of the variable. |
frib::analysis::CTreeVariable::CTreeVariable | ( | std::string | name, |
std::string | units | ||
) |
constructor
name | - name of the variable. |
units | - Units for a new one. |
frib::analysis::CTreeVariable::CTreeVariable | ( | std::string | name, |
double | value, | ||
std::string | units | ||
) |
constructor
name | - variable name. |
value | -initial variable value. |
units | - units of measure. |
frib::analysis::CTreeVariable::CTreeVariable | ( | std::string | name, |
const Definition & | properties | ||
) |
construct from definition
name | -name of parameter. |
def | - References the definition. |
frib::analysis::CTreeVariable::CTreeVariable | ( | const CTreeVariable & | rhs | ) |
copy construction.
frib::analysis::CTreeVariable::~CTreeVariable | ( | ) |
Destructor doesn't actually have to do anything:
|
static |
begin Provide standard iteration support for the tree variable dict.
void frib::analysis::CTreeVariable::Bind | ( | ) |
Bind This is a no-op but preserved for compatibility with old programs.
|
static |
end Provide standard iteration support for the tree variable dict.
|
static |
getDefinitions.
std::string frib::analysis::CTreeVariable::getName | ( | ) | const |
getName
|
static |
getNames Collect the names of all tree variables:
std::string frib::analysis::CTreeVariable::getUnit | ( | ) | const |
getUnit Return units if bound else throw std::Logic_error.
double frib::analysis::CTreeVariable::getValue | ( | ) | const |
getValue Return the value of the variable if it's bound else throw std::Logic_error.
bool frib::analysis::CTreeVariable::hasChanged | ( | ) | const |
hasChanged
void frib::analysis::CTreeVariable::Initialize | ( | std::string | name, |
double | value, | ||
std::string | units | ||
) |
Initialize Do full initialization of a tree variable.
name | - name of of the variable. |
value | - initial value (replaces existing value). |
units | - units of measure(replaces any existing). |
|
static |
lookupDefinition Try to find a definition given its name
name | - name to lookup. |
nullptr | -if there's no match. |
frib::analysis::CTreeVariable::operator double | ( | ) | const |
operator double This is a call to getValue which does all the bind checking etc.
CTreeVariable & frib::analysis::CTreeVariable::operator*= | ( | double | rhs | ) |
*=
double frib::analysis::CTreeVariable::operator++ | ( | int | dummy | ) |
postincrement
CTreeVariable & frib::analysis::CTreeVariable::operator++ | ( | ) |
Pre increment
CTreeVariable & frib::analysis::CTreeVariable::operator+= | ( | double | rhs | ) |
+=
double frib::analysis::CTreeVariable::operator-- | ( | int | dummy | ) |
post decrement
CTreeVariable & frib::analysis::CTreeVariable::operator-- | ( | ) |
predecrement
CTreeVariable & frib::analysis::CTreeVariable::operator-= | ( | double | rhs | ) |
-=
CTreeVariable & frib::analysis::CTreeVariable::operator= | ( | double | rhs | ) |
operator= Assignment from double Uses setValue which does bind checking
CTreeVariable & frib::analysis::CTreeVariable::operator= | ( | const CTreeVariable & | rhs | ) |
assignment from another tree variable
rhs | - the other tree variable. |
void frib::analysis::CTreeVariable::resetChanged | ( | ) |
resetChanged reset the changed flags to false:
void frib::analysis::CTreeVariable::setUnit | ( | const char * | pUnits | ) |
setUnit New units of measure
void frib::analysis::CTreeVariable::setValue | ( | double | newValue | ) |
setValue set a new value for the variable if bound or throw std::logic_error.
newValue |
|
static |
size
bool frib::analysis::CTreeVariable::valueChanged | ( | ) | const |
valueChanged