FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
frib::analysis::CTreeVariable Class Reference

#include <TreeVariable.h>

Classes

struct  _Definition
 

Public Types

typedef struct frib::analysis::CTreeVariable::_Definition Definition
 
typedef struct frib::analysis::CTreeVariable::_DefinitionpDefinition
 
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
 
CTreeVariableoperator= (double rhs)
 
CTreeVariableoperator= (const CTreeVariable &rhs)
 
CTreeVariableoperator+= (double rhs)
 
CTreeVariableoperator-= (double rhs)
 
CTreeVariableoperator*= (double rhs)
 
CTreeVariableoperator/= (double rhs)
 
double operator++ (int dummy)
 
CTreeVariableoperator++ ()
 
double operator-- (int dummy)
 
CTreeVariableoperator-- ()
 
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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CTreeVariable() [1/6]

frib::analysis::CTreeVariable::CTreeVariable ( )

constructor Default constructor is unbound from a data block. Initialize must be called prior to use:

◆ CTreeVariable() [2/6]

frib::analysis::CTreeVariable::CTreeVariable ( std::string  name)

constructor

Parameters
name- name of the variable.
Note
if this is a new variable we initialize the value - 0.0 and units to an empty string, otherwise we don't touch. the metadata - on the assumption we're trying to make another reference to the original

◆ CTreeVariable() [3/6]

frib::analysis::CTreeVariable::CTreeVariable ( std::string  name,
std::string  units 
)

constructor

Parameters
name- name of the variable.
units- Units for a new one.
Note
, if the variable exists, we replace the units but leave the value alone.

◆ CTreeVariable() [4/6]

frib::analysis::CTreeVariable::CTreeVariable ( std::string  name,
double  value,
std::string  units 
)

constructor

Parameters
name- variable name.
value-initial variable value.
units- units of measure.

◆ CTreeVariable() [5/6]

frib::analysis::CTreeVariable::CTreeVariable ( std::string  name,
const Definition properties 
)

construct from definition

Parameters
name-name of parameter.
def- References the definition.

◆ CTreeVariable() [6/6]

frib::analysis::CTreeVariable::CTreeVariable ( const CTreeVariable rhs)

copy construction.

◆ ~CTreeVariable()

frib::analysis::CTreeVariable::~CTreeVariable ( )

Destructor doesn't actually have to do anything:

Member Function Documentation

◆ begin()

CTreeVariable::TreeVariableIterator frib::analysis::CTreeVariable::begin ( )
static

begin Provide standard iteration support for the tree variable dict.

Returns
CTreeVarialbe::TreeVariableIterator

◆ Bind()

void frib::analysis::CTreeVariable::Bind ( )

Bind This is a no-op but preserved for compatibility with old programs.

◆ end()

CTreeVariable::TreeVariableIterator frib::analysis::CTreeVariable::end ( )
static

end Provide standard iteration support for the tree variable dict.

Returns
CTreeVariable::TreeVariableIterator

◆ getDefinitions()

std::vector< std::pair< std::string, const CTreeVariable::Definition * > > frib::analysis::CTreeVariable::getDefinitions ( )
static

getDefinitions.

Returns
std::vector<std::pair<std::string, const pDefinition>> first is the name of an item, second its definition.

◆ getName()

std::string frib::analysis::CTreeVariable::getName ( ) const

getName

Returns
std::string -name given to the variable.

◆ getNames()

std::vector< std::string > frib::analysis::CTreeVariable::getNames ( )
static

getNames Collect the names of all tree variables:

Returns
std::vector<std::string>

◆ getUnit()

std::string frib::analysis::CTreeVariable::getUnit ( ) const

getUnit Return units if bound else throw std::Logic_error.

Returns
std::string

◆ getValue()

double frib::analysis::CTreeVariable::getValue ( ) const

getValue Return the value of the variable if it's bound else throw std::Logic_error.

Returns
double

◆ hasChanged()

bool frib::analysis::CTreeVariable::hasChanged ( ) const

hasChanged

Returns
bool true if the definition has changed.

◆ Initialize()

void frib::analysis::CTreeVariable::Initialize ( std::string  name,
double  value,
std::string  units 
)

Initialize Do full initialization of a tree variable.

Parameters
name- name of of the variable.
value- initial value (replaces existing value).
units- units of measure(replaces any existing).

◆ lookupDefinition()

CTreeVariable::pDefinition frib::analysis::CTreeVariable::lookupDefinition ( const char *  name)
static

lookupDefinition Try to find a definition given its name

Parameters
name- name to lookup.
Returns
pDefinition -definition of that variable.
Return values
nullptr-if there's no match.

◆ operator double()

frib::analysis::CTreeVariable::operator double ( ) const

operator double This is a call to getValue which does all the bind checking etc.

Returns
double - the value associated with this variable.

◆ operator*=()

CTreeVariable & frib::analysis::CTreeVariable::operator*= ( double  rhs)

*=

◆ operator++() [1/2]

double frib::analysis::CTreeVariable::operator++ ( int  dummy)

postincrement

Returns
double -the value prior to the increment.

◆ operator++() [2/2]

CTreeVariable & frib::analysis::CTreeVariable::operator++ ( )

Pre increment

Returns
*this - after the increment.

◆ operator+=()

CTreeVariable & frib::analysis::CTreeVariable::operator+= ( double  rhs)

+=

Returns
*this

◆ operator--() [1/2]

double frib::analysis::CTreeVariable::operator-- ( int  dummy)

post decrement

◆ operator--() [2/2]

CTreeVariable & frib::analysis::CTreeVariable::operator-- ( )

predecrement

◆ operator-=()

CTreeVariable & frib::analysis::CTreeVariable::operator-= ( double  rhs)

-=

Returns
*this

◆ operator=() [1/2]

CTreeVariable & frib::analysis::CTreeVariable::operator= ( double  rhs)

operator= Assignment from double Uses setValue which does bind checking

Returns
*this

◆ operator=() [2/2]

CTreeVariable & frib::analysis::CTreeVariable::operator= ( const CTreeVariable rhs)

assignment from another tree variable

Parameters
rhs- the other tree variable.
Returns
*this

◆ resetChanged()

void frib::analysis::CTreeVariable::resetChanged ( )

resetChanged reset the changed flags to false:

◆ setUnit()

void frib::analysis::CTreeVariable::setUnit ( const char *  pUnits)

setUnit New units of measure

◆ setValue()

void frib::analysis::CTreeVariable::setValue ( double  newValue)

setValue set a new value for the variable if bound or throw std::logic_error.

Parameters
newValue

◆ size()

size_t frib::analysis::CTreeVariable::size ( )
static

size

Returns
size_t - number of unique tree variables.

◆ valueChanged()

bool frib::analysis::CTreeVariable::valueChanged ( ) const

valueChanged

Returns
bool - if the value changed.

The documentation for this class was generated from the following files: