Parameters.h
00001 #ifndef PARAMETERS_H
00002 #define PARAMETERS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <map>
00029 #include <iostream>
00030
00031 #include <ParFile.h>
00032
00033 using namespace std;
00034
00035 class Parameters {
00036
00037 friend ostream& operator << ( ostream& os, Parameters& a ) {
00038 a.print( os );
00039 return os;
00040 }
00041
00042
00043
00044 friend ostream& operator << ( ostream& os, Parameters* a ) {
00045 a->print( os );
00046 return os;
00047 }
00048
00049
00050
00051 public:
00052
00053 virtual ~Parameters( ) { }
00054
00055 Parameters( int argc, char* argv[], const char* fname=NULL,
00056 const char* boolpars[]=0, const char* doublepars[]=0,
00057 const char* intpars[]=0, const char* stringpars[]=0 )
00058 throw ( ParFileException );
00059
00060 void init_Parameters( int argc, char* argv[],const char* fname=NULL,
00061 const char* boolpars[]=0, const char* doublepars[]=0,
00062 const char* intpars[]=0, const char* stringpars[]=0 )
00063 throw ( ParFileException );
00064
00065 virtual void print( ostream& os=cout, const char* prefix="#: " ) const;
00066
00067 bool pgetb( const char* ) const throw ( ParFileException );
00068
00069 int pgeti( const char* ) const throw ( ParFileException );
00070
00071 double pgetd( const char* ) const throw ( ParFileException );
00072
00073 string pgetstring( const char* ) const throw ( ParFileException );
00074
00075 private:
00076
00077 map< string, bool, less< string > > bool_parameters;
00078
00079 map< string, double, less< string > > double_parameters;
00080
00081 map< string, int, less< string > > int_parameters;
00082
00083 map< string, string, less< string > > string_parameters;
00084
00085 void init_boolpars( ParFile& pf, const char* boolpars[] )
00086 throw ( ParFileException );
00087
00088 void init_doublepars( ParFile& pf, const char* doublepars[] )
00089 throw ( ParFileException );
00090
00091 void init_intpars( ParFile& pf, const char* intpars[] )
00092 throw ( ParFileException );
00093
00094 void init_stringpars( ParFile& pf, const char* stringpars[] )
00095 throw ( ParFileException );
00096
00097 };
00098
00099 #endif