SST  14.1.0
StructuralSimulationToolkit
SST::Core::Serialization::ObjectMap Class Referenceabstract

Class created by the serializer mapping mode used to map the variables for objects. More...

#include <objectMap.h>

Inheritance diagram for SST::Core::Serialization::ObjectMap:
SST::Core::Serialization::ObjectMapDeferred< T > SST::Core::Serialization::ObjectMapFundamental< T > SST::Core::Serialization::ObjectMapFundamental< TimeConverter * > SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra > SST::Core::Serialization::ObjectMapString SST::Core::Serialization::ObjectMapWithChildren SST::Core::Serialization::ObjectMapClass SST::Core::Serialization::ObjectMapHierarchyOnly SST::Core::Serialization::ObjectMapVector< T >

Public Member Functions

 ObjectMap ()
 Default constructor primarily used for the "top" object in the hierarchy.
 
bool isReadOnly ()
 
void setReadOnly ()
 
std::string getName ()
 Get the name of the variable represented by this ObjectMap. More...
 
std::string getFullName ()
 Get the full hierarchical name of the variable represented by this ObjectMap, based on the path taken to get to this object. More...
 
virtual std::string getType ()=0
 Get the type of the variable represented by the ObjectMap. More...
 
virtual void * getAddr ()=0
 Get the address of the variable represented by the ObjectMap. More...
 
virtual const std::vector< std::pair< std::string, ObjectMap * > > & getVariables ()
 Get the list of child variables contained in this ObjectMap. More...
 
void incRefCount ()
 Increament the reference counter for this object map.
 
void decRefCount ()
 Decreament the reference counter for this object map. More...
 
int32_t getRefCount ()
 Get the current reference count. More...
 
ObjectMapselectParent ()
 Get the parent for this ObjectMap. More...
 
ObjectMapselectVariable (std::string name, bool &loop_detected)
 Get the ObjectMap for the specified variable. More...
 
virtual void addVariable (const std::string &UNUSED(name), ObjectMap *UNUSED(obj))
 Adds a varaible to this ObjectMap. More...
 
virtual std::string get ()
 Get the value of the variable as a string. More...
 
void set (const std::string &value)
 Sets the value of the variable represented by the ObjectMap to the specified value, which is represented as a string. More...
 
virtual std::string get (const std::string &var)
 Gets the value of the specified variable as a string. More...
 
virtual void set (const std::string &var, const std::string &value, bool &found, bool &read_only)
 Sets the value of the specified variable to the specified value, which is represented as a string. More...
 
virtual bool isFundamental ()
 Check to see if this ObjectMap represents a fundamental or a class treated as a fundamental. More...
 
virtual bool isContainer ()
 Check to see if this ObjectMap represents a container. More...
 
virtual ~ObjectMap ()
 Destructor.
 
virtual std::string listVariable (std::string name, bool &found, int recurse=0)
 Create a string that lists information for the specified variable. More...
 
virtual std::string list (int recurse=0)
 Create a string that lists information for the current object. More...
 

Static Public Member Functions

static std::string demangle_name (const char *name)
 Static function to demangle type names returned from typeid<T>.name() More...
 

Protected Member Functions

virtual void set_impl (const std::string &UNUSED(value))
 Function implemented by derived classes to implement set(). More...
 
virtual void activate_callback ()
 Function that will get called when this object is selected.
 
virtual void deactivate_callback ()
 

Protected Attributes

ObjectMapMetaDatamdata_ = nullptr
 Metedata object for walking the object hierarchy. More...
 
bool read_only_ = false
 Indicates wheter or not the variable is read-only.
 

Static Protected Attributes

static std::vector< std::pair< std::string, ObjectMap * > > emptyVars
 Static empty variable vector for use by versions that don't have variables (i.e. More...
 

Detailed Description

Class created by the serializer mapping mode used to map the variables for objects.

This allows access to read and write the mapped variables. The base class is used for non-fundamental and non-container types, but there is a templated child class used for fundameentals and containers. The templating is needed so that the type information can be embedded in the code for reading and writing.

