SST 15.0
Structural Simulation Toolkit
|
Base class for objects created by the serializer mapping mode used to map the variables for objects. More...
#include <objectMap.h>
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 ObjectMapComparison * | getComparison (const std::string &UNUSED(name), ObjectMapComparison::Op UNUSED(op), const std::string &UNUSED(value)) |
Get a watch point for this object. | |
ObjectMap * | selectParent () |
Get the parent for this ObjectMap. | |
ObjectMap * | selectVariable (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. | |
ObjectMap & | operator= (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 ObjectMap * | findVariable (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 | |
ObjectMapMetaData * | mdata_ = 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. | |
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.
|
virtualdefault |
Destructor.
NOTE: delete should not be called directly on ObjectMaps, rather decRefCount() should be called when the object is no longer needed.
|
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 >.
|
inlinevirtual |
Adds a variable to this ObjectMap.
NOTE: calls to this function will be ignore if isFundamental() returns true.
name | Name of the object in the context of the parent class |
obj | ObjectMap to add as a variable |
References ObjectMap().
|
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 >.
|
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().
|
static |
Static function to demangle type names returned from typeid(T).name()
name | typename returned from typeid(T).name() |
Referenced by SST::Core::Serialization::ObjectMapContainer< T >::getType(), SST::Core::Serialization::ObjectMapFundamental< T >::getType(), SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >::getType(), SST::Core::Serialization::ObjectMapFundamental< TimeConverter >::getType(), SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >::getType(), and SST::Core::Serialization::ObjectMapClass::ObjectMapClass().
|
inlinevirtual |
Find a variable in this object map.
name | Name of variable to find |
References getVariables(), and ObjectMap().
Referenced by listVariable(), and selectVariable().
|
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).
Reimplemented in SST::Core::Serialization::ObjectMapFundamental< T >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, and SST::Core::Serialization::ObjectMapString.
Referenced by get().
|
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.
var | Name of variable |
References get(), isFundamental(), ObjectMap(), selectParent(), and selectVariable().
|
pure virtual |
Get the address of the variable represented by the ObjectMap.
Implemented in SST::Core::Serialization::ObjectMapClass, SST::Core::Serialization::ObjectMapContainer< T >, SST::Core::Serialization::ObjectMapDeferred< T >, SST::Core::Serialization::ObjectMapDeferred< SST::BaseComponent >, SST::Core::Serialization::ObjectMapFundamental< T >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapHierarchyOnly, and SST::Core::Serialization::ObjectMapString.
|
inlinevirtual |
Get a watch point for this object.
If it is not a valid object for a watch point, nullptr will be returned.
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.
References mdata_, SST::Core::Serialization::ObjectMapMetaData::name, and SST::Core::Serialization::ObjectMapMetaData::parent.
std::string SST::Core::Serialization::ObjectMap::getName | ( | ) |
|
inline |
Get the current reference count.
|
pure virtual |
Get the type of the variable represented by the ObjectMap.
Implemented in SST::Core::Serialization::ObjectMapClass, SST::Core::Serialization::ObjectMapContainer< T >, SST::Core::Serialization::ObjectMapDeferred< T >, SST::Core::Serialization::ObjectMapDeferred< SST::BaseComponent >, SST::Core::Serialization::ObjectMapFundamental< T >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapHierarchyOnly, and SST::Core::Serialization::ObjectMapString.
Referenced by listVariable().
|
inlinevirtual |
Get the list of child variables contained in this ObjectMap.
Reimplemented in SST::Core::Serialization::ObjectMapDeferred< T >, SST::Core::Serialization::ObjectMapDeferred< SST::BaseComponent >, and SST::Core::Serialization::ObjectMapWithChildren.
References emptyVars.
Referenced by findVariable().
|
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.
|
inlinevirtual |
Check to see if this ObjectMap represents a container.
Reimplemented in SST::Core::Serialization::ObjectMapContainer< T >.
|
inlinevirtual |
Check to see if this ObjectMap represents a fundamental or a class treated as a fundamental.
Reimplemented in SST::Core::Serialization::ObjectMapFundamental< T >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter * >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< TimeConverter >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, SST::Core::Serialization::ObjectMapFundamental< UnitAlgebra >, and SST::Core::Serialization::ObjectMapString.
Referenced by get().
|
inline |
Check to see if this object is read-only.
References read_only_.
Referenced by set().
|
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.
recurse | Number of levels to recurse (default is 0) |
References mdata_.
|
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.
name | Name of variable to list | |
[out] | found | Set to true if variable is found, set to false otherwise |
recurse | Number of levels to recurse (default is 0) |
References findVariable(), getType(), mdata_, and ObjectMap().
ObjectMap * SST::Core::Serialization::ObjectMap::selectParent | ( | ) |
ObjectMap * SST::Core::Serialization::ObjectMap::selectVariable | ( | std::string | name, |
bool & | loop_detected ) |
Get the ObjectMap for the specified variable.
name | Name of variable to select |
References findVariable(), mdata_, ObjectMap(), and SST::Core::Serialization::ObjectMapMetaData::parent.
|
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).
value | Value to set the object to, represented as a string |
References read_only_, and set_impl().
Referenced by set().
|
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).
var | Name of variable | |
value | Value to set var to represented as a string | |
[out] | found | Set to true if var is found, set to false otherwise |
[out] | read_only | Set to true if var is read-only, set to false otherwise |
References isReadOnly(), ObjectMap(), selectParent(), selectVariable(), and set().
|
inlineprotectedvirtual |
Function implemented by derived classes to implement set().
No need to check for read-only, that is done in set().
value | Value 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().
|
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.
state | Read-only state to set this ObjectMap to. Defaults to true. |
References read_only_.
|
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().
|
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().