SST 15.0
Structural Simulation Toolkit
objectMap.h
1// Copyright 2009-2025 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2025, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_SERIALIZATION_OBJECTMAP_H
13#define SST_CORE_SERIALIZATION_OBJECTMAP_H
14
15#include "sst/core/from_string.h"
16#include "sst/core/warnmacros.h"
17
18#include <cstdint>
19#include <map>
20#include <string>
21#include <typeinfo>
22#include <utility>
23#include <vector>
24
25namespace SST::Core::Serialization {
26
27class ObjectMap;
28
29/**
30 Metadata object that each ObjectMap has a pointer to in order to
31 track the hierarchy information while traversing the data
32 structures. This is used because a given object can be pointed to
33 by multiple other objects, so we need to track the "path" through
34 which we got to the object so we can traverse back up the object
35 hierarchy.
36*/
38{
39 /**
40 Parent object that contained this object and through which it
41 was selected.
42 */
44
45 /**
46 Name of this object in the context of the currently set parent
47 */
48 std::string name;
49
50 /**
51 Constructor for intializing data memebers
52 */
53 ObjectMapMetaData(ObjectMap* parent, const std::string& name) :
55 name(name)
56 {}
57
58 ObjectMapMetaData(const ObjectMapMetaData&) = delete;
59 ObjectMapMetaData& operator=(const ObjectMapMetaData&) = delete;
60};
61
62
63/**
64 Base class for interacting with data from ObjectMap. This includes
65 the ability to keep a history of values and compare the value
66 against specified criteria (i.e., value >= 15, value == 6,
67 etc). Because this class is type agnostic, interactions will be
68 through strings, just as with the ObjectMapClass.
69
70 The implementations of the virtual functions needs to be done in
71 templated child clases so that the type of the data is known.
72 */
73class ObjectMapComparison
74{
75public:
76 enum class Op : std::uint8_t { LT, LTE, GT, GTE, EQ, NEQ, CHANGED, INVALID };
77
78 static Op getOperationFromString(const std::string& op)
79 {
80 if ( op == "<" ) return Op::LT;
81 if ( op == "<=" ) return Op::LTE;
82 if ( op == ">" ) return Op::GT;
83 if ( op == ">=" ) return Op::GTE;
84 if ( op == "==" ) return Op::EQ;
85 if ( op == "!=" ) return Op::NEQ;
86 return Op::INVALID;
87 }
88
89 ObjectMapComparison() = default;
90
91 ObjectMapComparison(const std::string& name) :
92 name_(name)
93 {}
94 virtual ~ObjectMapComparison() = default;
95
96 virtual bool compare() = 0;
97 virtual std::string getCurrentValue() = 0;
98 std::string getName() { return name_; }
99
100protected:
101 std::string name_ = "";
102};
103
104/**
105 Base class for objects created by the serializer mapping mode used
106 to map the variables for objects. This allows access to read and
107 write the mapped variables. ObjectMaps for fundamental types are
108 templated because they need the type information embedded in the
109 code so they can read and print the values.
110 */
112{
113protected:
114 /**
115 Static empty variable map for use by versions that don't have
116 variables (i.e. are fundamentals or classes treated as
117 fundamentals. This is needed because getVariables() returns a
118 reference to the map.
119 */
120 static const std::multimap<std::string, ObjectMap*> emptyVars;
121
122 /**
123 Metadata object for walking the object hierarchy. When this
124 object is selected by a parent object, a metadata object will
125 be added. The metadata contains a pointer to the parent and
126 the name of this object in the context of the parent. When the
127 object selects its parent, then this field is set to nullptr.
128 If this object is selected and the metadata is not a nullptr,
129 then we have hit a loop in the data structure.
130
131 Under normal circumstances, the metadata allows you to get the
132 full path of the object according to how you walked the
133 hierarchy, and allows you to return to the parent object. If a
134 loop is detected on select, then the full path of the object
135 will return to the highest level path and the metadata from
136 that path to the current path will be erased.
137 */
139
140
141 /**
142 Indicates whether or not the variable is read-only
143 */
144 bool read_only_ = false;
145
146
147 /**
148 Function implemented by derived classes to implement set(). No
149 need to check for read-only, that is done in set().
150
151 @param value Value to set the object to expressed as a string
152 */
153 virtual void set_impl(const std::string& UNUSED(value)) {}
154
155 /**
156 Function that will get called when this object is selected
157 */
158 virtual void activate_callback() {}
159
160 /**
161 Function that will get called when this object is deactivated
162 (i.e selectParent() is called)
163 */
164 virtual void deactivate_callback() {}
165
166private:
167 /**
168 Reference counter so the object knows when to delete itself.
169 ObjectMaps should not be deleted directly, rather the
170 decRefCount() function should be called when the object is no
171 longer needed and the object will delete itself if refCount_
172 reaches 0.
173 */
174 int32_t refCount_ = 1;
175
176public:
177 /**
178 Default constructor primarily used for the "top" object in the hierarchy
179 */
180 ObjectMap() = default;
181
182
183 /**
184 Check to see if this object is read-only
185
186 @return true if ObjectMap is read-only, false otherwise
187 */
188 bool isReadOnly() { return read_only_; }
189
190 /**
191 Set the read-only state of the object. NOTE: If the ObjectMap
192 is created as read-only, setting the state back to false could
193 lead to unexpected results. Setting the state to false should
194 only be done by the same object that set it to true.
195
196 @param state Read-only state to set this ObjectMap to. Defaults to true.
197 */
198 void setReadOnly(bool state = true) { read_only_ = state; }
199
200
201 /**
202 Get the name of the variable represented by this ObjectMap. If
203 this ObjectMap has no metadata registered (i.e. it was not
204 selected by another ObjectMap), then an empty string will be
205 returned, since it has no name.
206
207 @return Name of variable
208 */
209 std::string getName();
210
211
212 /**
213 Get the full hierarchical name of the variable represented by
214 this ObjectMap, based on the path taken to get to this
215 object. If this ObjectMap has no metadata registered (i.e. it
216 was not selected by another ObjectMap), then an empty string
217 will be returned, since it has no name.
218
219 @return Full hierarchical name of variable
220 */
221 std::string getFullName();
222
223
224 /**
225 Get the type of the variable represented by the ObjectMap
226
227 @return Type of variable
228 */
229 virtual std::string getType() = 0;
230
231 /**
232 Get the address of the variable represented by the ObjectMap
233
234 @return Address of variable
235 */
236 virtual void* getAddr() = 0;
237
238
239 /**
240 Get the list of child variables contained in this ObjectMap
241
242 @return Reference to map containing ObjectMaps for this
243 ObjectMap's child variables. Fundamental types will return the
244 same empty map.
245 */
246 virtual const std::multimap<std::string, ObjectMap*>& getVariables() { return emptyVars; }
247
248 /**
249 Increment the reference counter for this ObjectMap. When
250 keeping a pointer to the ObjectMap, incRefCount() should be
251 called to indicate usage. When done, call decRefCount() to
252 indicate it is no longer needed.
253 */
254 void incRefCount() { ++refCount_; }
255
256 /**
257 Decrement the reference counter for this ObjectMap. If this
258 reference count reaches zero, the object will delete itself.
259 NOTE: delete should not be called directly on this object and
260 should only be done automatically using decRefCount().
261 */
263 {
264 if ( !--refCount_ ) delete this;
265 }
266
267 /**
268 Get the current reference count
269
270 @return current value of reference counter for the object
271 */
272 int32_t getRefCount() { return refCount_; }
273
274
275 /**
276 Get a watch point for this object. If it is not a valid object
277 for a watch point, nullptr will be returned.
278 */
280 const std::string& UNUSED(name), ObjectMapComparison::Op UNUSED(op), const std::string& UNUSED(value))
281 {
282 return nullptr;
283 }
284
285 /************ Functions for walking the Object Hierarchy ************/
286
287
288 /**
289 Get the parent for this ObjectMap
290
291 @return Parent for this ObjectMap. If this is the top of the
292 hierarchy, it will return nullptr
293 */
295
296 /**
297 Get the ObjectMap for the specified variable
298
299 @param name Name of variable to select
300
301 @return ObjectMap for specified variable, if it exists, this
302 otherwise
303 */
304 ObjectMap* selectVariable(std::string name, bool& loop_detected);
305
306
307 /**
308 Adds a variable to this ObjectMap. NOTE: calls to this
309 function will be ignore if isFundamental() returns true.
310
311 @param name Name of the object in the context of the parent class
312
313 @param obj ObjectMap to add as a variable
314
315 */
316 virtual void addVariable(const std::string& UNUSED(name), ObjectMap* UNUSED(obj)) {}
317
318
319 /************ Functions for getting/setting Object's Value *************/
320
321 /**
322 Get the value of the variable as a string. NOTE: this function
323 is only valid for ObjectMaps that represent fundamental types
324 or classes treated as fundamental types (i.e. isFundamental()
325 returns true).
326
327 @return Value of the represented variable as a string
328 */
329 virtual std::string get() { return ""; }
330
331 /**
332 Sets the value of the variable represented by the ObjectMap to
333 the specified value, which is represented as a string. The
334 templated child classes for fundamentals will know how to
335 convert the string to a value of the approproprite type. NOTE:
336 this function is only valid for ObjectMaps that represent
337 fundamental types or classes treated as fundamentatl types
338 (i.e. isFundamental() returns true).
339
340 @param value Value to set the object to, represented as a string
341
342 */
343 void set(const std::string& value)
344 {
345 if ( !read_only_ ) set_impl(value);
346 }
347
348 /**
349 Gets the value of the specified variable as a string. NOTE:
350 this function is only valid for ObjectMaps that represent
351 non-fundamental types or classes not treated as fundamental
352 types.
353
354 @param var Name of variable
355
356 @return Value of the specified variable, represented as a
357 string
358 */
359 virtual std::string get(const std::string& var);
360
361 /**
362 Sets the value of the specified variable to the specified
363 value, which is represented as a string. The templated child
364 classes for fundamentals will know how to convert the string to
365 a value of the approproprite type. NOTE: this function is only
366 valid for ObjectMaps that represent non-fundamental types or
367 classes not treated as fundamentatl types (i.e. they must have
368 children).
369
370 @param var Name of variable
371
372 @param value Value to set var to represented as a string
373
374 @param[out] found Set to true if var is found, set to false otherwise
375
376 @param[out] read_only Set to true if var is read-only, set to false otherwise
377
378 */
379 virtual void set(const std::string& var, const std::string& value, bool& found, bool& read_only);
380
381 /**
382 Check to see if this ObjectMap represents a fundamental or a
383 class treated as a fundamental.
384
385 @return true if this ObjectMap represents a fundamental or
386 class treated as a fundamental, false otherwise
387 */
388 virtual bool isFundamental() { return false; }
389
390 /**
391 Check to see if this ObjectMap represents a container
392
393 @return true if this ObjectMap represents a container, false
394 otherwise
395 */
396 virtual bool isContainer() { return false; }
397
398 /**
399 Destructor. NOTE: delete should not be called directly on
400 ObjectMaps, rather decRefCount() should be called when the
401 object is no longer needed.
402 */
403 virtual ~ObjectMap() = default;
404
405 /**
406 Disallow copying and assignment
407 */
408
409 ObjectMap(const ObjectMap&) = delete;
410 ObjectMap& operator=(const ObjectMap&) = delete;
411
412 /**
413 Static function to demangle type names returned from typeid(T).name()
414
415 @param name typename returned from typeid(T).name()
416
417 @return demangled name
418 */
419 static std::string demangle_name(const char* name);
420
421 /**
422 Create a string that lists information for the specified
423 variable. This will list all child variables, including the
424 values for any children that are fundamentals, up to the
425 specified recursion depth.
426
427 @param name Name of variable to list
428
429 @param[out] found Set to true if variable is found, set to false otherwise
430
431 @param recurse Number of levels to recurse (default is 0)
432
433 @return String representing this object and any children
434 included based on the value of recurse
435 */
436 virtual std::string listVariable(std::string name, bool& found, int recurse = 0);
437
438 /**
439 Create a string that lists information for the current object.
440 This will list all child variables, including the values for
441 any children that are fundamentals, up to the specified
442 recursion depth.
443
444 @param recurse Number of levels to recurse (default is 0)
445
446 @return String representing this object and any children
447 included based on the value of recurse
448 */
449 virtual std::string list(int recurse = 0);
450
451 /**
452 Find a variable in this object map
453
454 @param name Name of variable to find
455
456 @return ObjectMap representing the requested variable if it is
457 found, nullptr otherwise
458 */
459 virtual ObjectMap* findVariable(const std::string& name)
460 {
461 auto& variables = getVariables();
462 for ( auto [it, end] = variables.equal_range(name); it != end; ++it )
463 return it->second; // For now, we return only the first match if multiple matches
464 return nullptr;
465 }
466
467private:
468 /**
469 Called to activate this ObjectMap. This will create the
470 metadata object and call activate_callback().
471
472 @param parent ObjectMap parent of this ObjectMap
473
474 @param name Name of this ObjectMap in the context of the parent
475 */
476 void activate(ObjectMap* parent, const std::string& name)
477 {
478 mdata_ = new ObjectMapMetaData(parent, name);
480 }
481
482 /**
483 Deactivate this object. This will remove and delete the
484 metadata and call deactivate_callback().
485 */
486 void deactivate()
487 {
488 delete mdata_;
489 mdata_ = nullptr;
491 }
492
493 /**
494 Function called by list to recurse the object hierarchy
495
496 @param name Name of current ObjectMap
497
498 @param level Current level of recursion
499
500 @param recurse Number of levels deep to recurse
501 */
502 std::string listRecursive(const std::string& name, int level, int recurse);
503};
504
505/**
506 ObjectMap object for non-fundamental, non-container types. This
507 class allows for child variables.
508 */
510{
511protected:
512 /**
513 Map that child ObjectMaps are stored in
514 */
515 std::multimap<std::string, ObjectMap*> variables_;
516
517 /**
518 Default constructor
519 */
521
522public:
523 /**
524 Destructor. Should not be called directly (i.e. do not call
525 delete on the object). Call decRefCount() when object is no
526 longer needed. This will also call decRefCount() on all its
527 children.
528 */
530 {
531 for ( auto& obj : variables_ ) {
532 if ( obj.second != nullptr ) obj.second->decRefCount();
533 }
534 }
535
536 /**
537 Disallow copying and assignment
538 */
539
541 ObjectMapWithChildren& operator=(const ObjectMapWithChildren&) = delete;
542
543 /**
544 Adds a variable to this ObjectMap
545
546 @param name Name of the object in the context of this ObjectMap
547
548 @param obj ObjectMap to add as a variable
549 */
550 void addVariable(const std::string& name, ObjectMap* obj) override { variables_.emplace(name, obj); }
551
552 /**
553 Get the list of child variables contained in this ObjectMap
554
555 @return Reference to map containing ObjectMaps for this ObjectMap's
556 child variables. pair.first is the name of the variable in the
557 context of this object. pair.second is a pointer to the ObjectMap.
558 */
559 const std::multimap<std::string, ObjectMap*>& getVariables() override { return variables_; }
560};
561
562
563/**
564 ObjectMap object to create a level of hierarchy that doesn't
565 represent a specific object. This can be used to create views of
566 data that don't align specifically with the underlying data
567 structures.
568 */
570{
571public:
572 /**
573 Default constructor
574 */
576
577
578 /**
579 Destructor. Should not be called directly (i.e. do not call
580 delete on the object). Call decRefCount() when object is no
581 longer needed. This will also call decRefCount() on all its
582 children.
583 */
584 ~ObjectMapHierarchyOnly() override = default;
585
586 /**
587 Returns empty string since there is no underlying object being
588 represented
589
590 @return empty string
591 */
592 std::string getType() override { return ""; }
593
594 /**
595 Returns nullptr since there is no underlying object being
596 represented
597
598 @return nullptr
599 */
600 void* getAddr() override { return nullptr; }
601};
602
603
604/**
605 ObjectMap object for non-fundamental, non-container types. This
606 class allows for child variables.
607 */
609{
610protected:
611 /**
612 Type of the variable as given by the demangled version of
613 typeid(T).name() for the type.
614 */
615 std::string type_;
616
617 /**
618 Address of the variable for reading and writing
619 */
620 void* addr_ = nullptr;
621
622public:
623 /**
624 Default constructor
625 */
626 ObjectMapClass() = default;
627
628 /**
629 Disallow copying and assignment
630 */
631
633 ObjectMapClass& operator=(const ObjectMapClass&) = delete;
634
635 /**
636 Constructor
637
638 @param addr Address of the object represented by this ObjectMap
639
640 @param type Type of this object as return by typeid(T).name()
641 */
642 ObjectMapClass(void* addr, const std::string& type) :
644 type_(demangle_name(type.c_str())),
645 addr_(addr)
646 {}
647
648 /**
649 Destructor. Should not be called directly (i.e. do not call
650 delete on the object). Call decRefCount() when object is no
651 longer needed. This will also call decRefCount() on all its
652 children.
653 */
654 ~ObjectMapClass() override = default;
655
656 /**
657 Get the type of the represented object
658
659 @return type of represented object
660 */
661 std::string getType() override { return type_; }
662
663 /**
664 Get the address of the represented object
665
666 @return address of represented object
667 */
668 void* getAddr() override { return addr_; }
669};
670
671
672/**
673 Templated implementation of ObjectMapComparison
674 */
675template <typename T>
676class ObjectMapComparison_impl : public ObjectMapComparison
677{
678public:
679 ObjectMapComparison_impl(const std::string& name, T* var, Op op, const std::string& value) :
680 ObjectMapComparison(name),
681 var_(var),
682 op_(op)
683 {
684 // If we are looking for changes, get the current value as the
685 // comp_value_
686 if ( op_ == Op::CHANGED ) {
687 comp_value_ = *var_;
688 }
689 // Otherwise, we have to have a valid value. If the value is
690 // not valid, it will throw an exception.
691 else {
692 comp_value_ = SST::Core::from_string<T>(value);
693 }
694 }
695
696
697 bool compare() override
698 {
699 switch ( op_ ) {
700 case Op::LT:
701 return *var_ < comp_value_;
702 break;
703 case Op::LTE:
704 return *var_ <= comp_value_;
705 break;
706 case Op::GT:
707 return *var_ > comp_value_;
708 break;
709 case Op::GTE:
710 return *var_ >= comp_value_;
711 break;
712 case Op::EQ:
713 return *var_ == comp_value_;
714 break;
715 case Op::NEQ:
716 return *var_ != comp_value_;
717 break;
718 case Op::CHANGED:
719 {
720 // See if we've changed
721 bool ret = *var_ != comp_value_;
722 // Store the current value for the next test
723 comp_value_ = *var_;
724 return ret;
725 } break;
726 default:
727 return false;
728 break;
729 }
730 }
731
732 std::string getCurrentValue() override { return SST::Core::to_string(*var_); }
733
734
735private:
736 T* var_ = nullptr;
737 T comp_value_ = T();
738 Op op_ = Op::INVALID;
739};
740
741/**
742 ObjectMap representing fundamental types, and classes treated as
743 fundamental types. In order for an object to be treated as a
744 fundamental, it must be printable using SST::Core::to_string() and
745 assignable using SST::Core::from_string(). If this is not true, it
746 is possible to create a template specialization for the type
747 desired to be treated as a fundamental. The specialization will
748 need to provide the functions for getting and setting the values as
749 a string.
750*/
751template <typename T>
752class ObjectMapFundamental : public ObjectMap
753{
754protected:
755 /**
756 Address of the variable for reading and writing
757 */
758 T* addr_ = nullptr;
759
760public:
761 /**
762 Set the value of the object represented as a string
763
764 @param value Value to set the underlying object to, represented
765 as a string
766 */
767 virtual void set_impl(const std::string& value) override { *addr_ = SST::Core::from_string<T>(value); }
768
769 /**
770 Get the value of the object as a string
771 */
772 virtual std::string get() override { return SST::Core::to_string(*addr_); }
773
774 /**
775 Returns true as object is a fundamental
776
777 @return true
778 */
779 bool isFundamental() override { return true; }
780
781 /**
782 Get the address of the variable represented by the ObjectMap
783
784 @return Address of variable
785 */
786 void* getAddr() override { return (void*)addr_; }
787
788 explicit ObjectMapFundamental(T* addr) :
789 addr_(addr)
790 {}
791
792 /**
793 Destructor. Should not be called directly (i.e. do not call
794 delete on the object). Call decRefCount() when object is no
795 longer needed. This will also call decRefCount() on all its
796 children.
797 */
798 ~ObjectMapFundamental() override = default;
799
800 /**
801 Disallow copying and assignment
802 */
803
804 ObjectMapFundamental(const ObjectMapFundamental&) = delete;
805 ObjectMapFundamental& operator=(const ObjectMapFundamental&) = delete;
806
807 /**
808 Return the type represented by this ObjectMap as given by the
809 demangled version of typeid(T).name()
810
811 @return type of underlying object
812 */
813 std::string getType() override { return demangle_name(typeid(T).name()); }
814
815 ObjectMapComparison* getComparison(
816 const std::string& name, ObjectMapComparison::Op op, const std::string& value) override
817 {
818 return new ObjectMapComparison_impl<T>(name, addr_, op, value);
819 }
820};
821
822/**
823 Class used to map containers
824 */
825template <class T>
826class ObjectMapContainer : public ObjectMapWithChildren
827{
828protected:
829 T* addr_;
830
831public:
832 bool isContainer() override final { return true; }
833
834 std::string getType() override { return demangle_name(typeid(T).name()); }
835
836 void* getAddr() override { return addr_; }
837
838 explicit ObjectMapContainer(T* addr) :
839 addr_(addr)
840 {}
841
842 ~ObjectMapContainer() override = default;
843};
844
845/**
846 Class used to map arrays
847 */
848template <class T>
849class ObjectMapArray : public ObjectMapContainer<T>
850{
851protected:
852 size_t size;
853
854public:
855 virtual size_t getSize() { return size; }
856 ObjectMapArray(T* addr, size_t size) :
857 ObjectMapContainer<T>(addr),
858 size(size)
859 {}
860 ~ObjectMapArray() override = default;
861};
862
863} // namespace SST::Core::Serialization
864
865#endif // SST_CORE_SERIALIZATION_OBJECTMAP_H
std::string type_
Type of the variable as given by the demangled version of typeid(T).name() for the type.
Definition objectMap.h:615
ObjectMapClass(const ObjectMapClass &)=delete
Disallow copying and assignment.
ObjectMapClass(void *addr, const std::string &type)
Constructor.
Definition objectMap.h:642
void * addr_
Address of the variable for reading and writing.
Definition objectMap.h:620
void * getAddr() override
Get the address of the represented object.
Definition objectMap.h:668
~ObjectMapClass() override=default
Destructor.
std::string getType() override
Get the type of the represented object.
Definition objectMap.h:661
ObjectMapClass()=default
Default constructor.
Templated implementation of ObjectMapComparison.
Definition objectMap.h:677
Base class for interacting with data from ObjectMap.
Definition objectMap.h:74
Class used to map containers.
Definition objectMap.h:827
std::string getType() override
Get the type of the variable represented by the ObjectMap.
Definition objectMap.h:834
void * getAddr() override
Get the address of the variable represented by the ObjectMap.
Definition objectMap.h:836
bool isContainer() override final
Check to see if this ObjectMap represents a container.
Definition objectMap.h:832
ObjectMap representing fundamental types, and classes treated as fundamental types.
Definition objectMap.h:753
~ObjectMapFundamental() override=default
Destructor.
virtual void set_impl(const std::string &value) override
Set the value of the object represented as a string.
Definition objectMap.h:767
ObjectMapFundamental(const ObjectMapFundamental &)=delete
Disallow copying and assignment.
std::string getType() override
Return the type represented by this ObjectMap as given by the demangled version of typeid(T)....
Definition objectMap.h:813
virtual std::string get() override
Get the value of the object as a string.
Definition objectMap.h:772
void * getAddr() override
Get the address of the variable represented by the ObjectMap.
Definition objectMap.h:786
bool isFundamental() override
Returns true as object is a fundamental.
Definition objectMap.h:779
T * addr_
Address of the variable for reading and writing.
Definition objectMap.h:758
ObjectMapHierarchyOnly()=default
Default constructor.
void * getAddr() override
Returns nullptr since there is no underlying object being represented.
Definition objectMap.h:600
~ObjectMapHierarchyOnly() override=default
Destructor.
std::string getType() override
Returns empty string since there is no underlying object being represented.
Definition objectMap.h:592
ObjectMapWithChildren()=default
Default constructor.
void addVariable(const std::string &name, ObjectMap *obj) override
Adds a variable to this ObjectMap.
Definition objectMap.h:550
~ObjectMapWithChildren() override
Destructor.
Definition objectMap.h:529
std::multimap< std::string, ObjectMap * > variables_
Map that child ObjectMaps are stored in.
Definition objectMap.h:515
ObjectMapWithChildren(const ObjectMapWithChildren &)=delete
Disallow copying and assignment.
const std::multimap< std::string, ObjectMap * > & getVariables() override
Get the list of child variables contained in this ObjectMap.
Definition objectMap.h:559
Base class for objects created by the serializer mapping mode used to map the variables for objects.
Definition objectMap.h:112
ObjectMap()=default
Default constructor primarily used for the "top" object in the hierarchy.
int32_t getRefCount()
Get the current reference count.
Definition objectMap.h:272
bool isReadOnly()
Check to see if this object is read-only.
Definition objectMap.h:188
virtual ObjectMap * findVariable(const std::string &name)
Find a variable in this object map.
Definition objectMap.h:459
static const std::multimap< std::string, ObjectMap * > emptyVars
Static empty variable map for use by versions that don't have variables (i.e.
Definition objectMap.h:120
std::string getFullName()
Get the full hierarchical name of the variable represented by this ObjectMap, based on the path taken...
Definition objectMap.cc:32
virtual std::string getType()=0
Get the type of the variable represented by the ObjectMap.
ObjectMap * selectVariable(std::string name, bool &loop_detected)
Get the ObjectMap for the specified variable.
Definition objectMap.cc:59
bool read_only_
Indicates whether or not the variable is read-only.
Definition objectMap.h:144
virtual std::string listVariable(std::string name, bool &found, int recurse=0)
Create a string that lists information for the specified variable.
Definition objectMap.cc:153
ObjectMap(const ObjectMap &)=delete
Disallow copying and assignment.
virtual ObjectMapComparison * getComparison(const std::string &UNUSED(name), ObjectMapComparison::Op UNUSED(op), const std::string &UNUSED(value))
Get a watch point for this object.
Definition objectMap.h:279
virtual std::string list(int recurse=0)
Create a string that lists information for the current object.
Definition objectMap.cc:177
virtual std::string get()
Get the value of the variable as a string.
Definition objectMap.h:329
std::string getName()
Get the name of the variable represented by this ObjectMap.
Definition objectMap.cc:26
virtual const std::multimap< std::string, ObjectMap * > & getVariables()
Get the list of child variables contained in this ObjectMap.
Definition objectMap.h:246
virtual bool isContainer()
Check to see if this ObjectMap represents a container.
Definition objectMap.h:396
virtual void addVariable(const std::string &UNUSED(name), ObjectMap *UNUSED(obj))
Adds a variable to this ObjectMap.
Definition objectMap.h:316
virtual ~ObjectMap()=default
Destructor.
void incRefCount()
Increment the reference counter for this ObjectMap.
Definition objectMap.h:254
virtual bool isFundamental()
Check to see if this ObjectMap represents a fundamental or a class treated as a fundamental.
Definition objectMap.h:388
void set(const std::string &value)
Sets the value of the variable represented by the ObjectMap to the specified value,...
Definition objectMap.h:343
virtual void deactivate_callback()
Function that will get called when this object is deactivated (i.e selectParent() is called)
Definition objectMap.h:164
virtual void set_impl(const std::string &UNUSED(value))
Function implemented by derived classes to implement set().
Definition objectMap.h:153
virtual void activate_callback()
Function that will get called when this object is selected.
Definition objectMap.h:158
static std::string demangle_name(const char *name)
Static function to demangle type names returned from typeid(T).name()
Definition objectMap.cc:137
void decRefCount()
Decrement the reference counter for this ObjectMap.
Definition objectMap.h:262
ObjectMap * selectParent()
Get the parent for this ObjectMap.
Definition objectMap.cc:47
void setReadOnly(bool state=true)
Set the read-only state of the object.
Definition objectMap.h:198
ObjectMapMetaData * mdata_
Metadata object for walking the object hierarchy.
Definition objectMap.h:138
virtual void * getAddr()=0
Get the address of the variable represented by the ObjectMap.
Metadata object that each ObjectMap has a pointer to in order to track the hierarchy information whil...
Definition objectMap.h:38
ObjectMapMetaData(ObjectMap *parent, const std::string &name)
Constructor for intializing data memebers.
Definition objectMap.h:53
ObjectMap * parent
Parent object that contained this object and through which it was selected.
Definition objectMap.h:43
std::string name
Name of this object in the context of the currently set parent.
Definition objectMap.h:48