#include <parameter.h>
Collaboration diagram for ParameterDefinition< T >:
a wrapper for a variable of various types that can be stored in a unified map for lookup. Upper and/or lower bounds can be provided to provide automatic error checking, and documentation for the parameter can be stored for later retrieval.
At present, the template argument is a dummy that ensures that only a single copy of each function is generated, even though it is all defined here in the header file.
Definition at line 80 of file parameter.h.
Public Types | |
typedef ParameterDefinition< T > | self |
Public Methods | |
ParameterDefinition (const Typeless &externallocation, const char *name_i="", bool is_constant_i=false) | |
Construct from an existing Typeless. | |
ParameterDefinition () | |
Default constructor; not a valid parameter. | |
int | check2 () const |
int | check2 (const Typeless &val) const |
Check the given value against the upper and lower bounds, if there are any. | |
string | usage_string (const string prefix="") const |
string | doc_string (const string prefix="") const |
template<class BT> self & | add_lower_bound (const BT &bound) |
template<class BT> self & | add_upper_bound (const BT &bound) |
self & | add_doc (const char *docstring) |
Define help string for a parameter. | |
self & | add_default_expr (const string &expr) |
Add an expression representing a default value. | |
self & | add_setfn (SetFnWrapper2 *fnobj) |
Register a function object which will be in charge of setting this parameter. | |
const char * | get_default_expr () const |
string | stringrep (const Typeless &value, const string &flags="", bool pretty=false) const |
Construct a string representation for the given value, accepting printf-like format flags. | |
string | stringrep (const string &flags="", bool pretty=false) const |
void | mark_set () |
bool | has_been_set () const |
bool | set (const StringParser &parser, const string &s, bool mark=true, bool verbose=changes_verbose, const string &prefix="") |
Sets the parameter to the result of parsing the given string with the given parser. | |
void | update_default_value (const StringParser &sp) |
If there is an expression available for the default value, and the parameter hasn't been set explicitly, generate a new value for the param by evaluating the expression. | |
bool | definition_matches (const self &o) const |
Check to ensure that the specified parameter matches this one closely enough to ignore a redefinition. | |
bool | is_constant () const |
bool | is_valid () const |
const Typeless & | datavalue () const |
Typeless & | datavalue () |
string | print_to_str (const string prefix="") const |
const string & | name () const |
bool | operator< (const self &o) const |
Comparison operator for sorting. | |
self * | duplicate () const |
Return a copy of self which is guaranteed to have an independent copy of the underlying parameter value. | |
Static Public Methods | |
void | message (Msg::MessageLevel m, const string &s) |
Static Public Attributes | |
bool | changes_verbose = true |
Whether to announce param changes. |
|
Add an expression representing a default value. The expression must be allocated in storage that will persist until the last call to get_default_expr(); a string literal will suffice. Definition at line 128 of file parameter.h. |
|
Define help string for a parameter. The docstring should ordinarily be a string literal to avoid scoping and lifetime problems. Definition at line 123 of file parameter.h. |
|
Register a function object which will be in charge of setting this parameter. This function should be careful not to delete any map in which this parameter resides, or segmentation faults are likely. Since in general the setfn cannot know whether it will be called for a particular Parameter map, this means that the setfn should ordinarily refrain from deleting any object containing a Parameter map. Definition at line 139 of file parameter.h. Referenced by LissomMap::LissomMap(). |
|
Check the given value against the upper and lower bounds, if there are any. Returns the number of errors found. Definition at line 290 of file parameter.h. References Typeless::stringrep(). Referenced by ParameterDefinition< T >::set(). |
|
Sets the parameter to the result of parsing the given string with the given parser. If present, the given prefix is used for notification messages. Returns true on success. Definition at line 251 of file parameter.h. References ParameterDefinition< T >::check2(), and ParameterDefinition< T >::stringrep(). Referenced by ParameterDefinition< T >::update_default_value(). |
|
Construct a string representation for the given value, accepting printf-like format flags. If pretty is true, the value may contain extra formatting for user output, e.g. quotes around strings. Definition at line 149 of file parameter.h. References Typeless::prettyprint(), and Typeless::stringrep(). Referenced by ParameterDefinition< T >::set(). |
|
If there is an expression available for the default value, and the parameter hasn't been set explicitly, generate a new value for the param by evaluating the expression. Note that this doesn't count as an explicit set, and thus does not change the value of has_been_set(). Definition at line 170 of file parameter.h. References ParameterDefinition< T >::set(). |