Member Function Documentation

◆ addVariable()

virtual void SST::Core::Serialization::ObjectMap::addVariable ( const std::string &  UNUSEDname,
ObjectMap UNUSEDobj 
)
inlinevirtual

Adds a varaible to this ObjectMap.

NOTE: calls to this function will be ignore if isFundamental() returns true.

Parameters
nameName of the object in the context of the parent class
objObjectMap to add as a variable

◆ decRefCount()

void SST::Core::Serialization::ObjectMap::decRefCount ( )
inline

Decreament the reference counter for this object map.

If this reference count reaches zero, the object will delete itself. NOTE: delete should not be called directly on this object and should only be done automatically using decRefCount().

◆ demangle_name()

std::string SST::Core::Serialization::ObjectMap::demangle_name ( const char *  name)
static

Static function to demangle type names returned from typeid<T>.name()

Parameters
nametypename returned from typid<T>.name()
Returns
demangled name

Referenced by SST::Core::Serialization::ObjectMapVector< T >::getType(), SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >::getType(), and SST::Core::Serialization::ObjectMapFundamental< T >::getType().

◆ get() [1/2]

virtual std::string SST::Core::Serialization::ObjectMap::get ( )
inlinevirtual

Get the value of the variable as a string.

NOTE: this function is only valid for ObjectMaps that represent fundamental types or classes treated as fundamental types.

Returns
Value of the represented variable as a string

Reimplemented in SST::Core::Serialization::ObjectMapFundamental< T >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, and SST::Core::Serialization::ObjectMapString.

Referenced by get().

◆ get() [2/2]

std::string SST::Core::Serialization::ObjectMap::get ( const std::string &  var)
virtual

Gets the value of the specified variable as a string.

NOTE: this function is only valid for ObjectMaps that represent non-fundamental types or classes not treated as fundamental types.

Parameters
varName of variable
Returns
Value of the specified variable as a string

References get(), isFundamental(), selectParent(), and selectVariable().

◆ getAddr()

◆ getFullName()

std::string SST::Core::Serialization::ObjectMap::getFullName ( )

Get the full hierarchical name of the variable represented by this ObjectMap, based on the path taken to get to this object.

Returns
Full hierarchical name of variable

References mdata_, SST::Core::Serialization::ObjectMapMetaData::name, and SST::Core::Serialization::ObjectMapMetaData::parent.

◆ getName()

std::string SST::Core::Serialization::ObjectMap::getName ( )

Get the name of the variable represented by this ObjectMap.

Returns
Name of variable

References mdata_, and SST::Core::Serialization::ObjectMapMetaData::name.

◆ getRefCount()

int32_t SST::Core::Serialization::ObjectMap::getRefCount ( )
inline

Get the current reference count.

Returns
current value of reference counter for the object

◆ getType()

◆ getVariables()

virtual const std::vector<std::pair<std::string, ObjectMap*> >& SST::Core::Serialization::ObjectMap::getVariables ( )
inlinevirtual

◆ isContainer()

virtual bool SST::Core::Serialization::ObjectMap::isContainer ( )
inlinevirtual

Check to see if this ObjectMap represents a container.

Returns
true if this ObjectMap represents a container, false otherwise

Reimplemented in SST::Core::Serialization::ObjectMapVector< T >.

◆ isFundamental()

virtual bool SST::Core::Serialization::ObjectMap::isFundamental ( )
inlinevirtual

Check to see if this ObjectMap represents a fundamental or a class treated as a fundamental.

Returns
true if this ObjectMap represents a fundamental or class treated as a fundamental, false otherwise

Reimplemented in SST::Core::Serialization::ObjectMapFundamental< T >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, and SST::Core::Serialization::ObjectMapString.

Referenced by get().

◆ list()

std::string SST::Core::Serialization::ObjectMap::list ( int  recurse = 0)
virtual

Create a string that lists information for the current object.

This will list all child variables, including the values for any children that are fundamentals.

Parameters
recursenumber of levels to recurse (default is 0)
Returns
String representing this object and any children included based on the value of recurse

