VPTissue Reference Manual
SimPT_Sim::AttributeStore Class Reference

Store and manage attributes. More...

#include <AttributeStore.h>

Collaboration diagram for SimPT_Sim::AttributeStore:
Collaboration graph

Public Member Functions

 AttributeStore ()=default
 Default constructor creates empty AttributeStore.
 
 AttributeStore (const boost::property_tree::ptree &pt)
 Creates an AttributeStore from an attribute property tree. More...
 
template<typename T >
std::vector< T > & Container (const std::string &name)
 Reference to the appropriate (type and name) attribute container. More...
 
template<typename T >
const std::vector< T > & Container (const std::string &name) const
 Constant reference to the appropriate (type and name) attribute container. More...
 
template<typename T >
std::vector< std::string > GetAttributeNames () const
 Return a vector containing the names of attributes of type T.
 
boost::property_tree::ptree GetAttributeValues (std::size_t pos) const
 Return all attribute values at position i in the container in property tree format. More...
 
template<typename T >
GetDefaultValue (const std::string &name) const
 Return default value for attribute of type and name. More...
 
boost::property_tree::ptree GetIndexDump () const
 Produces representation of index structure in a ptree descriptor. More...
 
boost::property_tree::ptree GetIndexPtree () const
 Return original attribute ptree the AttributeStore was created from. More...
 
template<typename T >
void Initialize (const std::string &name, const std::vector< T > &values)
 Set container of type and name to values iff that container is currently empty and values is size consistent with the current containers in store. More...
 
template<typename T >
void Initialize (const std::string &name, std::vector< T > &&values)
 Set container of type and name to values iff that container is currently empty and values is size consistent with the current containers in store. More...
 
template<typename T >
bool IsAttribute (const std::string &name) const
 Returns true iff there is an attribute of type and name.
 
bool IsEmpty () const
 Returns true iff no attributes are defined.
 
std::tuple< bool, std::size_t > IsStrictSizeConsistent () const
 Strict size consistent iff all containers have the same size. More...
 
bool IsWeakSizeConsistent (std::size_t N) const
 Weak size consistent iff all containers with non-zero size have the same size.
 

Detailed Description

Store and manage attributes.

Definition at line 43 of file AttributeStore.h.

Constructor & Destructor Documentation

SimPT_Sim::AttributeStore::AttributeStore ( const boost::property_tree::ptree &  pt)

Creates an AttributeStore from an attribute property tree.

An attribute property tree has the following structure:

<attribute> <name>testint</name> <type>int</type> <default>255</default> </attribute> <attribute> <name>a_bool</name> <type>bool</type> <default>true</default> </attribute> <attribute> <name>another_int</name> <type>int</type> <default>10</default> </attribute> <attribute> <name>testdouble</name> <type>double</type> <default>3.14</default> </attribute> <attribute> <name>teststring</name> <type>string</type> <default>hellodynamic world</default> </attribute>

The ordering (in types and or names in inconsequential.

Definition at line 33 of file AttributeStore.cpp.

Member Function Documentation

template<typename T >
std::vector< T > & SimPT_Sim::AttributeStore::Container ( const std::string &  name)
inline

Reference to the appropriate (type and name) attribute container.

Throws runtime error if name not present in index.

Definition at line 284 of file AttributeStore.h.

Referenced by SimPT_Sim::operator<<().

Here is the caller graph for this function:

template<typename T >
const std::vector< T > & SimPT_Sim::AttributeStore::Container ( const std::string &  name) const
inline

Constant reference to the appropriate (type and name) attribute container.

Throws runtime error if name not present in index.

Definition at line 295 of file AttributeStore.h.

ptree SimPT_Sim::AttributeStore::GetAttributeValues ( std::size_t  pos) const

Return all attribute values at position i in the container in property tree format.

The format is: <name1>value1</name1> <name2>value2</name2> etc.

Definition at line 72 of file AttributeStore.cpp.

template<typename T >
T SimPT_Sim::AttributeStore::GetDefaultValue ( const std::string &  name) const
inline

Return default value for attribute of type and name.

Throws runtime error if name not present in index.

Definition at line 322 of file AttributeStore.h.

ptree SimPT_Sim::AttributeStore::GetIndexDump ( ) const

Produces representation of index structure in a ptree descriptor.

This method does note preserve ordering and loses comments wrt original attribute property tree.

Definition at line 92 of file AttributeStore.cpp.

boost::property_tree::ptree SimPT_Sim::AttributeStore::GetIndexPtree ( ) const
inline

Return original attribute ptree the AttributeStore was created from.

We have this method to recover the original in terms of ordering, comments etc.

See also
AttributeStore(const boost::property_tree::ptree& pt) for format.

Definition at line 315 of file AttributeStore.h.

Referenced by SimPT_Sim::operator<<().

Here is the caller graph for this function:

template<typename T >
void SimPT_Sim::AttributeStore::Initialize ( const std::string &  name,
const std::vector< T > &  values 
)
inline

Set container of type and name to values iff that container is currently empty and values is size consistent with the current containers in store.

This means either the current container is empty or it has the same size as values.

Throws runtime error if name not present in index or values not size consistent.

Definition at line 333 of file AttributeStore.h.

References IsWeakSizeConsistent().

Here is the call graph for this function:

template<typename T >
void SimPT_Sim::AttributeStore::Initialize ( const std::string &  name,
std::vector< T > &&  values 
)
inline

Set container of type and name to values iff that container is currently empty and values is size consistent with the current containers in store.

This means either the current container is empty or it has the same size as values.

Throws runtime error if name not present in index or values not size consistent.

Definition at line 344 of file AttributeStore.h.

References IsWeakSizeConsistent().

Here is the call graph for this function:

std::tuple< bool, std::size_t > SimPT_Sim::AttributeStore::IsStrictSizeConsistent ( ) const
inline

Strict size consistent iff all containers have the same size.

Returns
tuple with bool (true or false for consistent), size_t (size of containers but undefined if not consistent).

Definition at line 361 of file AttributeStore.h.


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