The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::Parameter< ValueType > Class Template Reference

Parameter instance, templated to contain only a specific type. More...

#include <Parameter.hpp>

Inheritance diagram for sparta::Parameter< ValueType >:
Collaboration diagram for sparta::Parameter< ValueType >:

Public Types

enum class  ParameterAttribute : std::uint8_t {
  DEFAULT = 0 , __FIRST = DEFAULT , LOCKED = 1 , HIDDEN = 2 ,
  __LAST
}
 ParameterAttribute enum class which describes special attributes of this parameter. More...
 
using type = ValueType
 Type held by this parameter. This cannot change at run-time.
 
using value_type = ValueType
 
- Public Types inherited from sparta::ParameterBase
typedef class sparta::ParameterBase::ParameterValueIterator const_iterator
 Generic value iterator for a SINGLE parameter which represents values ONLY as std::string.
 
- Public Types inherited from sparta::TreeNode
typedef uint64_t node_uid_type
 Type of unique-identifier assigned to every node.
 
typedef std::vector< TreeNode * > ChildrenVector
 Vector of TreeNode children.
 
typedef std::vector< std::string > AliasVector
 Vector of aliases (other names for this node)
 
typedef std::multimap< std::string, TreeNode * > ChildNameMapping
 Mapping of names, aliases, and groups to individual child nodes within one node. This must be in a deterministic order, so an ordered container (e.g. std::map) is required. A sorted contained is probably desirable, but not required.
 
typedef uint32_t group_idx_type
 Index within a group.
 
typedef std::weak_ptr< TreeNodeWeakPtr
 Weak pointer to a TreeNode. Acquire with getWeakPtr.
 
typedef std::weak_ptr< const TreeNodeConstWeakPtr
 Weak pointer to a const TreeNode. Acquire with getWeakPtr.
 
typedef std::shared_ptr< TreeNodeSharedPtr
 Shared pointer to TreeNode. Acquire with WeakPtr::lock().
 
typedef std::map< const std::string *, std::vector< TreeNode * > > TagsMap
 Map of strings (interned in StringManager) tags to TreeNodes.
 
- Public Types inherited from sparta::PhasedObject
enum  TreePhase {
  TREE_BUILDING = 0 , TREE_CONFIGURING = 1 , TREE_FINALIZING = 2 , TREE_FINALIZED = 3 ,
  TREE_TEARDOWN = 4
}
 Current phase of tree construction (applies to node and entire tree). More...
 

Public Member Functions

 Parameter (const std::string &name, const ValueType &def, const std::string &doc, bool isvolatile=false)
 Construct a parameter.
 
 Parameter (const std::string &name, const ValueType &def, const std::string &doc, ParameterSet *ps, bool isvolatile=false)
 Constructor used by the PARAMETER macro.
 
 Parameter (const std::string &name, const ValueType &def, const std::string &doc, const ParameterAttribute &attr, ParameterSet *ps, bool isvolatile=false)
 
virtual ~Parameter ()=default
 Destructor.
 
template<class T , bool(T::*)(ValueType &, const sparta::TreeNode *) TMethod>
void addDependentValidationCallback (T *obj, const std::string &name)
 Adds dependency callback to a class member function.
 
void addDependentValidationCallback (bool(*method)(ValueType &, const sparta::TreeNode *), const std::string &name)
 Adds dependency callback via a global function or lambda.
 
virtual const std::string getTypeName () const override final
 Gets the human-readable name of this parameter's type.
 
ValueType getDefault () const
 Returns the default value.
 
virtual std::string getDefaultAsString () const override final
 Returns the default value as a string, even if type is a vector.
 
std::string getValueAsString () const override final
 Returns value as a string, even if type is a vector.
 
std::string getValueAsStringAt (size_t idx, bool peek=false) const override final
 Treats this parameter as a vector and gets the value as a string at a specific index. If parameter is not a vector, it is treated as a 1-element vector.
 
std::string getItemValueFromString (const std::vector< uint32_t > &indices, bool peek=false) const override final
 Override from ParameterBase.
 
uint32_t getVectorSizeAt (const std::vector< uint32_t > &indices, bool peek=false) const override final
 Get the size of a nested vector within the parameter located by indices.
 
 operator const ValueType & () const
 Gets a the value currently held by this Parameter.
 
const ValueType & operator() () const
 Gets the value currently held by this Parameter.
 
void ignore () const
 Marks this parameter as ignored.
 
void unread () const
 Mark this parameter as unread and unignored.
 
const ValueType & getValue () const
 Gets the current value of this Parameter.
 
const ValueType & peekValue () const
 Gets the current value of this Parameter without incrementing the read count. This should be used when validating parameters in a Resource Constructor.
 
double getDoubleValue () const override final
 Cast value to double if possible. Throw if not.
 
virtual size_t getNumValues (bool peek=false) const override final
 Gets the number of values in this Parameter.
 
virtual bool isVector () const override final
 Is this parameter a vector?
 
virtual uint32_t getDimensionality () const override final
 Determines the number of dimensions of this Parameter. A scalar has 0 dimensions. A parameter of type vector<uint32_t> would have a dimensionality of 1. vector<vector<uint32_t>> would have a dimensionality of 2.
 
virtual ParameterBase::const_iterator begin () const override final
 Get begin iterator.
 
virtual ParameterBase::const_iterator end () const override final
 Get begin iterator.
 
template<class T >
bool operator== (const Parameter< T > &rhp) const
 Compares two Parameter objects by value.
 
template<class T >
bool operator!= (const Parameter< T > &rhp) const
 Compares two Parameter objects by value.
 
bool operator> (const Parameter< type > &rhp) const
 Compares two Parameter objects by value.
 
template<class T >
bool operator>= (const Parameter< T > &rhp) const
 Compares two Parameter objects by value.
 
bool operator< (const Parameter< type > &rhp) const
 Compares two Parameter objects by value.
 
bool operator<= (const Parameter< type > &rhp) const
 Compares two Parameter objects by value.
 
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type operator== (const T rhp) const
 Increments read count.
 
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type operator!= (const T rhp) const
 Increments read count.
 
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type operator> (const T rhp) const
 Increments read count.
 
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type operator>= (const T rhp) const
 Increments read count.
 
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type operator< (const T rhp) const
 Increments read count.
 
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type operator<= (const T rhp) const
 Increments read count.
 
void operator= (const Parameter &p)=delete
 Copy assignment - deleted explicitly.
 
void operator= (const ValueType &v)
 Assigns the specified value to this parameter.
 
virtual bool isDefaultOverridden () const override final
 Has the default value (NOT the current value) for parameter been overridden in any way (including partially changed).
 
virtual void overrideDefaultFromString (const std::string &str) override final
 Sets the default value of this non-vector parameter for architecture baseline configuration purposes.
 
virtual void overrideDefaultFromStringVector (const std::vector< std::string > &vec) override final
 Sets the default value of this vector parameter for architecture baseline configuration purposes.
 
virtual void overrideDefaultItemValueFromString (const std::vector< uint32_t > &indices, const std::string &str) override final
 Partially override the default default value in some element at an n-dimensional array specified.
 
virtual void overrideDefaultResizeVectorsFromString (const std::vector< uint32_t > &indices) override final
 Override the default value by clearing the possibly-nested vector (if this parameter is a vector). The nested vector contens can then be set by overrideDefaultItemValueFromString.
 
virtual void overrideDefaultClearVectorValue () override final
 If the parameter is a vector type, clears the default value so that it becomes an empty vector (regardless of dimensionality)
 
virtual void restoreValueFromDefaultImpl_ () override final
 Implements restoreValueFromDefault.
 
virtual bool equals (const ParameterBase &other) override final
 Returns true if the value of this equals other.
 
virtual void resizeVectorsFromString (const std::vector< uint32_t > &indices) override final
 Attempt to resize a vector nested within this parameter to contain the vector indicated by indices.
 
virtual void clearVectorValue () override final
 If the parameter is a vector type, clears the value so that it becomes an empty vector (regardless of dimensionality)
 
sparta::utils::DisplayBase setNumericDisplayBase (sparta::utils::DisplayBase base)
 Set the numeric base for displaying the value of this parameter.
 
sparta::utils::DisplayBase getNumericDisplayBase () const
 Gets the numeric base for displaying the value of this parameter.
 
bool validateIndependently (std::string &err_names) const override
 Performs validation independently of all other Parameters.
 
bool validateDependencies (const TreeNode *node, std::string &err_names) const override
 Invokes all validation callbacks for a particular node in the device tree and returns true if none of them fail.
 
template<class U >
Parameter< ValueType > & operator<< (U e)
 Helper for constructing vectors.
 
virtual bool isVisibilityAllowed () const override
 Query if this parameter is safe to be displayed via prints, dumps. A parameter should not be displayed if it is HIDDEN and the subtree containing this parameter is already locked.
 
