|
| | ParameterTree () |
| | Default Constructor.
|
| |
| | ParameterTree (const ParameterTree &rhp) |
| |
| ParameterTree & | operator= (const ParameterTree &rhp) |
| |
| virtual | ~ParameterTree () |
| | Destructor.
|
| |
| void | clear () |
| | Clear all content from this tree.
|
| |
| bool | set (const std::string &path, const std::string &value, bool required, const std::string &origin="") |
| | Add a parameter to the tree, replacing any existing parameter.
|
| |
| Node * | create (const std::string &path, bool required=false) |
| | Add a node to the tree, with proper priority.
|
| |
| const Node & | get (const std::string &path) const |
| | Gets a node from the parameter tree while respecting parameter application order. In other words, getting through this method returns the latest value set for the parameter at the location described by path.
|
| |
| const Node & | operator[] (const std::string &name) const |
| | Gets a node form the parameter tree.
|
| |
| bool | hasValue (const std::string &path, const bool must_be_leaf=true) const |
| | Try to check if a node has value.
|
| |
| bool | exists (const std::string &path, const bool must_be_leaf=true) const |
| | Try to check if a node exists.
|
| |
| uint32_t | getUnreadValueNodes (std::vector< const Node * > *nodes) const |
| | Counts the number of values attached to the parameter tree which have values but have not been read. This is a smart system which looks at historical parameter values as well as the latest to be sure that all have been touched.
|
| |
| uint32_t | getUnreadValueNodes (std::vector< Node * > *nodes) |
| | Counts the number of values attached to the parameter tree which have values but have not been read. This is a smart system which looks at historical parameter values as well as the latest to be sure that all have been touched. non-const version.
|
| |
| const Node * | tryGet (const std::string &path, const bool must_be_leaf=true) const |
| | Try to get a node if it exists. Returns nullptr it it does not.
|
| |
| Node * | tryGet (const std::string &path, const bool must_be_leaf=true) |
| | tryGet non-const version
|
| |
| bool | isRequired (const std::string &path) const |
| | Recursively find first leaf node matching this pattern and decide if any node matching that node's pattern is required to exist in the SPARTA tree.
|
| |
| bool | unrequire (const std::string &path) |
| | Unrequire a node in the tree.
|
| |
| bool | isRead (const std::string &path) const |
| | Has a node with a given path been read.
|
| |
| Node const * | getRoot () const |
| |
| Node * | getRoot () |
| |
| void | merge (const ParameterTree &rhp) |
| | Merge this tree with another by applying all of its parameters to this tree. Parameters in the right tree will override this tree's parameters if there are duplicate paths or overlapping patterns.
|
| |
| void | visitLeaves (std::function< void(const Node *)> callback) const |
| | Apply the given callback to all leaf nodes.
|
| |
| void | recursePrint (std::ostream &o, bool print_user_data=true) const |
| | Recursively print.
|
| |
| std::map< const Node *, std::map< std::string, const TreeNode::ExtensionsBase * > > | getAllNodeExtensions () const |
| | Get a mapping from Nodes to their extensions.
|
| |
Virtual Parameter Tree. This represents a tree of parameters read from some source but does not necessarily correspond to the parameters in the simulation itself or even to the simulation tree. This is meant to provide a hierarchical view into simulation parameters before they are actually applied to a real TreeNode tree.
Eventually, this structure will automatically share data with sparta::ParameterSet instances as they are created. For now, it is limited.
Typical use is to subclass this object for each simulator component/model which has a set of parameters it must consume. sparta::ParameterSet provides a generic interface through which config-file parsers or command-line parsers can populate the parameters from strings. Models that expose the ParameterSet full of sparta::Parameter instances should dynamic_cast a sparta::ParameterSet supplied to them at runtime back to a known type and operate through Parameters directly instead of through this generic interface.
Definition at line 42 of file ParameterTree.hpp.
| Node * sparta::ParameterTree::create |
( |
const std::string & | path, |
|
|
bool | required = false ) |
|
inline |
Add a node to the tree, with proper priority.
- Parameters
-
| path | Path to create. TEMPORARY: Must not contain parent references (i.e. extra dots) |
| Are | the nodes added by this call required to exist? |
- Returns
- TEMPORARY: Returns a Node if one is created or found, nullptr if not. May return nullptr if parameter path contains parent reference (any '.' character whicih is proceded by another '.' or the beginnign of the string). This will be fixed eventually. Nothing else should cause this to return nullptr
Setting is fundamentally different than getting in a virtual parameter tree. It cannot fail and (when setting with patterns [paths containing wildcards]), new nodes are almost always created.
Definition at line 1150 of file ParameterTree.hpp.
| bool sparta::ParameterTree::set |
( |
const std::string & | path, |
|
|
const std::string & | value, |
|
|
bool | required, |
|
|
const std::string & | origin = "" ) |
|
inline |
Add a parameter to the tree, replacing any existing parameter.
- Parameters
-
| path | Path (from root) to assign value |
| value | Value to assign to a path in this tree |
| required | Must this parameter exist? |
| origin | Origin of the value (e.g. "foo.yaml line:50 col:23") |
- Returns
- TEMPORARY: Returns true of parameter is set, false if not. May return false if parameter path contains parent reference (any '.' character whicih is proceded by another '.' or the beginnign of the string). This will be fixed eventually.
Setting is fundamentally different than getting in a virtual parameter tree. It cannot fail and (when setting with patterns [paths containing wildcards]), new nodes are almost always created.
Definition at line 1126 of file ParameterTree.hpp.