A Node with Quantity, String and Integer variables. More...

#include <Object.h>

Inheritance diagram for Object:

Classes

class  ConstIteratorQuantities
 
class  ConstRangeQuantities
 
class  IteratorQuantities
 
class  RangeQuantities
 

Public Member Functions

 Object (Libpf::User::Defaults defaults, uint32_t id=0, Persistency *persistency=nullptr, Persistent *parent=nullptr, Persistent *root=nullptr)
 
Libpf::User::Defaults defaults (void) const
 
void readVariables (Persistency *persistency)
 reads Q, QV and QM from persistency More...
 
void readParameters (Persistency *persistency)
 reads I, IV, S and SV from persistency More...
 
Nodeoperator= (const Node &)
 copy assignment operator More...
 
Nodeoperator= (Node &&other)
 move assignment More...
 
 ~Object (void)
 
const std::string & type (void) const
 
Objectat (const std::string &fullRelativeTag)
 
const Objectat (const std::string &fullRelativeTag) const
 
Objectat (const std::string &fullRelativeTag, int index)
 
const ValueQ (const std::string &tag) const
 
const ValueQ (const std::string &tag, int index) const
 
const ValueQ (const std::string &tag, int row, int column) const
 
ValueQ (const std::string &tag)
 
ValueQ (const std::string &tag, int index)
 
ValueQ (const std::string &tag, int row, int column)
 
const ValueQ (const std::string &tag, std::string componentName) const
 
ValueQ (const std::string &tag, std::string componentName)
 
const ValueQ (const std::string &tag, int index, std::string componentName) const
 
ValueQ (const std::string &tag, int index, std::string componentName)
 
const int & I (const std::string &tag) const
 
const int & I (const std::string &tag, int index) const
 
int & I (const std::string &tag)
 
int & I (const std::string &tag, int index)
 
const std::string & S (const std::string &tag) const
 
const std::string & S (const std::string &tag, int index) const
 
std::string & S (const std::string &tag)
 
std::string & S (const std::string &tag, int index)
 
bool operator!= (const Object &rhs) const
 
bool operator== (const Object &rhs) const
 
bool compareParameters (const Object &rhs) const
 
bool existsI (const std::string &tag) const
 
bool existsS (const std::string &tag) const
 
bool existsQ (const std::string &tag) const
 
const RangeQuantities quantities (void)
 
const ConstRangeQuantities quantities (void) const
 
- Public Member Functions inherited from Node
 Node (Libpf::User::Defaults defaults, uint32_t id=0, Persistency *persistency=nullptr, Persistent *parent=nullptr, Persistent *root=nullptr)
 
 Node (const Node &other)
 copy constructor More...
 
 Node (Node &&other)
 move constructor More...
 
virtual std::unique_ptr< Nodeclone (void) const
 
 ~Node ()
 
int insert (Persistency *persistency) const
 
int update (Persistency *persistency) const
 
void restore (Persistency *persistency)
 
void remove (Persistency *persistency) const
 
uint32_t rootId (void) const
 
uint32_t range (void) const
 
uint32_t getId (void)
 returns the next available id and increments the internal counter More...
 
NodeaddChild (std::string type, uint32_t id, Persistency *persistency)
 
NodeaddChild (std::string type, Libpf::User::Defaults defaults)
 
NodeaddChild (const Node &child)
 
NodeaddChild (std::unique_ptr< Node > child)
 
std::unique_ptr< Nodeprune (const std::string &tag)
 
const Nodechild (const std::string &tag) const
 
Nodeat (const std::string &fullRelativeTag)
 
const Nodeat (const std::string &fullRelativeTag) const
 
uint32_t descendants (void) const
 
Persistentroot (void) const
 
void renameChild (const std::string &oldName, const std::string &newName)
 
bool existsChild (std::string tag) const
 
bool exists (uint32_t id)
 
Nodesearch (uint32_t id)
 
bool operator!= (const Node &rhs) const
 