References mdata_, and SST::Core::Serialization::ObjectMapMetaData::name.

◆ listVariable()

std::string SST::Core::Serialization::ObjectMap::listVariable ( std::string  name,
bool &  found,
int  recurse = 0 
)
virtual

Create a string that lists information for the specified variable.

This will list all child variables, including the values for any children that are fundamentals.

Parameters
namename of variable to list
[out]foundSet to true if variable is found, set to false otherwise
recursenumber of levels to recurse (default is 0)
Returns
String representing this object and any children included based on the value of recurse

References getType(), and mdata_.

◆ selectParent()

ObjectMap * SST::Core::Serialization::ObjectMap::selectParent ( )

Get the parent for this ObjectMap.

Returns
Parent for this ObjectMap. If this is the top of the hierarchy, it will return nullptr

References mdata_, and SST::Core::Serialization::ObjectMapMetaData::parent.

Referenced by get(), and set().

◆ selectVariable()

ObjectMap * SST::Core::Serialization::ObjectMap::selectVariable ( std::string  name,
bool &  loop_detected 
)

Get the ObjectMap for the specified variable.

Parameters
nameName of variable to select
Returns
ObjectMap for specified variable, if it exists, this otherwise

References mdata_, and SST::Core::Serialization::ObjectMapMetaData::parent.

Referenced by get(), and set().

◆ set() [1/2]

void SST::Core::Serialization::ObjectMap::set ( const std::string &  value)
inline

Sets the value of the variable represented by the ObjectMap to the specified value, which is represented as a string.

The templated child classes for fundamentals will know how to convert the string to a value of the approproprite type. NOTE: this fucntion is only value for ObjectMaps that represent fundamental types or classes treated as fundamentatl types.

Parameters
valueValue to set the object to represented as a string

References read_only_, and set_impl().

Referenced by set().

◆ set() [2/2]

void SST::Core::Serialization::ObjectMap::set ( const std::string &  var,
const std::string &  value,
bool &  found,
bool &  read_only 
)
virtual

Sets the value of the specified variable to the specified value, which is represented as a string.

The templated child classes for fundamentals will know how to convert the string to a value of the approproprite type. NOTE: this fucntion is only valuid for ObjectMaps that represent non-fundamental types or classes not treated as fundamentatl types (i.e. they must have childrent).

Parameters
varName of variable
valueValue to set var to represented as a string
[out]foundSet to true if var is found, set to false otherwise
[out]read_onlySet to true if var is read-only, set to false otherwise

References selectParent(), selectVariable(), and set().

◆ set_impl()

virtual void SST::Core::Serialization::ObjectMap::set_impl ( const std::string &  UNUSEDvalue)
inlineprotectedvirtual

Function implemented by derived classes to implement set().

No need to check for read_only, that is done in set().

Reimplemented in SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >.

Referenced by set().

Field Documentation

◆ emptyVars

std::vector< std::pair< std::string, ObjectMap * > > SST::Core::Serialization::ObjectMap::emptyVars
staticprotected

Static empty variable vector for use by versions that don't have variables (i.e.

are fundamentals or classes treated as fundamentals. This is needed because getVariables() returns a reference to the vector.

Referenced by SST::Core::Serialization::ObjectMapString::getVariables(), getVariables(), SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >::getVariables(), and SST::Core::Serialization::ObjectMapFundamental< T >::getVariables().

◆ mdata_

ObjectMapMetaData* SST::Core::Serialization::ObjectMap::mdata_ = nullptr
protected

Metedata object for walking the object hierarchy.

When this object is selected by a parent object, a metadata object will be added. The metadata contains a pointer to the parent and the name of this object in the context of the parent. If this object is selected and the metadata is non a nullptr, then we have hit a loop in the data structure.

Under normal circumstances, the metadata allows you to get the full path of the object according to how you walked the hierarchy, and allows you to return to the parent object. If a loop is detected on select, then the full path of the object will return to the highest level path and the metadata from that path to the current path will be erased.

Referenced by getFullName(), getName(), list(), listVariable(), selectParent(), and selectVariable().


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