classias::parameter_exchange Class Reference


Detailed Description

A class for exchanging parameters.


Public Types

enum  { VT_INT, VT_DOUBLE, VT_STRING }
 Parameter types. More...
typedef std::map< std::string,
value_type
parameter_map
 A type providing a mapping from parameter names to their values.
typedef std::vector< std::string > parameter_list
 A type providing a list of parameter names.

Public Member Functions

 parameter_exchange ()
 Constructs the object.
virtual ~parameter_exchange ()
 Destructs the object.
void init (const std::string &name, int *var, const int defval=0, const std::string &message="")
 Defines an integer parameter.
void init (const std::string &name, double *var, const double defval=0, const std::string &message="")
 Defines a double parameter.
void init (const std::string &name, std::string *var, const std::string &defval="", const std::string &message="")
 Defines a string parameter.
void set (const std::string &name, const int value, bool unk=true)
 Sets a value of a parameter.
void set (const std::string &name, const double value, bool unk=true)
 Sets a value of a parameter.
void set (const std::string &name, const std::string &value, bool unk=true)
 Sets a value of a parameter.
int get_stamp (const std::string &name)
 Gets the time stamp when the parameter value is set.
std::ostream & show (std::ostream &os)
 Shows the parameter values.
std::ostream & help (std::ostream &os)
 Shows the help message of parameters.

Data Fields

parameter_map pmap
 A parameter map.
parameter_list plist
 A parameter list.
int stamp
 A time stamp.

Data Structures

struct  value_type
 Parameter value. More...


Member Enumeration Documentation

anonymous enum

Parameter types.

Enumerator:
VT_INT  Parameter type int .
VT_DOUBLE  Parameter type double .
VT_STRING  Parameter type std::string .


Member Function Documentation

void classias::parameter_exchange::init ( const std::string &  name,
int *  var,
const int  defval = 0,
const std::string &  message = "" 
) [inline]

Defines an integer parameter.

Parameters:
name The name of the parameter.
var The pointer to the parameter variable.
defval The default value of the parameter.
message The help message for the parameter.

void classias::parameter_exchange::init ( const std::string &  name,
double *  var,
const double  defval = 0,
const std::string &  message = "" 
) [inline]

Defines a double parameter.

Parameters:
name The name of the parameter.
var The pointer to the parameter variable.
defval The default value of the parameter.
message The help message for the parameter.

void classias::parameter_exchange::init ( const std::string &  name,
std::string *  var,
const std::string &  defval = "",
const std::string &  message = "" 
) [inline]

Defines a string parameter.

Parameters:
name The name of the parameter.
var The pointer to the parameter variable.
defval The default value of the parameter.
message The help message for the parameter.

void classias::parameter_exchange::set ( const std::string &  name,
const int  value,
bool  unk = true 
) [inline]

Sets a value of a parameter.

Parameters:
name The name of the parameter.
value The integer value.
unk The indicator specifying whether this function throws an exception unknown_parameter when the parameter is undefined.

void classias::parameter_exchange::set ( const std::string &  name,
const double  value,
bool  unk = true 
) [inline]

Sets a value of a parameter.

Parameters:
name The name of the parameter.
value The double value.
unk The indicator specifying whether this function throws an exception unknown_parameter when the parameter is undefined.

void classias::parameter_exchange::set ( const std::string &  name,
const std::string &  value,
bool  unk = true 
) [inline]

Sets a value of a parameter.

Parameters:
name The name of the parameter.
value The string value.
unk The indicator specifying whether this function throws an exception unknown_parameter when the parameter is undefined.

int classias::parameter_exchange::get_stamp ( const std::string &  name  )  [inline]

Gets the time stamp when the parameter value is set.

Parameters:
name The name of the parameter.
Returns:
int The time stamp when the value of the parameter is set.

std::ostream& classias::parameter_exchange::show ( std::ostream &  os  )  [inline]

Shows the parameter values.

Parameters:
os The output stream.
Returns:
std::ostream& The output stream.

std::ostream& classias::parameter_exchange::help ( std::ostream &  os  )  [inline]

Shows the help message of parameters.

Parameters:
os The output stream.
Returns:
std::ostream& The output stream.


Copyright (c) 2002-2009 by Naoaki Okazaki
Mon Dec 28 23:41:05 2009