bool operator== (const Node &rhs) const
 
bool isRestored (void) const
 return whether the Node has just been retrieved from persistent storage More...
 
void setIcon (std::string icon, double width, double height)
 
bool hasIcon (void) const
 
std::string iconName (bool raster) const
 
double iconWidth (void) const
 
double iconHeight (void) const
 
const Range children (void)
 
const ConstRange children (void) const
 
- Public Member Functions inherited from Persistent
 Persistent (const std::string &tag, const std::string &description, Persistent *parent, uint32_t id)
 main constructor More...
 
 Persistent (const Persistent &)
 copy constructor More...
 
Persistentoperator= (const Persistent &)
 copy assignment More...
 
 Persistent (Persistent &&other)
 move constructor More...
 
Persistentoperator= (Persistent &&other)
 move assignment More...
 
 ~Persistent (void)
 
uint32_t id (void) const
 
std::string uuid (void) const
 
uint32_t parentId (void) const
 
double created_at (void) const
 
double updated_at (void) const
 
void updated_at (double u) const
 
- Public Member Functions inherited from Item
 Item (const Item &other)
 copy constructor copies all elements but parent which is set to nullptr More...
 
Itemoperator= (const Item &other)
 copy assignment operator copies all elements but parent which is set to nullptr More...
 
 Item (const std::string &tag, const std::string &description, Persistent *parent)
 
 Item (Item &&other)
 move constructor More...
 
Itemoperator= (Item &&other)
 move assignment operator More...
 
virtual ~Item (void)
 
const std::string & tag (void) const
 
const std::string & description (void) const
 
std::string fullTag (void) const
 
const Persistentparent (void) const
 
void setTag (const std::string &tag)
 
void setDescription (const std::string &description)
 
void setWideTag (const std::wstring &tag)
 wide-character variant, More...
 
void setWideDescription (const std::wstring &description)
 wide-character variant, More...
 
bool operator!= (const Item &rhs) const
 
bool operator== (const Item &rhs) const
 
- Public Member Functions inherited from Diagnostic
 Diagnostic (void)
 
void setVerbosity (int verbosity)
 sets the verbosity level for this instance More...
 
int verbosity (void) const
 

Protected Member Functions

int retrieveInteger (const Libpf::User::Defaults &defaults, uint32_t id, Persistency *persistency, std::string tag, int min, int max, int def=-1)
 
std::string retrieveString (const Libpf::User::Defaults &defaults, uint32_t id, Persistency *persistency, std::string tag, const std::string def)
 
template<class T >
void addVariable (T &variable)
 
template<class T >
void addVectorVariable (std::vector< T > &variable, const std::string &tag, const std::string &description, uint32_t size, typename T::ValueType value)
 
 Object (const Object &other)
 copy constructor More...
 
 Object (Object &&other)
 move constructor More...
 
Objectoperator= (const Object &)
 copy assignment operator More...
 
Objectoperator= (Object &&other)
 move assignment operator More...
 
- Protected Member Functions inherited from Node
int offset (void) const
 

Protected Attributes

std::map< std::string, Integer * > integers_
 collection of integer variables More...
 
std::map< std::string,
IntegerVector * > 
integerVectors_
 collection of integer variable vectors More...
 
std::map< std::string, Quantity * > quantities_
 collection of real variables More...
 
std::map< std::string,
QuantityVector * > 
quantityVectors_
 collection of real variable vectors More...
 
std::map< std::string,
QuantityMatrix * > 
quantityMatrices_
 collection of real variable matrices More...
 
std::map< std::string, String * > strings_
 collection of string variables More...
 
std::map< std::string,
StringVector * > 
stringVectors_
 collection of string variable vectors More...
 
- Protected Attributes inherited from Node
std::map< std::string,
std::unique_ptr< Node > > 
children_
 the collection of direct descendants More...
 
