SST 16.0.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< T, REF > SST::Core::Serialization::ObjectMapFundamental< bool > SST::Core::Serialization::ObjectMapFundamental< size_t > SST::Core::Serialization::ObjectMapFundamental< TimeConverter > SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra > SST::Core::Serialization::ObjectMapDeferred< T > SST::Core::Serialization::ObjectMapFundamental< T, REF > 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 () const
 Check to see if this object is read-only.
void setReadOnly (bool state=true)
 Set the read-only state of the object.
virtual bool checkValue (const std::string &UNUSED(value)) const
 Check if value string is valid for this type.
std::string getName () const
 Get the name of the variable represented by this ObjectMap.
std::string getFullName () const
 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 () const =0
 Get the type of the variable represented by the ObjectMap.
virtual void * getAddr () const =0
 Get the address of the variable represented by the ObjectMap.
virtual const ObjectMultimap & getVariables () const
 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.
size_t getRefCount () const
 Get the current reference count.
virtual ObjectMapComparisongetComparison (const std::string &UNUSED(name), ObjectMapComparison::Op UNUSED(op), const std::string &UNUSED(value)) const
 Get a watch point for this object.
virtual ObjectMapComparisongetComparisonVar (const std::string &UNUSED(name), ObjectMapComparison::Op UNUSED(op), const std::string &UNUSED(name2), ObjectMap *UNUSED(var2)) const
virtual ObjectBuffergetObjectBuffer (const std::string &UNUSED(name), size_t UNUSED(sz))
ObjectMapselectParent ()
 Get the parent for this ObjectMap.
ObjectMapselectVariable (std::string name, bool &loop_detected, bool confirm=false)
 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 void removeVariable (const std::string &UNUSED(name))
 Removes a variable from this ObjectMap.
virtual std::string get () const
 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 () const
 Check to see if this ObjectMap represents a fundamental or a class treated as a fundamental.
virtual bool isContainer () const
 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.
ObjectMapfindVariable (const std::string &name, bool confirm=false) const
 Find a variable in this object map.
virtual void refresh ()
 Refresh the ObjectMap, reconstructing children.

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.

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 ignored if isFundamental() returns true.

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

References ObjectMap().

◆ checkValue()

virtual bool SST::Core::Serialization::ObjectMap::checkValue ( const std::string & UNUSEDvalue) const
inlinevirtual

Check if value string is valid for this type.

Parameters
valueValue to set the object to expressed as a string

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

◆ findVariable()

ObjectMap * SST::Core::Serialization::ObjectMap::findVariable ( const std::string & name,
bool confirm = false ) const

Find a variable in this object map.

Parameters
nameName of variable to find
confirmPrompt user to resolve duplicate match of name. Select first found if false.
Returns
ObjectMap representing the requested variable if it is found, nullptr otherwise

References getName(), and getVariables().

Referenced by listVariable(), and selectVariable().

◆ get() [1/2]

virtual std::string SST::Core::Serialization::ObjectMap::get ( ) const
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 (i.e. isFundamental() returns true).

Returns
Value of the represented variable as a string

Reimplemented in SST::Core::Serialization::ObjectMapFundamental< T, REF >, SST::Core::Serialization::ObjectMapFundamental< bool >, SST::Core::Serialization::ObjectMapFundamental< size_t >, SST::Core::Serialization::ObjectMapFundamental< T, REF >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, 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, 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 ) const
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 ( ) const

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 ( ) const
inline

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

Referenced by findVariable(), and selectVariable().

◆ getRefCount()

size_t SST::Core::Serialization::ObjectMap::getRefCount ( ) const
inline

Get the current reference count.

Returns
current value of reference counter for the object

◆ getType()

◆ getVariables()

virtual const ObjectMultimap & SST::Core::Serialization::ObjectMap::getVariables ( ) const
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.

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.

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

Referenced by findVariable(), and SST::IMPL::Interactive::DebugConsole::summary().

◆ 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 ( ) const
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 >, and SST::Core::Serialization::ObjectMapContainer< ELEM_T >.

◆ isFundamental()

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

◆ isReadOnly()

bool SST::Core::Serialization::ObjectMap::isReadOnly ( ) const
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().

◆ refresh()

virtual void SST::Core::Serialization::ObjectMap::refresh ( )
inlinevirtual

◆ removeVariable()

virtual void SST::Core::Serialization::ObjectMap::removeVariable ( const std::string & UNUSEDname)
inlinevirtual

Removes a variable from this ObjectMap.

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

Parameters
nameName of the object in the context of the parent class

◆ 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,
bool confirm = false )

Get the ObjectMap for the specified variable.

Important!!! This function return 'this' pointer and not a nullptr!!! TODO: prefer this return nullptr as bugs have occurred with incorrect use

Parameters
nameName of variable to select
confirmPrompt user to resolve duplicate match of name. Select first found if false.
Returns
ObjectMap for specified variable, if it exists, this otherwise

References findVariable(), getName(), 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 fundamental 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 fundamental 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 >.

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

◆ 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:
  • src/sst/core/serialization/objectMap.h
  • src/sst/core/serialization/objectMap.cc