- Public Member Functions inherited from sparta::ParameterBase
 ParameterBase (const std::string &name, const std::string &desc)
 Constructor.
 
virtual ~ParameterBase ()
 Destructor.
 
void setIsVolatile ()
 Set volatile flag (allows write after read)
 
bool isVolatile () const
 Is this a volatile parmaeter?
 
virtual bool isDefault () const
 Is this parameter's current value the default value.
 
std::string peekItemValueFromString (const std::vector< uint32_t > &indices) const
 Wrapper for getItemValueFromString with peek=true.
 
template<class T >
const T getValueAs () const
 Gets the value of this ParameterBase as a templated type T if this parameter actually contains a value of type T.
 
uint32_t peekVectorSizeAt (const std::vector< uint32_t > &indices) const
 Wrapper of getVectorSizeAt with peek=true.
 
size_t peekNumValues () const
 Wrapper for getNumValues with peek=true.
 
void restoreValueFromDefault ()
 Attempts to restore the devalue value of this parameter.
 
void setValueFromString (const std::string &str, bool poke=false)
 Attempts to assign a value to this non-vector Parameter from a string.
 
void setValueFromStringVector (const std::vector< std::string > &str, bool poke=false)
 Attempts to assign a value to this vector Parameter from a string.
 
void setItemValueFromString (const std::vector< uint32_t > &indices, const std::string &str)
 Attempts to assign a value to this nested vector Parameter from a string at a position within the vector indicated by indices.
 
virtual std::string stringize (bool pretty=false) const override
 Render description of this parameter as a string.
 
void associateParametersForModification (std::vector< const ParameterBase * > params, const sparta::SpartaHandler &modifier_callback)
 Associate a parameter with this parameter for future modification.
 
uint32_t getWriteCount () const
 Number of times this Parameter has been written after initialization.
 
uint32_t getReadCount () const
 Number of times this Parameter has been read after initialization or after the last write (or explicit resetReadCount_() call)
 
bool isReadOrIgnored () const
 Is this parameter ignored or read at least once (barring any reset of the read count or ignore flag)
 
bool isIgnored () const
 Has this parameter been ignored (without having read count reset after)
 
virtual bool supportsCompression () const
 Scalar parameters may compress well, but we cannot really make a strong enough determination without knowing more about the parameter. Let's disable compression for these by default.
 
std::string setStringQuote (const std::string &s)
 Set the quote sequence for printing strings.
 
- Public Member Functions inherited from sparta::TreeNode
const ClockgetClock () override
 Walks up parents (starting with self) until a parent with an associated local clock is found, then returns that clock.
 
const ClockgetClock () const
 
const ClockgetLocalClock ()
 Gets the clock associated directly with this Node. This is useful for configuration and simulator debug, but not at run-time.
 
const ClockgetLocalClock () const
 
virtual void setClock (const Clock *clk)
 Assigns a clock to this node. This clock will then be accessed by any descendant which has no assigned clock or an ancestor with an assigned clock between that descendant and this node. getClock returns the Clock associated with the nearest ancestor.
 
SchedulergetScheduler (const bool must_exist=false)
 Get the scheduler associated with this tree node's root.
 
const SchedulergetScheduler (const bool must_exist=false) const
 
WeakPtr getWeakPtr ()
 Gets a weak pointer to this TreeNode. This weak pointer is guaranteed to expire when this TreeNode is destructed unless locked.
 
ConstWeakPtr getWeakPtr () const
 Const variant of getWeakPtr.
 
virtual void addLink (TreeNode *node, const std::string &label)
 Link this tree node with another tree node.
 
virtual void activateLink (const std::string &label)
 Activate one of the links added with addLink.
 
 TreeNode ()=delete
 Not default-constructable.
 
 TreeNode (const TreeNode &)=delete
 Not copy-constructable.
 
 TreeNode (TreeNode &&rhp)
 Move constructor.
 
TreeNodeoperator= (const TreeNode &)=delete
 Not assign-constructable.
 
 TreeNode (TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, bool is_indexable)
 TreeNode full constructor. Initializes node and adds it as a child of an existing tree node (if parent is not null).
 
 TreeNode (TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc)
 TreeNode constructor with no is_indexable parameter [defaults to true].
 
 TreeNode (const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc)
 TreeNode constructor with no parent Node.
 
 TreeNode (TreeNode *parent, const std::string &name, const std::string &desc)
 TreeNode constructor with no group information.
 
 TreeNode (TreeNode *parent, const std::string &group, group_idx_type group_idx, const std::string &desc)
 TreeNode constructor for anonymous node with group information.
 
 TreeNode (const std::string &name, const std::string &desc)
 TreeNode constructor with no parent node or group information.
 
virtual ~TreeNode ()
 Virtual destructor.
 
void addAlias (const std::string &alias)
 Add a single alias for this node.
 
void addAliases (const AliasVector &v)
 Adds each element of a vector of aliases to this node..
 
void addTag (const std::string &tag)
 Adds single tag to this node.
 
void addTags (const std::vector< std::string > &v)
 Adds each elements of a vector of tags to this node.
 
void stringizeTags (std::stringstream &ss) const
 Render tags to a string in the form: " tags:[tag0, tag1]" If there are any tags. The leading space makes this a useful sub-utility of stringize because if there are no tags, returns empty string with no leading space.
 
node_uid_type getNodeUID () const
 Gets the unique ID of this node.
 
const std::string & getName () const override
 Gets the name of this node.
 
const std::string * getNamePtr () const
 Gets the name of this node's string pointer which isinterned in StringManager)
 
bool isAnonymous () const
 Is this node anonymous.
 
bool isExpired () const
 Is this expired (i.e. has it been the rhp of a move constructor)
 
bool isIndexableByGroup () const
 Returns whether this object is accessible through its parent's interfaces for getting children by group and index.
 
const std::string & getGroup () const
 Gets the group name of this node.
 
const std::string * getGroupNamePtr () const
 Gets the group name string pointer (interned in StringManager singleton) of this node.
 
group_idx_type getGroupIdx () const
 Gets the group index of this node.
 
const std::vector< const std::string * > & getTags () const
 Gets the set of tags associated with this TreeNode.
 
bool hasTag (const std::string &tag) const
 Does this node have a specific tag (by name)
 
bool hasTag (const std::string *interned_tag_name) const
 Does this node have a specific tag (by string pointer interned with StringManager). This is faster than the alternate hasTag method because it relies only on pointer comparisons.
 
const std::string & getDesc () const
 Gets the description of this node.
 
bool isBuiltin () const
 Is this node in the builtins group.
 
void markHidden (bool hidden=true)
 Marks this TreeNode hidden for the purposes of printint out nodes. This does not make the node inaccessible, but causes it (and its subtree) to be hidden from typical recursive tree printouts.
 
bool isHidden () const
 Is this TreeNode supposed to be hidden during tree printouts This value does not have to be respected by anything using TreeNode and is mainly a UI/printout convenience.
 
void validateName (const std::string &nm)
 Validates the given name string for this TreeNode. Does not consider context (e.g. name collisions)
 
void validateGroup (const std::string &name, const std::string &group, group_idx_type idx)
 Validates the given group name string and group index for this TreeNode. Does not consider context (e.g. name collisions)
 
void validateDesc (const std::string &desc)
 Validates the given description string for this TreeNode.
 
void addExtensionParameters (const std::string &extension_name, std::unique_ptr< ParameterSet > extension_params)
 Add a named parameter set to extend this tree node's metadata.
 
void addExtensionFactory (const std::string &extension_name, std::function< ExtensionsBase *()> factory)
 Add an extension factory to this tree node by its type (name). This method does not actually create any objects at this time. It will validate and create the extension only if asked for later on during simulation.
 
ExtensionsBasegetExtension (const std::string &extension_name)
 Get an extension object by type string. Returns nullptr if not found (unrecognized).
 
ExtensionsBasegetExtension ()
 Get an extension without needing to specify any particular type string. If no extensions exist, returns nullptr. If only one extension exists, returns that extension. If more than one extension exists, throws an exception.
 
