coin-Bcp
|
This is the class serves as a holder for a set of parameters. More...
#include <BCP_parameters.hpp>
Public Types | |
typedef Par::chr_params | chr_params |
typedef Par::int_params | int_params |
typedef Par::dbl_params | dbl_params |
typedef Par::str_params | str_params |
typedef Par::str_array_params | str_array_params |
Public Member Functions | |
Query methods | |
The members of the parameter set can be queried for using the overloaded entry() method. Using the example in the class documentation the user can get a parameter with the "<code>param.entry(USER_par::parameter_name)</code>" expression. | |
char | entry (const chr_params key) const |
int | entry (const int_params key) const |
double | entry (const dbl_params key) const |
const BCP_string & | entry (const str_params key) const |
const BCP_vec< BCP_string > & | entry (const str_array_params key) const |
Set methods | |
First, there is the assignment operator that sets the whole parameter set at once. Individual members of the parameter set can be set for using the overloaded set_entry() method. Using the example in the class documentation the user can set a parameter with the "<code>param.set_entry(USER_par::parameter_name, param_value)</code>" expression. | |
BCP_parameter_set< Par > & | operator= (const BCP_parameter_set< Par > &x) |
void | set_entry (const chr_params key, const char val) |
void | set_entry (const chr_params key, const bool val) |
void | set_entry (const int_params key, const int val) |
void | set_entry (const dbl_params key, const double val) |
void | set_entry (const str_params key, const char *val) |
void | set_entry (const str_array_params key, const char *val) |
void | set_entry (const BCP_parameter key, const char *val) |
Read parameters from a stream. | |
void | read_from_stream (std::istream &parstream) |
Read the parameters from the stream specified in the argument. More... | |
Expand parameter value (look for environment vars). | |
std::string | expand (const char *value) |
Read parameters from a file. | |
void | read_from_file (const char *paramfile) |
Simply invoke reading from a stream. More... | |
Read parameters from the command line | |
void | read_from_arglist (const int argnum, const char *const *arglist) |
Simply invoke reading from a stream. More... | |
Write parameters to a stream. | |
void | write_to_stream (std::ostream &outstream) const |
Write keyword-value pairs to the stream specified in the argument. More... | |
Packing/unpacking methods | |
void | pack (BCP_buffer &buf) |
Pack the parameter set into the buffer. More... | |
void | unpack (BCP_buffer &buf) |
Unpack the parameter set from the buffer. More... | |
Constructors and destructor. | |
BCP_parameter_set () | |
The default constructor creates a parameter set with from the template argument structure. More... | |
~BCP_parameter_set () | |
The destructor deletes all data members. More... | |
Private Member Functions | |
Private methods that must be defined for each parameter set. | |
If the user creates a new parameter set, she must define these two methods for the class. | |
void | create_keyword_list () |
Method for creating the list of keyword looked for in the parameter file. More... | |
void | set_default_entries () |
Method for setting the default values for the parameters. More... | |
Private Attributes | |
Data members. All of them are private. | |
BCP_vec< std::pair< BCP_string, BCP_parameter > > | keys |
The keyword, parameter pairs. More... | |
BCP_vec< BCP_string > | obsolete_keys |
list of obsolete keywords. More... | |
char * | cpar |
The character parameters. More... | |
int * | ipar |
The integer parameters. More... | |
double * | dpar |
The double parameters. More... | |
BCP_string * | spar |
The string (actually, BCP_string) parameters. More... | |
BCP_vec< BCP_string > * | sapar |
The string array parameters. More... | |
This is the class serves as a holder for a set of parameters.
For example, BCP stores has a parameter set for each process. Of course, the user can use this class for her own parameters. To use this class the user must
struct
with the names of the parameters (see, e.g., BCP_tm_par. Assume that the structure is named USER_par
. BCP_parameter_set<USER_par>::create_keyword_list()
and BCP_parameter_set<USER_par>::set_default_entries()
. For an example look at the file BCP-common/TM/BCP_tm_param.cpp
. Essentially, the first method defines what keywords should be looked for in the parameter file, and if one is found which parameter should take the corresponding value; the other method specifies the default values for each parameter. After this the user can read in the parameters from a file, she can set/access the parameters in the parameter, etc.
Definition at line 113 of file BCP_parameters.hpp.
typedef Par::chr_params BCP_parameter_set< Par >::chr_params |
Definition at line 129 of file BCP_parameters.hpp.
typedef Par::int_params BCP_parameter_set< Par >::int_params |
Definition at line 130 of file BCP_parameters.hpp.
typedef Par::dbl_params BCP_parameter_set< Par >::dbl_params |
Definition at line 131 of file BCP_parameters.hpp.
typedef Par::str_params BCP_parameter_set< Par >::str_params |
Definition at line 132 of file BCP_parameters.hpp.
typedef Par::str_array_params BCP_parameter_set< Par >::str_array_params |
Definition at line 133 of file BCP_parameters.hpp.
|
inline |
The default constructor creates a parameter set with from the template argument structure.
The keyword list is created and the defaults are set.
Definition at line 564 of file BCP_parameters.hpp.
|
inline |
The destructor deletes all data members.
Definition at line 576 of file BCP_parameters.hpp.
|
private |
Method for creating the list of keyword looked for in the parameter file.
Referenced by BCP_parameter_set< BCP_tm_par >::BCP_parameter_set().
|
private |
Method for setting the default values for the parameters.
Referenced by BCP_parameter_set< BCP_tm_par >::BCP_parameter_set().
|
inline |
Definition at line 168 of file BCP_parameters.hpp.
Referenced by BCP_ts_user::get_param(), BCP_lp_prob::param(), and BCP_tm_prob::param().
|
inline |
Definition at line 171 of file BCP_parameters.hpp.
|
inline |
Definition at line 174 of file BCP_parameters.hpp.
|
inline |
Definition at line 177 of file BCP_parameters.hpp.
|
inline |
Definition at line 180 of file BCP_parameters.hpp.
|
inline |
Definition at line 196 of file BCP_parameters.hpp.
|
inline |
Definition at line 215 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::read_from_stream(), and BCP_ts_user::set_param().
|
inline |
Definition at line 218 of file BCP_parameters.hpp.
|
inline |
Definition at line 221 of file BCP_parameters.hpp.
|
inline |
Definition at line 224 of file BCP_parameters.hpp.
|
inline |
Definition at line 227 of file BCP_parameters.hpp.
|
inline |
Definition at line 230 of file BCP_parameters.hpp.
|
inline |
Definition at line 233 of file BCP_parameters.hpp.
|
inline |
Read the parameters from the stream specified in the argument.
The stream is interpreted as a lines separated by newline characters. The first word on each line is tested for match with the keywords specified in the create_keyword_list() method. If there is a match then the second word will be interpreted as the value for the corresponding parameter. Any further words on the line are discarded. Every non-matching line is discarded.
If the keyword corresponds to a non-array parameter then the new value simply overwrites the old one. Otherwise, i.e., if it is a StringArrayPar, the value is appended to the list of strings in that array.
Definition at line 262 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::read_from_arglist(), and BCP_parameter_set< BCP_tm_par >::read_from_file().
|
inline |
Definition at line 385 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::read_from_stream().
|
inline |
Simply invoke reading from a stream.
Definition at line 441 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::read_from_stream().
|
inline |
Simply invoke reading from a stream.
Definition at line 454 of file BCP_parameters.hpp.
|
inline |
Write keyword-value pairs to the stream specified in the argument.
Each keyword-value pair is separated by a newline character.
Definition at line 476 of file BCP_parameters.hpp.
|
inline |
Pack the parameter set into the buffer.
Definition at line 522 of file BCP_parameters.hpp.
|
inline |
Unpack the parameter set from the buffer.
Definition at line 535 of file BCP_parameters.hpp.
|
private |
The keyword, parameter pairs.
Used when the parameter file is read in.
Definition at line 140 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::read_from_stream(), and BCP_parameter_set< BCP_tm_par >::write_to_stream().
|
private |
list of obsolete keywords.
If any of these is encountered a warning is printed.
Definition at line 143 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::read_from_stream().
|
private |
The character parameters.
Definition at line 145 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::entry(), BCP_parameter_set< BCP_tm_par >::pack(), BCP_parameter_set< BCP_tm_par >::set_entry(), BCP_parameter_set< BCP_tm_par >::unpack(), BCP_parameter_set< BCP_tm_par >::write_to_stream(), and BCP_parameter_set< BCP_tm_par >::~BCP_parameter_set().
|
private |
The integer parameters.
Definition at line 147 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::entry(), BCP_parameter_set< BCP_tm_par >::pack(), BCP_parameter_set< BCP_tm_par >::set_entry(), BCP_parameter_set< BCP_tm_par >::unpack(), BCP_parameter_set< BCP_tm_par >::write_to_stream(), and BCP_parameter_set< BCP_tm_par >::~BCP_parameter_set().
|
private |
The double parameters.
Definition at line 149 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::entry(), BCP_parameter_set< BCP_tm_par >::pack(), BCP_parameter_set< BCP_tm_par >::set_entry(), BCP_parameter_set< BCP_tm_par >::unpack(), BCP_parameter_set< BCP_tm_par >::write_to_stream(), and BCP_parameter_set< BCP_tm_par >::~BCP_parameter_set().
|
private |
The string (actually, BCP_string) parameters.
Definition at line 151 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::entry(), BCP_parameter_set< BCP_tm_par >::pack(), BCP_parameter_set< BCP_tm_par >::set_entry(), BCP_parameter_set< BCP_tm_par >::unpack(), BCP_parameter_set< BCP_tm_par >::write_to_stream(), and BCP_parameter_set< BCP_tm_par >::~BCP_parameter_set().
|
private |
The string array parameters.
Definition at line 153 of file BCP_parameters.hpp.
Referenced by BCP_parameter_set< BCP_tm_par >::entry(), BCP_parameter_set< BCP_tm_par >::pack(), BCP_parameter_set< BCP_tm_par >::set_entry(), BCP_parameter_set< BCP_tm_par >::unpack(), BCP_parameter_set< BCP_tm_par >::write_to_stream(), and BCP_parameter_set< BCP_tm_par >::~BCP_parameter_set().