Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ParameterDefinition< T > Class Template Reference

#include <parameter.h>

Collaboration diagram for ParameterDefinition< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T = int>
class ParameterDefinition< T >

Holds a single parameter definition, i.e.

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> selfadd_lower_bound (const BT &bound)
template<class BT> selfadd_upper_bound (const BT &bound)
selfadd_doc (const char *docstring)
 Define help string for a parameter.

selfadd_default_expr (const string &expr)
 Add an expression representing a default value.

selfadd_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 Typelessdatavalue () const
Typelessdatavalue ()
string print_to_str (const string prefix="") const
const string & name () const
bool operator< (const self &o) const
 Comparison operator for sorting.

selfduplicate () 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.


Member Function Documentation

template<class T = int>
self& ParameterDefinition< T >::add_default_expr const string &    expr [inline]
 

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.

template<class T = int>
self& ParameterDefinition< T >::add_doc const char *    docstring [inline]
 

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.

template<class T = int>
self& ParameterDefinition< T >::add_setfn SetFnWrapper2 *    fnobj [inline]
 

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().

template<class T>
int ParameterDefinition< T >::check2 const Typeless   value const
 

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().

template<class T>
bool ParameterDefinition< T >::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.

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().

template<class T = int>
string ParameterDefinition< T >::stringrep const Typeless   value,
const string &    flags = "",
bool    pretty = false
const [inline]
 

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().

template<class T = int>
void ParameterDefinition< T >::update_default_value const StringParser   sp [inline]
 

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().


The documentation for this class was generated from the following file:
Generated on Mon Jan 20 02:37:07 2003 for RF-LISSOM by doxygen1.3-rc2