- Protected Attributes inherited from Item
Persistentparent_
 pointer to the parent Persistent; set to this by the constructor if Item is self-standing or a root Persistent of a tree More...
 
- Protected Attributes inherited from Diagnostic
int verbosityInstance
 

Detailed Description

A Node with Quantity, String and Integer variables.

#include <libpf/persistency/Object.h>

Remarks

Constructor & Destructor Documentation

Object::Object ( const Object other)
protected

copy constructor

Object::Object ( Object &&  other)
protected

move constructor

Object::Object ( Libpf::User::Defaults  defaults,
uint32_t  id = 0,
Persistency persistency = nullptr,
Persistent parent = nullptr,
Persistent root = nullptr 
)

universal constructor

Parameters
defaultsdefault informations to build and configure the Node and its descendants
idinteger identifier, for a Node belonging to a tree must be unique within the tree; defaults to 0
persistencydatabase connection
parentpointer to the parent Node; set to nullptr if Node is self-standing or the root Node in a tree; defaults to nullptr
rootpointer to the root Node; set to nullptr if Node is self-standing or the root Node in a tree; defaults to nullptr
Object::~Object ( void  )

Member Function Documentation

template<class T >
void Object::addVariable ( T &  variable)
protected

inserts a reference to an automatic variable in the collections of variables

Parameters
variablethe automatic variable
template<class T >
void Object::addVectorVariable ( std::vector< T > &  variable,
const std::string &  tag,
const std::string &  description,
uint32_t  size,
typename T::ValueType  value 
)
protected

populates a vector variable and inserts the references in the collections of variables

Exceptions
ErrorRunTimeif there is already a variable with the same label tag
Parameters
variablethe vector variable
tagthe tag of the vector variable
descriptionthe description of the vector variable
sizethe size of the vector variable
valuethe initialization value for the elements of the vector variable
Object& Object::at ( const std::string &  fullRelativeTag)
Returns
a reference to the recursive descendant with the supplied full relative label
Parameters
fullRelativeTagthe UTF-8 encoded full relative human-readable label, unique within the scope of this Node and all its descendants
Exceptions
ErrorRunTimeif there no descendant with the supplied full relative label tag
Note
it is the responsibility of the caller to not access this reference after the lifecycle of the Object is over
const Object& Object::at ( const std::string &  fullRelativeTag) const
Returns
a const reference to the recursive descendant with the supplied full relative label
Parameters
fullRelativeTagthe UTF-8 encoded full relative human-readable label, unique within the scope of this Node and all its descendants
Note
it is the responsibility of the caller to not access this reference after the lifecycle of the Node is over
Exceptions
ErrorRunTimeif there no descendant with the supplied full relative label tag
Object& Object::at ( const std::string &  fullRelativeTag,
int  index 
)
Returns
a reference to the recursive descendant corresponding to the supplied full relative tag and index in the collection of embedded objects
Parameters
fullRelativeTagthe UTF-8 encoded full relative human-readable label, unique within the scope of this Node and all its descendants
indexindex of element to retrieve, 0-base
Note
it is the responsibility of the caller to not access this reference after the lifecycle of the Node is over
Exceptions
ErrorRunTimeif there no descendant vector with the supplied full relative label tag
ErrorRunTimeif the index is outside range
bool Object::compareParameters ( const Object rhs) const

compares Integers, Strings and vectors / matrices thereof

