#include <parametermap.h>
Inheritance diagram for ParameterMap< ParamT >:
This class provides a standard interface for defining parameters and setting/viewing their values via interactive displays, command-line arguments, and command prompts.
The methods were originally designed for the C implementation, and thus have such ugliness as FILE* parameters and explicit loops for searching and printing. There's no urgent need to clean it up further, though, until expression parsing (the ExpressionParser class) is also replaced with something cleaner.
Definition at line 40 of file parametermap.h.
Public Types | |
typedef ParamT | ParamType |
typedef ParameterMap< ParamT > | self |
typedef ParamType | value_type |
Public Methods | |
ParameterMap (self *parent_i=0, const string name_="") | |
Constructor. | |
virtual self * | new_child (const string name_="", const bool owned=false) |
Returns a new child map (presumably linked to this map) of the same specific type as self; should be implemented by all derived classes. | |
void | init_hook (void) |
Old comment said that all source-code-level params and commands must have been defined by this point, but it's not clear why that would still have to be so, except to make sure everything gets sorted. | |
int | define_param (const ParamType ¶m) |
Add a parameter to the user interface structure. | |
void | add_constants () |
void | update_all_default_values (const StringParser &sp) |
Generate the default value for all unset params having an expression for it. | |
virtual const ParamType & | lookup (const string &name, bool warn=true) const |
virtual ParamType & | lookup (const string &name, bool warn=true) |
Returns the specified parameter structure. | |
virtual ParamType & | local_copy (ParamType ¶m, bool notify=true, bool copysetfn=true) |
template<class T> self & | set_local (const string &name, const T &value) |
virtual ParamMap & | get_child (const string &name_="") |
virtual const ParamMap & | get_child (const string &name_="") const |
Const version uses same implementation, but results in a const object. | |
const self & | root () const |
Returns the highest-level parent map. | |
self & | root () |
self & | lookup_map (const string &mapname, bool warn=true) |
Searches self and children for the specified map, returning it if found. | |
self & | lookup_map (const PathSpecification::NameList &names, bool warn, bool isrooted) |
Searches self and children for the specified map, returning it if found. | |
const self & | lookup_map (const PathSpecification::NameList &names, bool warn, bool isrooted) const |
int | set_matching (const StringParser &sp, const string &pathspec, const string &valuestr, const bool mark=true, const bool verbose=true, const bool local_only=false, const bool copysetfn=true) |
ParamType & | lookup_with_path (const string &pathspec, bool warn=true) |
Convenience macro: look up a parameter given a full path specification. | |
const ParamType & | lookup_with_path (const string &pathspec, bool warn=true) const |
Typeless * | getptr (const key_type &k) |
Returns a pointer to the given parameter, or zero if there is none. | |
const Typeless * | getptr (const key_type &k) const |
Const version of getptr. | |
int | check_all (void) const |
Check upper and lower bounds for each parameter, if defined. | |
void | print_all (FILE *fp, const string &prefix="") const |
Prints parameter values to a file from the parameter blackboard. | |
void | print_constants (FILE *fp, const string &prefix="") const |
Prints constant values to a file. | |
void | print_constants_doc (FILE *fp, const string &prefix="") const |
void | print_children (FILE *fp, const string &prefix="") const |
Prints the names of all children to a file. | |
void | print_parameters (FILE *fp, const string &prefix="") const |
Prints values of all non-constant parameters to a file. | |
void | print_parameters_doc (FILE *fp, const string &prefix="") const |
void | save_parameters (FILE *fp, const string &prefix="") const |
Prints values of all non-constant parameters to a file. | |
char * | completion_generator (char *text, int state) const |
For use with functions like readline(); returns a dynamically-allocated string with the next possible completion for the given partial word. | |
void | message (Msg::MessageLevel m, const string &s) const |
const string & | name () const |
Returns the name of this map. | |
const string | path_name () const |
Returns the fully-qualified (with path) name of this map. | |
const string | path_prefix () const |
Same as path_name() but adds "::" after all non-empty paths, so that the path can be used as a prefix for a parameter name. | |
void | merge (const self &b, const bool overwrite=true) |
bool | defined_locally (const string &name) const |
Static Public Attributes | |
const char *const | help_separator |
|
Constructor. The optional parent argument provides a way to search a series of cascaded maps, returning the first match found. The map can be named, so that e.g. a particular one can be specified for a lookup or set. Definition at line 60 of file parametermap.h. |
|
Check upper and lower bounds for each parameter, if defined. Returns the number that had errors. Definition at line 451 of file parametermap.h. |
|
For use with functions like readline(); returns a dynamically-allocated string with the next possible completion for the given partial word. Free should be called on the string when done with it. Definition at line 636 of file parametermap.h. |
|
Add a parameter to the user interface structure. Returns a true value if the parameter is defined by the end of the call -- 1 if it was defined by this call, 2 if it was already defined. Definition at line 550 of file parametermap.h. References String::C_identifier_length(), and ParameterMap< ParamT >::lookup(). |
|
Returns the specified parameter structure. Always returns a value, so that users are not required to check for errors. However, it can write an error message if the parameter was not found, and a user may check that the result is_valid() to determine if it was found or not. If the parameter is not found in this map, and a parent is defined, the parent is searched recursively, and the first version found is returned. Warning about parameters not found is deferred until there are no more parents available to search. Definition at line 397 of file parametermap.h. References ParameterMap< ParamT >::lookup(). Referenced by ParameterMap< ParamT >::define_param(). |
|
Searches self and children for the specified map, returning it if found. Accepts a vector of strings as the names for each child. If isrooted, names are interpreted relative to the root(); otherwise relative to self. Defaults to self if none found. Definition at line 122 of file parametermap.h. |
|
Searches self and children for the specified map, returning it if found. Accepts a specification of the form [[::]childname][::childname]*[::], i.e. a list of children separated by double colons, ignoring trailing double colons. The mapname must contain no whitespace. A pair of colons at the start means to go first to the highest parent level, then traverse down from there. (Same as get_child but has self type; implemented with a different name because some operations need self type yet some compilers (e.g. Cray) cannot handle differing return value types for the same virtual function.) Definition at line 112 of file parametermap.h. Referenced by ParameterMap< ParamType >::lookup_map(), and ParameterMap< ParamType >::lookup_with_path(). |
|
Returns a new child map (presumably linked to this map) of the same specific type as self; should be implemented by all derived classes. The return type should always be ParamMap* to avoid problems with older compilers, e.g. Cray C++. The child is allocated using new, and should be deleted when no longer needed. If owned is true, this object is responsible for the destruction of the child object when this child is destroyed. (Usually a ParamMap will be associated with another object, to be destroyed when that object is destroyed, but passing true here can be useful for sub-maps owned by a single object. Implements ParamMap. Definition at line 64 of file parametermap.h. |
|
Initial value:
"_______________________________________________________________________________\n"
Definition at line 298 of file parametermap.h. |