SST 15.0
Structural Simulation Toolkit
SST::Core::Serialization::ObjectMap Class Referenceabstract

Base class for objects 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< SST::BaseComponent > SST::Core::Serialization::ObjectMapFundamental< TimeConverter * > SST::Core::Serialization::ObjectMapFundamental< TimeConverter > SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra > SST::Core::Serialization::ObjectMapDeferred< T > SST::Core::Serialization::ObjectMapFundamental< T > SST::Core::Serialization::ObjectMapFundamental< TimeConverter * > SST::Core::Serialization::ObjectMapFundamental< TimeConverter > SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra > SST::Core::Serialization::ObjectMapString SST::Core::Serialization::ObjectMapWithChildren

Public Member Functions

 ObjectMap ()=default
 Default constructor primarily used for the "top" object in the hierarchy.
 
bool isReadOnly ()
 Check to see if this object is read-only.
 
void setReadOnly (bool state=true)
 Set the read-only state of the object.
 
std::string getName ()
 Get the name of the variable represented by this ObjectMap.
 
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.
 
virtual std::string getType ()=0
 Get the type of the variable represented by the ObjectMap.
 
virtual void * getAddr ()=0
 Get the address of the variable represented by the ObjectMap.
 
virtual const std::multimap< std::string, ObjectMap * > & getVariables ()
 Get the list of child variables contained in this ObjectMap.
 
void incRefCount ()
 Increment the reference counter for this ObjectMap.
 
void decRefCount ()
 Decrement the reference counter for this ObjectMap.
 
int32_t getRefCount ()
 Get the current reference count.
 
virtual ObjectMapComparisongetComparison (const std::string &UNUSED(name), ObjectMapComparison::Op UNUSED(op), const std::string &UNUSED(value))
 Get a watch point for this object.
 
ObjectMapselectParent ()
 Get the parent for this ObjectMap.
 
ObjectMapselectVariable (std::string name, bool &loop_detected)
 Get the ObjectMap for the specified variable.
 
virtual void addVariable (const std::string &UNUSED(name), ObjectMap *UNUSED(obj))
 Adds a variable to this ObjectMap.
 
virtual std::string get ()
 Get the value of the variable as a string.
 
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.
 
virtual std::string get (const std::string &var)
 Gets the value of the specified variable as a string.
 
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.
 
virtual bool isFundamental ()
 Check to see if this ObjectMap represents a fundamental or a class treated as a fundamental.
 
virtual bool isContainer ()
 Check to see if this ObjectMap represents a container.
 
virtual ~ObjectMap ()=default
 Destructor.
 
 ObjectMap (const ObjectMap &)=delete
 Disallow copying and assignment.
 
ObjectMapoperator= (const ObjectMap &)=delete
 
virtual std::string listVariable (std::string name, bool &found, int recurse=0)
 Create a string that lists information for the specified variable.
 
virtual std::string list (int recurse=0)
 Create a string that lists information for the current object.
 
virtual ObjectMapfindVariable (const std::string &name)
 Find a variable in this object map.
 

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Static Protected Attributes

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

Detailed Description

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

This allows access to read and write the mapped variables. ObjectMaps for fundamental types are templated because they need the type information embedded in the code so they can read and print the values.

Constructor & Destructor Documentation

◆ ~ObjectMap()

virtual SST::Core::Serialization::ObjectMap::~ObjectMap ( )
virtualdefault

Destructor.

NOTE: delete should not be called directly on ObjectMaps, rather decRefCount() should be called when the object is no longer needed.

Member Function Documentation

◆ activate_callback()

virtual void SST::Core::Serialization::ObjectMap::activate_callback ( )
inlineprotectedvirtual

Function that will get called when this object is selected.

Reimplemented in SST::Core::Serialization::ObjectMapDeferred< T >, and SST::Core::Serialization::ObjectMapDeferred< SST::BaseComponent >.

◆ addVariable()

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

Adds a variable 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

References ObjectMap().

◆ deactivate_callback()