Returns
true if the two Object is recursively identical to rhs w.r.t. parameters
Libpf::User::Defaults Object::defaults ( void  ) const
Returns
the information originally supplied to the constructor and persisted in Integers and Strings
bool Object::existsI ( const std::string &  tag) const
Returns
true if an element with the supplied tag exists in the collection of integer variables
Parameters
tagUTF-8 encoded human-readable identifier
bool Object::existsQ ( const std::string &  tag) const
Returns
true if an element with the supplied tag exists in the collection of real variables
Parameters
tagUTF-8 encoded human-readable identifier
bool Object::existsS ( const std::string &  tag) const
Returns
true if an element with the supplied tag exists in the collection of strings
Parameters
tagUTF-8 encoded human-readable identifier
const int& Object::I ( const std::string &  tag) const
Returns
a const reference to the integral value of the element corresponding to the supplied tag in the collection of integer variables, parameters and integer pointers to embedded object's CATALOGID
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
See also
integers_
const int& Object::I ( const std::string &  tag,
int  index 
) const
Returns
a const reference to the integral value of the i-th element from the vector with supplied tag in the collection of integer variables, parameters and integer pointers to embedded object's CATALOGID
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
indexindex of element to retrieve, 0-base
See also
integers_
int& Object::I ( const std::string &  tag)
Returns
a non-const reference to the integral value of the element corresponding to the supplied tag in the collection of integer variables, parameters and integer pointers to embedded object's CATALOGID
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
See also
integers_
int& Object::I ( const std::string &  tag,
int  index 
)
Returns
a non-const reference to the integral value of the i-th element from the vector with supplied tag in the collection of integer variables, parameters and integer pointers to embedded object's CATALOGID
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
indexindex of element to retrieve, 0-base
See also
integers_
bool Object::operator!= ( const Object rhs) const
Returns
true if the two Objects are recursively different
Object& Object::operator= ( const Object )
protected

copy assignment operator

Object& Object::operator= ( Object &&  other)
protected

move assignment operator

Node& Object::operator= ( const Node )
virtual

copy assignment operator

Reimplemented from Node.

Node& Object::operator= ( Node &&  other)
virtual

move assignment

Reimplemented from Node.

bool Object::operator== ( const Object rhs) const
Returns
true if the two Objects are recursively identical
const Value& Object::Q ( const std::string &  tag) const
Returns
a const reference to the real value of the element corresponding to the supplied tag in the collection of real variables
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of element to retrieve
See also
quantities_
const Value& Object::Q ( const std::string &  tag,
int  index 
) const
Returns
a const reference to the real value of the element corresponding to the supplied tag and index in the collection of real variable vectors
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
indexindex of element to retrieve, 0-base
See also
quantities_
const Value& Object::Q ( const std::string &  tag,
int  row,
int  column 
) const
Returns
a const reference to the real value of the element corresponding to the supplied tag, row and column in the collection of real variable matrices
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
rowrow index of element to retrieve, 0-base
columncolumn index of element to retrieve, 0-base
See also
quantities_
Value& Object::Q ( const std::string &  tag)
Returns
a non-const reference to the real value of the element corresponding to the supplied tag in the collection of real variables
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of element to retrieve
See also
quantities_
Value& Object::Q ( const std::string &  tag,
int  index 
)
Returns
a non-const reference to the real value of the element corresponding to the supplied tag and index in the collection of real variable vectors
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
indexindex of element to retrieve, 0-base
See also
quantities_
Value& Object::Q ( const std::string &  tag,
int  row,
int  column 
)
Returns
a non-const reference to the real value of the element corresponding to the supplied tag, row and column in the collection of real variable matrices
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
rowrow index of element to retrieve, 0-base
columncolumn index of element to retrieve, 0-base
See also
quantities_
const Value& Object::Q ( const std::string &  tag,
std::string  componentName 
) const
Returns
a const reference to the real value of the element with the supplied component name from a dictionary with supplied tag in the collection of real variables
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
componentNamecomponent name of vector element to retrieve
See also
quantities_
Value& Object::Q ( const std::string &  tag,
std::string  componentName 
)
Returns
a non-const reference to the real value of the element with the supplied component name from a dictionary with supplied tag in the collection of real variables
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
componentNamecomponent name of vector element to retrieve
See also
quantities_
const Value& Object::Q ( const std::string &  tag,
int  index,
std::string  componentName 
) const
Returns
a const reference to the real value of the element corresponding to the supplied tag, index and component in the collection of real variable matrices
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
indexindex of element to retrieve, 0-base
componentNamecomponent name of vector element to retrieve
See also
quantities_
Value& Object::Q ( const std::string &  tag,
int  index,
std::string  componentName 
)
Returns
a non-const reference to the real value of the element corresponding to the supplied tag, index and component in the collection of real variable matrices
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
taglabel of vector element
indexindex of element to retrieve, 0-base
componentNamecomponent name of vector element to retrieve
See also
quantities_
const RangeQuantities Object::quantities ( void  )
Returns
a RangeQuantities object that with a range-based for-loop can iterate over all real variables
const ConstRangeQuantities Object::quantities ( void  ) const
Returns
a ConstRangeQuantities object that with a const range-based for-loop can iterate over all real variables
void Object::readParameters ( Persistency )
virtual

reads I, IV, S and SV from persistency

Reimplemented from Node.

void Object::readVariables ( Persistency )
virtual

reads Q, QV and QM from persistency

Reimplemented from Node.

int Object::retrieveInteger ( const Libpf::User::Defaults defaults,
uint32_t  id,
Persistency persistency,
std::string  tag,
int  min,
int  max,
int  def = -1 
)
protected

retrieve a strictly positive configuration integer parameter if persistency is nullptr, get it from defaults; else try to retrieve it from persistency based on id if the supplied / retrieved value is negative, set it to default value; in any case make sure the final value is strictly within bounds

Parameters
defaultsdefaults passed to constructor
tagparameter name
minparameter minimum value (strict: can not be equal)
maxparameter maximum value (strict: can not be equal)
defdefault value if no user input is present in options
std::string Object::retrieveString ( const Libpf::User::Defaults defaults,
uint32_t  id,
Persistency persistency,
std::string  tag,
const std::string  def 
)
protected

retrieve a non-empty configuration string parameter if persistency is nullptr, get it from defaults else try to retrieve it from persistency based on id if the retrieved value is empty, set it to default value

Parameters
defaultsdefaults passed to constructor
tagparameter name
defdefault value if no user input is present in options
const std::string& Object::S ( const std::string &  tag) const
Returns
a const reference to the string value of the element corresponding to the supplied tag in the collection of strings
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
See also
strings_
const std::string& Object::S ( const std::string &  tag,
int  index 
) const
Returns
a reference to the string value of the i-th element from the vector with supplied tag in the collection of strings
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
indexindex of element to retrieve, 0-base
See also
strings_
std::string& Object::S ( const std::string &  tag)
Returns
a non-const reference to the string value of the element corresponding to the supplied tag in the collection of strings
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
See also
strings_
std::string& Object::S ( const std::string &  tag,
int  index 
)
Returns
a non-const reference to the string value of the i-th element from the vector with supplied tag in the collection of strings
Exceptions
ErrorBrowsingin case non-existing tag
Parameters
tagtag of element to retrieve
indexindex of element to retrieve, 0-base
See also
strings_
const std::string& Object::type ( void  ) const
virtual
Returns
the C++ name of the class the instance belongs to
Note
it is the responsibility of the caller to not access this reference after the lifecycle of the Item

Reimplemented from Node.

Reimplemented in StreamTwo< FlashVl >, MultiReaction< 2 >, PhaseIapws< PhaseType::vapor >, and PhaseIapws< PhaseType::liquid >.

Member Data Documentation

std::map<std::string, Integer *> Object::integers_
protected

collection of integer variables

std::map<std::string, IntegerVector *> Object::integerVectors_
protected

collection of integer variable vectors

std::map<std::string, Quantity *> Object::quantities_
protected

collection of real variables

std::map<std::string, QuantityMatrix *> Object::quantityMatrices_
protected

collection of real variable matrices

std::map<std::string, QuantityVector *> Object::quantityVectors_
protected

collection of real variable vectors

std::map<std::string, String *> Object::strings_
protected

collection of string variables

std::map<std::string, StringVector *> Object::stringVectors_
protected

collection of string variable vectors


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