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

ParameterMap< ParamT > Class Template Reference

#include <parametermap.h>

Inheritance diagram for ParameterMap< ParamT >:

Inheritance graph
[legend]
Collaboration diagram for ParameterMap< ParamT >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class ParamT = ParameterDefinition<>>
class ParameterMap< ParamT >

Full-featured ParamMap managing documentation and definition as well as lookup.

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 selfnew_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 &param)
 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 &param, bool notify=true, bool copysetfn=true)
template<class T> selfset_local (const string &name, const T &value)
virtual ParamMapget_child (const string &name_="")
virtual const ParamMapget_child (const string &name_="") const
 Const version uses same implementation, but results in a const object.

const selfroot () const
 Returns the highest-level parent map.

selfroot ()
selflookup_map (const string &mapname, bool warn=true)
 Searches self and children for the specified map, returning it if found.

selflookup_map (const PathSpecification::NameList &names, bool warn, bool isrooted)
 Searches self and children for the specified map, returning it if found.

const selflookup_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
Typelessgetptr (const key_type &k)
 Returns a pointer to the given parameter, or zero if there is none.

const Typelessgetptr (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 & Destructor Documentation

template<class ParamT = ParameterDefinition<>>
ParameterMap< ParamT >::ParameterMap self   parent_i = 0,
const string    name_ = ""
[inline]
 

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.


Member Function Documentation

template<class ParamT>
int ParameterMap< ParamT >::check_all void    const
 

Check upper and lower bounds for each parameter, if defined.

Returns the number that had errors.

Definition at line 451 of file parametermap.h.

template<class ParamT>
char * ParameterMap< ParamT >::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.

Free should be called on the string when done with it.

Definition at line 636 of file parametermap.h.

template<class ParamT>
int ParameterMap< ParamT >::define_param const ParamType &    param
 

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

template<class ParamT>
ParameterMap< ParamT >::ParamType & ParameterMap< ParamT >::lookup const string &    name,
bool    warn = true
[virtual]
 

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

template<class ParamT = ParameterDefinition<>>
self& ParameterMap< ParamT >::lookup_map const PathSpecification::NameList &    names,
bool    warn,
bool    isrooted
[inline]
 

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.

template<class ParamT = ParameterDefinition<>>
self& ParameterMap< ParamT >::lookup_map const string &    mapname,
bool    warn = true
[inline]
 

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

template<class ParamT = ParameterDefinition<>>
virtual self* ParameterMap< ParamT >::new_child const string    name_ = "",
const bool    owned = false
[inline, virtual]
 

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.


Member Data Documentation

template<class ParamT = ParameterDefinition<>>
const char *const ParameterMap< ParamT >::help_separator [static]
 

Initial value:

"_______________________________________________________________________________\n"

Definition at line 298 of file parametermap.h.


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