const std::set< std::string > & getAllExtensionNames ()
 Extension names, if any. Tree node extensions are typically instantiated on-demand for best performance (you have to explicitly ask for an extension by its name, or it won't be created) - so note that calling this method will trigger the creation of all this node's extensions. The performance cost is proportional to the number of nodes in the virtual parameter tree.
 
void addChild (TreeNode *child, bool inherit_phase=true)
 Adds a TreeNode to this node as a child.
 
void addChild (TreeNode &child)
 AddChild by reference for convenience.
 
void makeSubtreePrivate ()
 Make the entire subtree private.
 
void setScopeRoot ()
 
bool isScopeRoot () const
 
void lockdownParameters ()
 Method to put the device tree in lockdown phase. All LOCKED and HIDDEN parameters are frozen after this point. Regular parameters are not affected by this phase. This method requires a Simulation pointer and will assert at compile time if anyone tries to lockdown the tree without the context of a Simulation.
 
virtual bool isAttached () const
 Is this node part of a device tree with a proper RootTreeNode at the root.
 
virtual TreeNodegetParent ()
 Gets immediate parent of this node if one exists.
 
virtual const TreeNodegetParent () const
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type>
const T getParentAs (bool must_exist=true) const
 Retrieves a parent casted to type T* if this node has a parent.
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
const T * getParentAs (bool must_exist=true) const
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type>
getParentAs (bool must_exist=true)
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
T * getParentAs (bool must_exist=true)
 
virtual TreeNodegetRoot ()
 Gets farthest ancestor of this node.
 
virtual const TreeNodegetRoot () const
 
TreeNodegetScopeRoot ()
 
const TreeNodegetScopeRoot () const
 
const TreeNodegetExpectedRoot () const
 build-time equivalent to getRoot before an object is actually attached to a tree. This is a mainly a framework and debugging tool for determining what the root of a node being constructed will be when complete
 
app::SimulationgetSimulation () const
 Gets the simulation (if any) associated with this tree.
 
uint32_t getNumChildren () const
 Gets the number of children that this node has including those in the sparta builtins group.
 
TreeNodegetChildAt (uint32_t idx) const
 Gets a child at a position in the children vector in the order in which they were added to this node.
 
const ChildrenVector getChildren () const
 Gets a vector of all children of this node in any group in the order in which they were added to this node.
 
uint32_t getChildren (std::vector< TreeNode * > &results, bool ignore_builtin_group=true, bool ignore_anonymous_nodes=true)
 Gets all children of this node in the order in which they were added to this node.
 
template<class T >
uint32_t getChildrenOfType (std::vector< T * > &results) const
 return all the children matching a particular type using dynamic cast.
 
sparta::TreeNodefindAncestorByName (const std::string &name)
 Find ancestor by name.
 
template<typename T >
sparta::TreeNodefindAncestorByType ()
 Find ancestor by type.
 
sparta::TreeNodefindAncestorByTag (const std::string &tag)
 Find the first ancestor with a particular tag.
 
template<typename T >
T * findAncestorResourceByType ()
 Find an ancestor's resource with a certain type.
 
const AliasVectorgetAliases () const
 Gets a vector of all aliases of this node.
 
uint32_t getChildrenIdentifiers (std::vector< std::string > &idents, bool ignore_builtin_group=true) const
 Gets all child identifiers, aliases, group names, and group-aliases which can be used to refer to a child of this node.
 
std::vector< const std::string * > getIdentifiers () const
 Gets all the identifiers for this node (excluding groups)
 
uint32_t getGroupSize (const std::string &group)
 Gets the number of nodes in a group.
 
group_idx_type getGroupIndexMax (const std::string &group)
 Gets the largest index of a node in the given group.
 
uint32_t getGroup (const std::string &group, std::vector< TreeNode * > &results)
 Gets all nodes in a child group.
 
uint32_t findChildren (const std::string &pattern, std::vector< TreeNode * > &results, std::vector< std::vector< std::string > > &replacements)
 Finds all children starting at this node with a given pattern relative to this node by matching names an aliases. Appends each found child to <results>.
 
uint32_t findChildren (const std::string &pattern, std::vector< TreeNode * > &results)
 Version of findChildren with no replacements vector.
 
virtual uint32_t findImmediateChildren_ (std::regex &expr, std::vector< TreeNode * > &found, std::vector< std::vector< std::string > > &replacements, bool allow_private=false)
 Finds immediate children with some identity (name or alias) matching a regex.
 
uint32_t findImmediateChildren_ (std::regex &expr, std::vector< TreeNode * > &found, bool allow_private=false)
 Variant of findImmediateChildren_ with no replacements vector.
 
virtual uint32_t findImmediateChildren_ (std::regex &expr, std::vector< const TreeNode * > &found, std::vector< std::vector< std::string > > &replacements, bool allow_private=false) const
 Const-qualified variant of findImmediateChildren_.
 
uint32_t findImmediateChildren_ (std::regex &expr, std::vector< const TreeNode * > &found, bool allow_private=false) const
 Variant of const-qualified findImmediateChildren_ with no replacements vector.
 
bool locationMatchesPattern (const std::string &pattern, const TreeNode *pat_loc) const
 Determines if the given pattern (which may contain wildcards) can describe this node.
 
TreeNodegetChild (const std::string &name, bool must_exist=true)
 Retrieves a child with this dotted path name.
 
const TreeNodegetChild (const std::string &name, bool must_exist=true) const
 Overloaded const-qualified.
 
std::string getDeepestMatchingPath (const std::string &path) const
 Gets the deepest whole node location starting from this node that matches some part of path starting at its beginning.
 
bool hasChild (const std::string &name) const noexcept
 Determines if a child can be found with the given dotted path.
 
bool hasImmediateChild (const TreeNode *n) const noexcept
 Determines if the node n is an immediate child of this node.
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type, class ConstT = typename ptr_to_const_obj_ptr<T>::type>
const ConstT getChildAs (const std::string &name, bool must_exist=true) const
 Retrieves a child that is castable to T with the given dotted path.
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
const T * getChildAs (const std::string &name, bool must_exist=true) const
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type>
getChildAs (const std::string &name, bool must_exist=true)
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
T * getChildAs (const std::string &name, bool must_exist=true)
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type, class ConstT = typename ptr_to_const_obj_ptr<T>::type>
ConstT getAs () const
 Retrieves this node after casting to type T.
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
const T * getAs () const
 Retrieves this node after casting to type const T.
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type>
getAs ()
 Retrieves this node after casting to type const T.
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
T * getAs ()
 Retrieves this node after casting to type const T.
 
uint32_t findChildrenByTag (const std::string &tag, std::vector< TreeNode * > &results, int32_t max_depth=-1)
 Finds a set of all children having the selected tag which this node or descendants of this node within a distance of the given max_depth.
 
bool isDescendantOf (const TreeNode *ancestor, int32_t max_depth=-1) const
 Determines if this node is a descendant of the specified ancestor node within some number of generations (depth).
 
std::string getLocation () const override final
 
std::string getDisplayLocation () const
 Returns the location of this node in the device tree which might not be usable for navigating the device tree (it cannot be used as an argument for getChild/findChildren).
 
std::string getExpectedLocation () const
 build-time equivalent to getLocation before an object is actually attached to a tree. This is a mainly a framework and debugging tool for determining what the location of a node currently being constructed will be when complete.
 
std::string renderSubtree (int32_t max_depth=-1, bool show_builtins=false, bool names_only=false, bool hide_hidden=false, bool(*leaf_filt_fxn)(const TreeNode *)=nullptr) const
 Renders the subtree starting at this node as a string containing an indentation-based depth-first representation.
 
uint32_t getLevel () const
 Gets the level of this node. 0 is root.
 
template<typename T >
uint32_t getRecursiveNodeCount () const
 Recursively gets the count of a nodes that are a subclass of a particular type (determined by dynamic_cast). Includes all descendants of this node in the tree, but excludes this node.
 
uint32_t getPossibleNotifications (std::vector< NotificationInfo > &infos) const
 Gets information on the possible notifications generated by this node (excludes children).
 
void dumpPossibleNotifications (std::ostream &o) const noexcept
 Dumps a listing of the notifications which this node can generate to the ostream o.
 
template<typename DataT = ANY_TYPE>
uint32_t locateNotificationSources (std::vector< TreeNode * > &nodes, const std::string &name="")
 Gets all possible notification info from NotificationSources within this node's subtree.
 
template<typename DataT = ANY_TYPE>
void dumpLocatedNotificationSources (std::ostream &o, const std::string &name="")
 Retrieves the relevant NotificationSources from locateNotificationSources and prints them to the output o.
 
uint32_t getPossibleSubtreeNotifications (std::vector< NotificationInfo > &infos) const noexcept
 Gets information on the possible notifications generated by this node and all its descendants.
 
void dumpPossibleSubtreeNotifications (std::ostream &o) const noexcept
 Dumps a listing of the notifications which this node and its descendants can generate to the ostream o.
 
bool canGenerateNotification (const std::type_info &tinfo, const std::string *name) const
 Can this TreeNode generate a notification of the given type having the given name or pattern.
 
bool canGenerateNotification (const std::type_info &tinfo, const std::string &name) const
 Can this TreeNode generate a notification of the given type having the given name (does not require interned string - will intern automatically with StringManager).
 
bool canGenerateNotification (const NotificationInfo &info) const
 Can this TreeNode generate a notification of the given NotificationInfo.
 
bool canSubtreeGenerateNotification (const std::type_info &tinfo, const std::string *name) const
 Can this TreeNode or its descendants (of any distance) generate a notification of the given type having the given name.
 
bool canSubtreeGenerateNotification (const std::type_info &tinfo, const std::string &name) const
 Can this TreeNode or its descendants (of any distance) generate a notification of the given type having the given name (does not require interned string)
 
bool canSubtreeGenerateNotifications (const std::type_info &tinfo, const std::vector< const std::string * > &names) const
 Checks to see if any a subtree can generate any of several notification names which may be patterns.
 
template<typename DataT , typename T , void(T::*)(const TreeNode &, const TreeNode &, const DataT &) TMethod>
void registerForNotification (T *obj, const std::string &name, bool ensure_possible=true)
 Registers a callback method to listen for all notifications having the specified data type DataT and name (or any name if name is "") occuring on this node or any descendant (subtree).
 
template<typename DataT , typename T , void(T::*)(const DataT &) TMethod>
void registerForNotification (T *obj, const std::string &name, bool ensure_possible=true)
 
template<typename DataT , typename T , void(T::*)(const TreeNode &, const TreeNode &, const DataT &) TMethod>
void deregisterForNotification (T *obj, const std::string &name)
 Removes at most one registration made with registerForNotification.
 
template<typename DataT , typename T , void(T::*)(const DataT &) TMethod>
void deregisterForNotification (T *obj, const std::string &name)
 
bool hasObserversRegisteredForNotification (const std::type_info &tinfo, const std::string *name) const noexcept
 Determines if this TreeNode (not descendants) has any observers for this type of event and name.
 
void getDelegatesRegisteredForNotification (const std::type_info &tinfo, const std::string *name, std::vector< delegate > &dels) noexcept
 Gets the vector of delegates registered for a notification on this TreeNode.
 
- Public Member Functions inherited from sparta::ResourceContainer
 ResourceContainer ()
 Consturct with a null, unlocked resource.
 
 ResourceContainer (const ResourceContainer &)=delete
 Copy construction disbled.
 
 ResourceContainer (ResourceContainer &&)=default
 Move constructor.
 
virtual ~ResourceContainer ()
 Destructor.
 
ResourcegetResource ()
 Gets the resource contained by this node if any. May only be called after finalization begins or during teardown.
 
const ResourcegetResource () const
 Const variant of getResource.
 
bool hasResource () const
 Determines if this node has a resource. This method exists in case the TreeNode is being explored by a tool or interactive UI. Typical TreeNode clients (such as Resources) will assume that there is a resource if they are expecting one.
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type>
const T getResourceAs () const
 Gets the resource contained by this node (if any) as the given type.
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
const T * getResourceAs () const
 Overload of getResourceAs for const access with a non-pointer template type.
 
template<class T , typename = typename std::enable_if<std::is_pointer<T>::value>::type>
getResourceAs ()
 Non-const overload of getResourceAs.
 
template<class T , typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
T * getResourceAs ()
 Non-const overload of getResourceAs.
 
virtual std::string getResourceType () const
 Gets the typename of the resource that this node will eventually contain.
 
virtual std::string getResourceTypeRaw () const
 Gets the typename of the resource that this node will eventually contain.
 
- Public Member Functions inherited from sparta::PhasedObject
 PhasedObject (PhasedObject &&)=default
 
TreePhase getPhase () const
 Gets the trees current phase.
 
virtual bool isBuilding () const
 Is this node (and thus the entire tree above and below it) currently in the TREE_BUILDING phase.
 
virtual bool isBuilt () const
 Is this node (and thus the entire tree above it) "built". Checks that getPhase has passed TREE_BUILDING.
 
virtual bool isConfigured () const
 Is this node (and thus the entire tree above it) "configured". Checks that getPhase has passed TREE_CONFIGURING (i.e. FINALIZED, FINALIZING, TEARDOWN, etc).
 
virtual bool isConfiguring () const
 Is this node (and thus the entire tree above it) currently in the TREE_CONFIGURING phase.
 
virtual bool isFinalizing () const
 Is this node (and thus the entire tree above it) "finalized".
 
virtual bool isFinalized () const
 Is this node (and thus the entire tree above it) "finalized".
 
virtual bool isTearingDown () const
 Is this node (and thus the entire tree above it) in the "teardown" phase.
 
- Public Member Functions inherited from sparta::ArchDataContainer
std::vector< ArchData * > getAssociatedArchDatas ()
 Retrieves all ArchDatas associated with this TreeNode so that children can use it to allocate their data.
 
const std::vector< ArchData * > getAssociatedArchDatas () const
 Const variant of getAssociatedArchDatas.
 
 ArchDataContainer ()=default
 Default constructor.
 
 ArchDataContainer (ArchDataContainer &)=delete
 Copy construction disabled.
 
 ArchDataContainer (ArchDataContainer &&)=default
 Move constructor.
 
virtual ~ArchDataContainer ()
 Virtual destructor.
 

Protected Member Functions

template<class U , class C1 >
std::enable_if< is_vector< C1 >::value, Parameter< ValueType > & >::type operator_insert_ (U e)
 
virtual void setValueFromStringImpl_ (const std::string &str, bool poke=false) override final
 Implements setValueFromString.
 
virtual void setValueFromStringVectorImpl_ (const std::vector< std::string > &vec, bool poke=false) override final
 Implements setValueFromStringVectorImpl_.
 
virtual void setItemValueFromStringImpl_ (const std::vector< uint32_t > &indices, const std::string &str) override final
 Implements setItemValueFromStringImpl_.
 
const ValueType & getValue_ () const
 Iternal getValue_ wrapper which does not increment the read counter.
 
template<typename T >
std::enable_if< std::is_arithmetic< T >::value, double >::type getDoubleValue_ () const
 
template<typename T >
std::enable_if<!std::is_arithmetic< T >::value, double >::type getDoubleValue_ () const
 
- Protected Member Functions inherited from sparta::ParameterBase
void unread_ () const
 Mark this parameter as unread and unignored This is used or preloading defaults to parameters and then clearing the write count. It is intended to be used by ParameterSet.
 
void invokeModifierCB_ ()
 Invoke any register callbacks for this parameter. These callbacks are used by Parameters to make modifications to other parameters.
 
void incrementReadCount_ () const
 Increment the number of reads that will be reported by getReadCount.
 
void resetReadCount_ () const
 Resets the number of reads that wil be reported by getReadCount.
 
void resetWriteCount_ ()
 Resets the number of writes that wil be reported by getWriteCount.
 
void ignore_ () const
 Flag as ignored. See Parameter<T>::ignore.
 
bool usingFinalConfig_ ()
 Ask the simulator if we are using a final config.
 
void incrementWriteCount_ ()
 Increments the number of writes that will be reported by getWriteCount.
 
void logLoadedDefaultValue_ () const
 Log the default loaded to this parameter to the global parameters logger for debugging.
 
void logAssignedValue_ () const
 Log the most recently assigned value given to this parameter to the global parameters logger for debugging.
 
void addToSet_ (ParameterSet *ps)
 Add this parameter to a set - an action which is protected and requires the friendship that the Parameter<> class has.
 
- Protected Member Functions inherited from sparta::TreeNode
std::pair< uint32_t, std::string > recursGetDeepestMatchingPath_ (const std::string &path, size_t name_pos) const
 Finds the deepest node path mathing the input path. Implements getDeepestMatchingPath.
 
void setExpectedParent_ (const TreeNode *parent)
 Tracks a node as an expected parent without actually adding this node as a child. This is used almost exclusively for printing error messages which include a device-tree location BEFORE actually inserting this node into the device tree since node construction can fail.
 
void enterFinalizing_ ()
 Recursively enter TREE_FINALIZING phase.
 
void finalizeTree_ ()
 Recursively create resources based on tree configuration. enter_finalize_ should be invoked after this method successfully completes for an entire tree. Finalizes in the order of construction.
 
void validateTree_ ()
 Iterates the finalized tree and validates each node (e.g. ensures statistics can be evaluated)
 
void enterFinalized_ ()
 Recursively enter TREE_FINALIZED phase.
 
void enterConfig_ () noexcept
 Recursively enter TREE_CONFIGURING phase.
 
void bindTreeEarly_ ()
 Recursively invoke TreeNode::onBindTreeEarly_ and Resource::onBindTreeEarly_ (in that order for each node)
 
void bindTreeLate_ ()
 Recursively invoke TreeNode::onBindTreeEarly_ and Resource::onBindTreeLate_ (in that order for each node)
 
void simulationTerminating_ ()
 Hook to allow simulation resources to clean-up before simulation is ended.
 
void validatePostRun_ (const PostRunValidationInfo &info) const
 Hook to check the state of the simulator post-run and throw exceptions if something is incorrect.
 
void dumpDebugContent_ (std::ostream &out) const noexcept
 Allows resources to write out detailed textual debugging information about the node. This is typically called by a simulator when shutting down due to an exception (or depending on simulator config). However, it could also be called at other times.
 
void enterTeardown_ () noexcept
 Recursively enter TREE_TEARDOWN phase while alerting nodes through onEnteringTeardown_ and alterting Resources through Resource::onStartingTeardown_. Nodes already in TREE_TEARDOWN phase will not be alerted (neither will their associated Resources). All nodes are visited regardless of their parent's phase.
 
void verifyUniqueChildIdentifier_ (const std::string &ident, bool ignore_group_collision=false)
 Verifies that the given identifier is unique for all children of this node by comparing against names, groups, and aliases. Throws SpartaException if not unique.
 
void removeChildForTeardown_ (TreeNode *child)
 "Removes" the given child by invoking onDestroyingChild_ then removing this child from the children_ list
 
void removeFromParentForTeardown_ (TreeNode *parent)
 Protected Wrapper for getParent()->removeChildForTeardown_ which allows subclases of TreeNode to indirectly invoke removeChildForTeardown_ with themselves as the argument.
 
void detachFromParent_ ()
 Removes a node from its parent with the expectation this node will be immediately destroyed (i.e. is an xvalue)
 
void detachFromChildren_ ()
 Removes a node from its children with the expectation this node will be immediately destroyed (i.e. is an xvalue)
 
bool areParametersLocked_ () const
 This method informs whether the tree is past the lockdown phase for all LOCKED and HIDDEN parameters. Modifying LOCKED and HIDDEN parameters after this phase is disallowed. Tree can be locked down during TREE_BUILDING phase or TREE_CONFIGURING phase. During TREE_FINALIZING phase, all parameters are locked down as is.
 
template<typename DataT >
void postPropagatingNotification_ (const TreeNode *origin, const DataT &data, const std::string *name_id)
 Starts a notification propagating up the tree.
 
template<typename DataT , typename T , void(T::*)(const TreeNode &, const TreeNode &, const DataT &) TMethod>
DelegateVector::iterator findDelegate_ (DelegateVector &dvec, T *obj, const std::string &target_name)
 Finds a delegate associated with the given type T, object pointer, DataT, and TMethod within a DelevateVector. The intent of this function is to help see if a delegate is already registered with a calback by checking all known information associated with that callback against the input arguments.
 
template<typename DataT , typename T , void(T::*)(const DataT &) TMethod>
DelegateVector::iterator findDelegate_ (DelegateVector &dvec, T *obj, const std::string &target_name)
 
virtual void broadcastRegistrationForNotificationToChildren_ (const std::type_info &tinfo, const std::vector< const std::string * > &name_ids, TreeNode *obs_node, const delegate *del, const bool allow_private)
 Recursively notifies children that the notification described is now (or still is) being observed at the observation point TreeNode obs_node with the newly registered delegate del.
 
virtual void broadcastDeregistrationForNotificationToChildren_ (const std::type_info &tinfo, const std::vector< const std::string * > &name_ids, TreeNode *obs_node, const delegate *del, const bool allow_private)
 Recursively notifies children that the notification described has lost one particular observer (del) which was observing at the observation point TreeNode obs_node with the delegate del.
 
void broadcastRegistrationForNotificationListStringToChildren_ (const std::type_info &tinfo, const std::string &name, TreeNode *obs_node, const delegate *del, const bool private_only)
 Entry point to broadcastRegistrationForNotificationToChildren_ recursion. Breaks a name string.
 
void broadcastDeregistrationForNotificationListStringToChildren_ (const std::type_info &tinfo, const std::string &name, TreeNode *obs_node, const delegate *del, const bool private_only)
 Symmetric oppostie of broadcastRegistrationForNotificationListStringToChildren_.
 
template<typename DataT >
void invokeDelegatesOn_ (TreeNode *to_invoke, const DataT &data, const std::string *name_id)
 Protected wrapper for invokeDelegates_ which allows a TreeNode to invoke delegates on another TreeNode using itself as the origin.
 
- Protected Member Functions inherited from sparta::ResourceContainer
std::string getResourceTypeName_ () const
 Gets the rtti type name (demangled) of the resource type held by this container. If there is no resource held, returns empty string.
 
void setResource_ (Resource *r)
 Allows subclasses to assign the resource associated with this node.
 
void unsetResource_ ()
 Allows a resource to unset the resource set with setResource_.
 
void lockResource_ ()
 Allows subclasses to assign the resource associated with this node.
 
ResourcegetResource_ () noexcept
 Returns the currently held resource of this node (if any). This method can be called at any time.
 
const ResourcegetResource_ () const noexcept
 Const variant of getResource_.
 
- Protected Member Functions inherited from sparta::PhasedObject
void setPhase_ (TreePhase phase)
 Sets the current phase.
 

Additional Inherited Members

- Static Public Member Functions inherited from sparta::TreeNode
static std::string createSearchRegexPattern (const std::string &pat)
 Compute a regex pattern for a node child path containing any number of wildcard characters (not a dot-separated location) which can be used to test against child node names.
 
static bool hasWildcardCharacters (const std::string &name)
 Determines if a given node name has any wildcard characters which will be substituted in createSearchRegexPattern.
 
static std::string getNextName (const std::string &name, size_t &pos)
 Gets the next name between two '.' chars in a string starting at pos.
 
static bool matchesGlobLike (const std::string &pattern, const std::string &other)
 Determine if a glob-like search pattern matches some other string.
 
static const std::map< const TreeNode *, WeakPtr > & getParentlessNodes ()
 
static const std::map< const TreeNode *, WeakPtr > & getAllNodes ()
 Gets the vector of all TreeNodes currently known to be constructed.
 
static std::string formatAllNodes ()
 Prints the list of all TreeNodes currently known to be constructed.
 
static bool isNodeConstructed (const TreeNode *)
 Is a given node constructed?
 
static TreeNodegetVirtualGlobalNode ()
 Gets the virtual global node singleton. This node can have no parent and no children. It receives notifications from all nodes in the simulator as if it were the parent of every node in the simulation that has no parent.
 
static std::vector< const std::string * > parseNotificationNameString (const std::string &csl)
 Parses a comma-separated list of notification names (or patterns) separated by commas and ignoring whitespace around commas.
 
static bool notificationCategoryMatch (const std::string *query_id, const std::string *node_id)
 Checks if two notification categories match where one is an actual category.
 
- Static Public Attributes inherited from sparta::ParameterBase
static constexpr char PARAMETER_NODE_TAG [] = "SPARTA_Parameter"
 Tag added to Parameter nodes.
 
- Static Public Attributes inherited from sparta::TreeNode
static const group_idx_type GROUP_IDX_NONE = (group_idx_type)-1
 GroupIndex indicating that a node has no group index because it belongs to no group.
 
static const node_uid_type MAX_NODE_UID
 Maximum value of node_uid_ before the framework throws an exception.
 
static constexpr char GROUP_NAME_NONE [] = ""
 Group name indicating that a node belongs to no group.
 
static constexpr char NODE_NAME_NONE [] = ""
 Node name for anonymous node.
 
static const std::string DEBUG_DUMP_SECTION_DIVIDER
 String dividing sections in a debug dump file.
 
static constexpr char NODE_NAME_VIRTUAL_GLOBAL [] = "_SPARTA_virtual_global_"
 Node name for the virtual glopbal node.
 
static constexpr char LOCATION_NODE_SEPARATOR_ATTACHED = '.'
 Separator character between node identifiers in a location string when the child is attached to the parent.
 
static constexpr char LOCATION_NODE_SEPARATOR_EXPECTING = ','
 Separator character between node identifiers in a location string when the child is being attached to the parent but has not been entirely attached (i.g. during construction of the child node)
 
static constexpr char LOCATION_NODE_SEPARATOR_UNATTACHED = '~'
 Separator character preceding a node identifiers in a location string when that node has no parent and is not in the process of being attached to one.
 
static const uint32_t RENDER_SUBTREE_INDENT = 2
 Spaces to indent for each tree level in sparta::TreeNode::renderSubtree.
 
static constexpr char GROUP_NAME_BUILTIN [] = "_SPARTA_builtin_group_"
 Reserved name for built-in nodes.
 
static const uint64_t CHILD_FIND_THRESHOLD = 100000
 Threshold for number of findChildren calls after finalization before a warning message is printed about framework misuse.
 
static const uint64_t CHILD_GET_THRESHOLD = 100000
 Threshold for number of getChild calls after finalization before a warning message is printed about framework misuse.
 
static const uint32_t TEARDOWN_ERROR_LIMIT = 5
 Number of teardown-phase-related messages that can be printed before the rest will be suppressed.
 
static const std::vector< std::pair< const char *, std::function< void(std::string &)> > > TREE_NODE_PATTERN_SUBS
 List of pattern susbtitutions when creating a search pattern from a TreeNode name containing wildcards.
 
- Protected Types inherited from sparta::TreeNode
typedef std::vector< delegateDelegateVector
 Vector of delegates representing a list of observers to notify.
 
typedef std::map< type_info_container, DelegateVectorNotificationObserverMap
 Map of delegate vectors containing all observers.
 
- Static Protected Member Functions inherited from sparta::ParameterBase
static void logCurrentBackTrace_ ()
 Log the current backtrace to the global parameters logger.
 
- Static Protected Member Functions inherited from sparta::TreeNode
static bool identityMatchesPattern_ (const std::string &ident, std::regex &expr, std::vector< std::string > &replacements)
 Performs pattern matching on a identity string.
 
static bool identityMatchesPattern_ (const std::string &ident, std::regex &expr)
 Variant of identityMatchesPattern_ with no replacements vector.
 
static std::string getPreviousName_ (const std::string &name, size_t &pos)
 Gets the previous name between two '.' chars in a string starting at pos.
 
- Protected Attributes inherited from sparta::ParameterBase
sparta::SpartaHandler modifier_callback_
 Modifier callback called when the parameter is written.
 
bool ignored_
 Has this parameter been ignored. Resettable. Mutable so that it can be accessed from a const Parmeter.
 
std::string string_quote_
 The quote sequence for printing strings. Defaults to empty string.
 

Detailed Description

template<typename ValueType>
class sparta::Parameter< ValueType >

Parameter instance, templated to contain only a specific type.

Template Parameters
ValueTypetype of data held by this parameter Supported types include are all bound types of sparta::KeyValue::GBL_type_name_map contained within any number of std::vector levels

Definition at line 1113 of file Parameter.hpp.

Member Typedef Documentation

◆ type

template<typename ValueType >
using sparta::Parameter< ValueType >::type = ValueType

Type held by this parameter. This cannot change at run-time.

Definition at line 1140 of file Parameter.hpp.

◆ value_type

template<typename ValueType >
using sparta::Parameter< ValueType >::value_type = ValueType

Definition at line 1141 of file Parameter.hpp.

Member Enumeration Documentation

◆ ParameterAttribute

template<typename ValueType >
enum class sparta::Parameter::ParameterAttribute : std::uint8_t
strong

ParameterAttribute enum class which describes special attributes of this parameter.

Definition at line 1121 of file Parameter.hpp.

Constructor & Destructor Documentation

◆ Parameter() [1/3]

template<typename ValueType >
sparta::Parameter< ValueType >::Parameter ( const std::string &  name,
const ValueType &  def,
const std::string &  doc,
bool  isvolatile = false 
)
inline

Construct a parameter.

Note
Within a ParameterSet subclass body, it's usually preferable to use PARAMETER* macros instead of constructing these manually.
Parameters
[in]nameParam/Node name
[in]defDefault value
[in]docDocstring
[in]isvolatileIs this parameter volatile (are writes after read allowed)? A param can never be written after finalization, but some may be automatically calculated and changed multiple times based on other values and their own.

Definition at line 1155 of file Parameter.hpp.

Here is the call graph for this function:

◆ Parameter() [2/3]

template<typename ValueType >
sparta::Parameter< ValueType >::Parameter ( const std::string &  name,
const ValueType &  def,
const std::string &  doc,
ParameterSet ps,
bool  isvolatile = false 
)
inline

Constructor used by the PARAMETER macro.

Note
This constructor delegates to the previous one defined above, and adds to the right ParameterSet object.

Definition at line 1178 of file Parameter.hpp.

Here is the call graph for this function:

◆ Parameter() [3/3]

template<typename ValueType >
sparta::Parameter< ValueType >::Parameter ( const std::string &  name,
const ValueType &  def,
const std::string &  doc,
const ParameterAttribute attr,
ParameterSet ps,
bool  isvolatile = false 
)
inline

Definition at line 1189 of file Parameter.hpp.

Member Function Documentation

◆ addDependentValidationCallback() [1/2]

template<typename ValueType >
void sparta::Parameter< ValueType >::addDependentValidationCallback ( bool(*)(ValueType &, const sparta::TreeNode *)  method,
const std::string &  name 
)
inline

Adds dependency callback via a global function or lambda.

Refer to other overload of addDependentValidationCallback for further explanation

Usage:

bool global_function(bool&, const sparta::TreeNode*) { return true; }
// ...
MyClass my_class;
// ...
// Given some Parameter<bool> parameter_global_check;
// Given some Parameter<bool> parameter_lambda_check;
// ...
parameter_global_check->addDependentValidationCallback(&global_function, "constraint1")
parameter_lambda_check->addDependentValidationCallback([](std::vector<bool>& val, const sparta::TreeNode*){return val == true;},
"constraint2")
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205

Definition at line 1254 of file Parameter.hpp.

◆ addDependentValidationCallback() [2/2]

template<typename ValueType >
template<class T , bool(T::*)(ValueType &, const sparta::TreeNode *) TMethod>
void sparta::Parameter< ValueType >::addDependentValidationCallback ( T *  obj,
const std::string &  name 
)
inline

Adds dependency callback to a class member function.

Usage:

class MyClass {
public:
bool Method(bool&, const sparta::TreeNode*) { return true; }
};
// ...
MyClass my_class;
// ...
// Given some Parameter<bool> parameter;
// ...
parameter->addDependentValidationCallback<MyClass, &MyClass::Method>(my_class, "constraint1");

Definition at line 1226 of file Parameter.hpp.

◆ begin()

template<typename ValueType >
virtual ParameterBase::const_iterator sparta::Parameter< ValueType >::begin ( ) const
inlinefinaloverridevirtual

Get begin iterator.

Note
Increments read count

Implements sparta::ParameterBase.

Definition at line 1454 of file Parameter.hpp.

◆ clearVectorValue()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::clearVectorValue ( )
inlinefinaloverridevirtual

If the parameter is a vector type, clears the value so that it becomes an empty vector (regardless of dimensionality)

Note
Has no effect if parameter is a non-vector type

Implements sparta::ParameterBase.

Definition at line 1685 of file Parameter.hpp.

◆ end()

template<typename ValueType >
virtual ParameterBase::const_iterator sparta::Parameter< ValueType >::end ( ) const
inlinefinaloverridevirtual

Get begin iterator.

Note
Increments read count

Implements sparta::ParameterBase.

Definition at line 1462 of file Parameter.hpp.

Here is the call graph for this function:

◆ equals()

template<typename ValueType >
virtual bool sparta::Parameter< ValueType >::equals ( const ParameterBase other)
inlinefinaloverridevirtual

Returns true if the value of this equals other.

Parameters
otherThe parameter to compere with

Implements sparta::ParameterBase.

Definition at line 1673 of file Parameter.hpp.

◆ getDefault()

template<typename ValueType >
ValueType sparta::Parameter< ValueType >::getDefault ( ) const
inline

Returns the default value.

Definition at line 1271 of file Parameter.hpp.

◆ getDefaultAsString()

template<typename ValueType >
virtual std::string sparta::Parameter< ValueType >::getDefaultAsString ( ) const
inlinefinaloverridevirtual

Returns the default value as a string, even if type is a vector.

Refer to 'sparta::stringize' for vector-to-string formatting.

Implements sparta::ParameterBase.

Definition at line 1281 of file Parameter.hpp.

◆ getDimensionality()

template<typename ValueType >
virtual uint32_t sparta::Parameter< ValueType >::getDimensionality ( ) const
inlinefinaloverridevirtual

Determines the number of dimensions of this Parameter. A scalar has 0 dimensions. A parameter of type vector<uint32_t> would have a dimensionality of 1. vector<vector<uint32_t>> would have a dimensionality of 2.

Note
Does not increment read count

Implements sparta::ParameterBase.

Definition at line 1446 of file Parameter.hpp.

◆ getDoubleValue()

template<typename ValueType >
double sparta::Parameter< ValueType >::getDoubleValue ( ) const
inlinefinaloverridevirtual

Cast value to double if possible. Throw if not.

Implements sparta::ParameterBase.

Definition at line 1422 of file Parameter.hpp.

◆ getDoubleValue_() [1/2]

template<typename ValueType >
template<typename T >
std::enable_if< std::is_arithmetic< T >::value, double >::type sparta::Parameter< ValueType >::getDoubleValue_ ( ) const
inlineprotected

Definition at line 1806 of file Parameter.hpp.

◆ getDoubleValue_() [2/2]

template<typename ValueType >
template<typename T >
std::enable_if<!std::is_arithmetic< T >::value, double >::type sparta::Parameter< ValueType >::getDoubleValue_ ( ) const
inlineprotected

Definition at line 1812 of file Parameter.hpp.

◆ getItemValueFromString()

template<typename ValueType >
std::string sparta::Parameter< ValueType >::getItemValueFromString ( const std::vector< uint32_t > &  indices,
bool  peek = false 
) const
inlinefinaloverridevirtual

Override from ParameterBase.

Warning
peek is highly discouraged outside of framework use since it undermines SPARTA's protection for parameter write-after-reads

Implements sparta::ParameterBase.

Definition at line 1316 of file Parameter.hpp.

◆ getNumericDisplayBase()

template<typename ValueType >
sparta::utils::DisplayBase sparta::Parameter< ValueType >::getNumericDisplayBase ( ) const
inline

Gets the numeric base for displaying the value of this parameter.

Definition at line 1704 of file Parameter.hpp.

◆ getNumValues()

template<typename ValueType >
virtual size_t sparta::Parameter< ValueType >::getNumValues ( bool  peek = false) const
inlinefinaloverridevirtual

Gets the number of values in this Parameter.

Returns
Number of values in this parameter if a vector. If not a vector, returns 1.
Postcondition
Increments reference count if this parameter is a vector type (see isVector). Otherwise, has no effect.

Implements sparta::ParameterBase.

Definition at line 1433 of file Parameter.hpp.

◆ getTypeName()

template<typename ValueType >
virtual const std::string sparta::Parameter< ValueType >::getTypeName ( ) const
inlinefinaloverridevirtual

Gets the human-readable name of this parameter's type.

See also
sparta::ParameterBase::getTypeName

Implements sparta::ParameterBase.

Definition at line 1265 of file Parameter.hpp.

◆ getValue()

template<typename ValueType >
const ValueType & sparta::Parameter< ValueType >::getValue ( ) const
inline

Gets the current value of this Parameter.

Returns
current value of parameter.
Postcondition
Increments reference count

Definition at line 1398 of file Parameter.hpp.

Here is the call graph for this function:

◆ getValue_()

template<typename ValueType >
const ValueType & sparta::Parameter< ValueType >::getValue_ ( ) const
inlineprotected

Iternal getValue_ wrapper which does not increment the read counter.

Definition at line 1800 of file Parameter.hpp.

◆ getValueAsString()

template<typename ValueType >
std::string sparta::Parameter< ValueType >::getValueAsString ( ) const
inlinefinaloverridevirtual

Returns value as a string, even if type is a vector.

Returns
string representation of current value
Note
does not increment read counter

Refer to 'sparta::stringize' for vector-to-string formatting.

Implements sparta::ParameterBase.

Definition at line 1292 of file Parameter.hpp.

◆ getValueAsStringAt()

template<typename ValueType >
std::string sparta::Parameter< ValueType >::getValueAsStringAt ( size_t  idx,
bool  peek = false 
) const
inlinefinaloverridevirtual

Treats this parameter as a vector and gets the value as a string at a specific index. If parameter is not a vector, it is treated as a 1-element vector.

Exceptions
SpartaExceptionif idx is out of bounds
Warning
peek is highly discouraged outside of framework use since it undermines SPARTA's protection for parameter write-after-reads

Implements sparta::ParameterBase.

Definition at line 1307 of file Parameter.hpp.

◆ getVectorSizeAt()

template<typename ValueType >
uint32_t sparta::Parameter< ValueType >::getVectorSizeAt ( const std::vector< uint32_t > &  indices,
bool  peek = false 
) const
inlinefinaloverridevirtual

Get the size of a nested vector within the parameter located by indices.

Warning
peek is highly discouraged outside of framework use since it undermines SPARTA's protection for parameter write-after-reads

Implements sparta::ParameterBase.

Definition at line 1333 of file Parameter.hpp.

◆ ignore()

template<typename ValueType >
void sparta::Parameter< ValueType >::ignore ( ) const
inline

Marks this parameter as ignored.

Note
This method is intentionally omitted from ParameterBase so that only components consuming parameters can choose to ignore.
Warning
Read counts must may be reset by sparta infrastructure so this method may have no effect if called within a ParameterSet constructor. The point of this behavior is to prevent early reads of the parameter value from appearing as if the Resource that owns this parameter read it.
See also
unread

When instantiating a Resource, every parameter must be either read (e.g. through getValue, operator ValueType, operator==), or ignored with this method.

Definition at line 1375 of file Parameter.hpp.

Here is the call graph for this function:

◆ isDefaultOverridden()

template<typename ValueType >
virtual bool sparta::Parameter< ValueType >::isDefaultOverridden ( ) const
inlinefinaloverridevirtual

Has the default value (NOT the current value) for parameter been overridden in any way (including partially changed).

Warning
This does not provide information about the current value held by the parameter, only the default value.

In SPARTA, parameter defaults are supplied at construction-time through constants or constructors, but these defaults can also be changed during initialization in order to support custom architectural configuration baselines. An overridden default value does not necessarily imply a change in the current value held by this parameter. To see if the current value (getValueAsString or Parameter<t>::getValue) has changed, use isDefault (i.e. is this parameter's value equal to the default?)

Implements sparta::ParameterBase.

Definition at line 1616 of file Parameter.hpp.

◆ isVector()

template<typename ValueType >
virtual bool sparta::Parameter< ValueType >::isVector ( ) const
inlinefinaloverridevirtual

Is this parameter a vector?

Note
THis is an invariant and does not increment the read count

Implements sparta::ParameterBase.

Definition at line 1441 of file Parameter.hpp.

◆ isVisibilityAllowed()

template<typename ValueType >
virtual bool sparta::Parameter< ValueType >::isVisibilityAllowed ( ) const
inlineoverridevirtual

Query if this parameter is safe to be displayed via prints, dumps. A parameter should not be displayed if it is HIDDEN and the subtree containing this parameter is already locked.

Implements sparta::ParameterBase.

Definition at line 1763 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator const ValueType &()

template<typename ValueType >
sparta::Parameter< ValueType >::operator const ValueType & ( ) const
inline

Gets a the value currently held by this Parameter.

Returns
Value currenty held by this Parameter

Definition at line 1348 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator!=() [1/2]

template<typename ValueType >
template<class T >
bool sparta::Parameter< ValueType >::operator!= ( const Parameter< T > &  rhp) const
inline

Compares two Parameter objects by value.

Postcondition
Increments read count

Definition at line 1480 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator!=() [2/2]

template<typename ValueType >
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type sparta::Parameter< ValueType >::operator!= ( const T  rhp) const
inline

Increments read count.

Definition at line 1527 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator()()

template<typename ValueType >
const ValueType & sparta::Parameter< ValueType >::operator() ( ) const
inline

Gets the value currently held by this Parameter.

Returns
Value currently held by this Parameter

Definition at line 1356 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator<() [1/2]

template<typename ValueType >
bool sparta::Parameter< ValueType >::operator< ( const Parameter< type > &  rhp) const
inline

Compares two Parameter objects by value.

Postcondition
Increments read count

Definition at line 1505 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator<() [2/2]

template<typename ValueType >
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type sparta::Parameter< ValueType >::operator< ( const T  rhp) const
inline

Increments read count.

Definition at line 1547 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator<<()

template<typename ValueType >
template<class U >
Parameter< ValueType > & sparta::Parameter< ValueType >::operator<< ( e)
inline

Helper for constructing vectors.

Note
Does not impact getWriteCount.
Warning
This should be used for initializing parameters only. This method is currently public so that distant subclasses can access it.
Postcondition
Write count is incremented and read count reset

Allows:

param << 1 << 2 << 3;

Definition at line 1728 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator<=() [1/2]

template<typename ValueType >
bool sparta::Parameter< ValueType >::operator<= ( const Parameter< type > &  rhp) const
inline

Compares two Parameter objects by value.

Postcondition
Increments read count

Definition at line 1513 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator<=() [2/2]

template<typename ValueType >
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type sparta::Parameter< ValueType >::operator<= ( const T  rhp) const
inline

Increments read count.

Definition at line 1554 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename ValueType >
void sparta::Parameter< ValueType >::operator= ( const Parameter< ValueType > &  p)
delete

Copy assignment - deleted explicitly.

Note
This explicit delete of the copy assignment operator is to work around cases where we have one parameter A getting its value at run time from another parameter B, using the simple syntax A = B. The issue with this is that it's rather ambiguous whether this syntax attempts to copy a parameter value into A from B, or copy the entire Parameter object. Hence, explicitly deleted. Use getValue() calls for value copy.

◆ operator=() [2/2]

template<typename ValueType >
void sparta::Parameter< ValueType >::operator= ( const ValueType &  v)
inline

Assigns the specified value to this parameter.

Todo:
Perform independent parameter validation and throw exception if failed.
Postcondition
Write count is incremented and read count reset
Note
If the user is initializing the parameters using a final config, then parameters assignments are not allocated. The user must use the override* methods. This does not apply to parameters whose visibility is hidden

Definition at line 1585 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator==() [1/2]

template<typename ValueType >
template<class T >
bool sparta::Parameter< ValueType >::operator== ( const Parameter< T > &  rhp) const
inline

Compares two Parameter objects by value.

Postcondition
Increments read count

Definition at line 1471 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator==() [2/2]

template<typename ValueType >
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type sparta::Parameter< ValueType >::operator== ( const T  rhp) const
inline

Increments read count.

Definition at line 1520 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator>() [1/2]

template<typename ValueType >
bool sparta::Parameter< ValueType >::operator> ( const Parameter< type > &  rhp) const
inline

Compares two Parameter objects by value.

Postcondition
Increments read count

Definition at line 1488 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator>() [2/2]

template<typename ValueType >
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type sparta::Parameter< ValueType >::operator> ( const T  rhp) const
inline

Increments read count.

Definition at line 1534 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator>=() [1/2]

template<typename ValueType >
template<class T >
bool sparta::Parameter< ValueType >::operator>= ( const Parameter< T > &  rhp) const
inline

Compares two Parameter objects by value.

Postcondition
Increments read count

Definition at line 1497 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator>=() [2/2]

template<typename ValueType >
template<class T >
std::enable_if<!std::is_base_of< ParameterBase, T >::value, bool >::type sparta::Parameter< ValueType >::operator>= ( const T  rhp) const
inline

Increments read count.

Definition at line 1541 of file Parameter.hpp.

Here is the call graph for this function:

◆ operator_insert_()

template<typename ValueType >
template<class U , class C1 >
std::enable_if< is_vector< C1 >::value, Parameter< ValueType > & >::type sparta::Parameter< ValueType >::operator_insert_ ( e)
inlineprotected

Definition at line 1772 of file Parameter.hpp.

◆ overrideDefaultClearVectorValue()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::overrideDefaultClearVectorValue ( )
inlinefinaloverridevirtual

If the parameter is a vector type, clears the default value so that it becomes an empty vector (regardless of dimensionality)

Note
Has no effect if parameter is a non-vector type

Implements sparta::ParameterBase.

Definition at line 1657 of file Parameter.hpp.

◆ overrideDefaultFromString()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::overrideDefaultFromString ( const std::string &  val)
inlinefinaloverridevirtual

Sets the default value of this non-vector parameter for architecture baseline configuration purposes.

Parameters
[in]valValue to write to default
Precondition
This parameter is allowed to have been written but must not have been read yet. This parameter must not be a vector
Note
Does not attempt to resture current value from default.
Does not increment write count
Warning
Do not assign new defaults to Parameters without understanding how architecture configurations interact with defaults

Implements sparta::ParameterBase.

Definition at line 1620 of file Parameter.hpp.

Here is the call graph for this function:

◆ overrideDefaultFromStringVector()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::overrideDefaultFromStringVector ( const std::vector< std::string > &  val)
inlinefinaloverridevirtual

Sets the default value of this vector parameter for architecture baseline configuration purposes.

Parameters
[in]valValue to write to default
Precondition
This parameter is allowed to have been written but must not have been read yet. This parameter must not be a vector
Note
Does not attempt to resture current value from default.
Does not increment write count
Warning
Do not assign new defaults to Parameters without understanding how architecture configurations interact with defaults

Implements sparta::ParameterBase.

Definition at line 1628 of file Parameter.hpp.

Here is the call graph for this function:

◆ overrideDefaultItemValueFromString()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::overrideDefaultItemValueFromString ( const std::vector< uint32_t > &  indices,
const std::string &  str 
)
inlinefinaloverridevirtual

Partially override the default default value in some element at an n-dimensional array specified.

Precondition
This parameter is allowed to have been written but must not have been read yet. This parameter must not be a vector
Note
Does not attempt to resture current value from default.

Implements sparta::ParameterBase.

Definition at line 1636 of file Parameter.hpp.

◆ overrideDefaultResizeVectorsFromString()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::overrideDefaultResizeVectorsFromString ( const std::vector< uint32_t > &  indices)
inlinefinaloverridevirtual

Override the default value by clearing the possibly-nested vector (if this parameter is a vector). The nested vector contens can then be set by overrideDefaultItemValueFromString.

Implements sparta::ParameterBase.

Definition at line 1649 of file Parameter.hpp.

◆ peekValue()

template<typename ValueType >
const ValueType & sparta::Parameter< ValueType >::peekValue ( ) const
inline

Gets the current value of this Parameter without incrementing the read count. This should be used when validating parameters in a Resource Constructor.

Returns
current value of parameter.
Warning
peek is highly discouraged outside of framework use since it undermines SPARTA's protection for parameter write-after-reads. If using this command for a model without a thorough understanding tree construction phases and parameter application, you may experience unexpected values for your parameters or read parameters that differ from the final assigned parameter.

Definition at line 1415 of file Parameter.hpp.

Here is the call graph for this function:

◆ resizeVectorsFromString()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::resizeVectorsFromString ( const std::vector< uint32_t > &  indices)
inlinefinaloverridevirtual

Attempt to resize a vector nested within this parameter to contain the vector indicated by indices.

Parameters
indicesSet of indices referring to nested vectors that must be accessible (at a minimum) by future reads. Nested vetors containing non-vector types will not be resized by this method. See resizeVectorsFromString_ for implementation details

Implements sparta::ParameterBase.

Definition at line 1677 of file Parameter.hpp.

◆ restoreValueFromDefaultImpl_()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::restoreValueFromDefaultImpl_ ( )
inlinefinaloverridevirtual

Implements restoreValueFromDefault.

Implements sparta::ParameterBase.

Definition at line 1662 of file Parameter.hpp.

Here is the call graph for this function:

◆ setItemValueFromStringImpl_()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::setItemValueFromStringImpl_ ( const std::vector< uint32_t > &  indices,
const std::string &  str 
)
inlinefinaloverrideprotectedvirtual

Implements setItemValueFromStringImpl_.

Implements sparta::ParameterBase.

Definition at line 1787 of file Parameter.hpp.

◆ setNumericDisplayBase()

template<typename ValueType >
sparta::utils::DisplayBase sparta::Parameter< ValueType >::setNumericDisplayBase ( sparta::utils::DisplayBase  base)
inline

Set the numeric base for displaying the value of this parameter.

Definition at line 1693 of file Parameter.hpp.

◆ setValueFromStringImpl_()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::setValueFromStringImpl_ ( const std::string &  s,
bool  poke = false 
)
inlinefinaloverrideprotectedvirtual

Implements setValueFromString.

Implements sparta::ParameterBase.

Definition at line 1779 of file Parameter.hpp.

◆ setValueFromStringVectorImpl_()

template<typename ValueType >
virtual void sparta::Parameter< ValueType >::setValueFromStringVectorImpl_ ( const std::vector< std::string > &  str,
bool  poke = false 
)
inlinefinaloverrideprotectedvirtual

Implements setValueFromStringVectorImpl_.

Implements sparta::ParameterBase.

Definition at line 1783 of file Parameter.hpp.

◆ unread()

template<typename ValueType >
void sparta::Parameter< ValueType >::unread ( ) const
inline

Mark this parameter as unread and unignored.

Note
This method is intentionally omitted from ParameterBase so that only components consuming parameters can choose to ignore.
See also
ignore

This is useful within a resource constructor which first validates parameters and then uses them. The validation would be considered a read (unless peekValue) were used. Also clears ignored_flag

Definition at line 1389 of file Parameter.hpp.

Here is the call graph for this function:

◆ validateDependencies()

template<typename ValueType >
bool sparta::Parameter< ValueType >::validateDependencies ( const TreeNode node,
std::string &  err_names 
) const
inlineoverridevirtual

Invokes all validation callbacks for a particular node in the device tree and returns true if none of them fail.

Parameters
nodeTreeNode in device tree associated with the object for which these parameters are being validated.
err_namesstring which will be appended with the names of any ValidationCheckCallbacks that failed in a comma-delimited list.

Implements sparta::ParameterBase.

Definition at line 1728 of file Parameter.hpp.

◆ validateIndependently()

template<typename ValueType >
bool sparta::Parameter< ValueType >::validateIndependently ( std::string &  err_names) const
inlineoverridevirtual

Performs validation independently of all other Parameters.

Parameters
err_namesString which will be appended with names of any failed validators.
Returns
false if any independent validators fail; true otherwise.
Postcondition
Appends to err_names a comma delimited list of any validators that failed.

Implements sparta::ParameterBase.

Definition at line 1708 of file Parameter.hpp.


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