virtual void SST::Core::Serialization::ObjectMap::deactivate_callback ( )
inlineprotectedvirtual

Function that will get called when this object is deactivated (i.e selectParent() is called)

Reimplemented in SST::Core::Serialization::ObjectMapDeferred< T >, and SST::Core::Serialization::ObjectMapDeferred< SST::BaseComponent >.

◆ decRefCount()

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

Decrement the reference counter for this ObjectMap.

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

◆ findVariable()

virtual ObjectMap * SST::Core::Serialization::ObjectMap::findVariable ( const std::string & name)
inlinevirtual

Find a variable in this object map.

Parameters
nameName of variable to find
Returns
ObjectMap representing the requested variable if it is found, nullptr otherwise

References getVariables(), and ObjectMap().

Referenced by listVariable(), and selectVariable().

◆ get() [1/2]

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

◆ 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, represented as a string

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

◆ getAddr()

◆ getComparison()

virtual ObjectMapComparison * SST::Core::Serialization::ObjectMap::getComparison ( const std::string & UNUSEDname,
ObjectMapComparison::Op UNUSEDop,
const std::string & UNUSEDvalue )
inlinevirtual

Get a watch point for this object.

If it is not a valid object for a watch point, nullptr will be returned.

◆ 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.

If this ObjectMap has no metadata registered (i.e. it was not selected by another ObjectMap), then an empty string will be returned, since it has no name.

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.

If this ObjectMap has no metadata registered (i.e. it was not selected by another ObjectMap), then an empty string will be returned, since it has no name.

Returns
Name of variable

References mdata_.

◆ 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::multimap< std::string, ObjectMap * > & SST::Core::Serialization::ObjectMap::getVariables ( )
inlinevirtual

Get the list of child variables contained in this ObjectMap.

Returns
Reference to map containing ObjectMaps for this ObjectMap's child variables. Fundamental types will return the same empty map.

Reimplemented in SST::Core::Serialization::ObjectMapDeferred< T >, SST::Core::Serialization::ObjectMapDeferred< SST::BaseComponent >, and SST::Core::Serialization::ObjectMapWithChildren.

References emptyVars.

Referenced by findVariable().

◆ incRefCount()

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

Increment the reference counter for this ObjectMap.

When keeping a pointer to the ObjectMap, incRefCount() should be called to indicate usage. When done, call decRefCount() to indicate it is no longer needed.

◆ 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::ObjectMapContainer< T >.

◆ isFundamental()

◆ isReadOnly()

bool SST::Core::Serialization::ObjectMap::isReadOnly ( )
inline

Check to see if this object is read-only.

Returns
true if ObjectMap is read-only, false otherwise

References read_only_.

Referenced by set().

◆ 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, up to the specified recursion depth.

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_.

◆ 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, up to the specified recursion depth.

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 findVariable(), getType(), mdata_, and ObjectMap().

◆ 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 ObjectMap().

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 findVariable(), mdata_, ObjectMap(), 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 function is only valid for ObjectMaps that represent fundamental types or classes treated as fundamentatl types (i.e. isFundamental() returns true).

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 function is only valid for ObjectMaps that represent non-fundamental types or classes not treated as fundamentatl types (i.e. they must have children).

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 isReadOnly(), ObjectMap(), 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().

Parameters
valueValue to set the object to expressed as a string

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

Referenced by set().

◆ setReadOnly()

void SST::Core::Serialization::ObjectMap::setReadOnly ( bool state = true)
inline

Set the read-only state of the object.

NOTE: If the ObjectMap is created as read-only, setting the state back to false could lead to unexpected results. Setting the state to false should only be done by the same object that set it to true.

Parameters
stateRead-only state to set this ObjectMap to. Defaults to true.

References read_only_.

Field Documentation

◆ emptyVars

const std::multimap< std::string, ObjectMap * > SST::Core::Serialization::ObjectMap::emptyVars
staticprotected

Static empty variable map 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 map.

Referenced by getVariables().

◆ mdata_

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

Metadata 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. When the object selects its parent, then this field is set to nullptr. If this object is selected and the metadata is not 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: