paramxx  1.0.7
Parameters.h
1 #ifndef PARAMETERS_H
2 #define PARAMETERS_H
3 
4 // --8<--8<--8<--8<--
5 //
6 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
7 //
8 // This file is part of paramxx
9 //
10 // paramxx is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License
12 // as published by the Free Software Foundation; either version 2
13 // of the License, or (at your option) any later version.
14 //
15 // paramxx is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the
22 // Free Software Foundation, Inc.
23 // 51 Franklin Street, Fifth Floor
24 // Boston, MA 02110-1301, USA
25 //
26 // -->8-->8-->8-->8--
27 
28 #include <map>
29 #include <iostream>
30 
31 #include <ParFile.h>
32 
33 using namespace std;
34 
35 class Parameters {
36 
37  friend ostream& operator << ( ostream& os, Parameters& a ) {
38  a.print( os );
39  return os;
40  }
41  //: Output operator.
42  // This operator outputs the contents of the object.
43 
44  friend ostream& operator << ( ostream& os, Parameters* a ) {
45  a->print( os );
46  return os;
47  }
48  //: Output operator.
49  // This operator outputs the contents of the object.
50 
51 public:
52 
53  virtual ~Parameters( ) { }
54 
55  Parameters( int argc, char* argv[], const char* fname=NULL,
56  const char* boolpars[]=0, const char* doublepars[]=0,
57  const char* intpars[]=0, const char* stringpars[]=0 )
58  throw ( ParFileException );
59 
60  void init_Parameters( int argc, char* argv[],const char* fname=NULL,
61  const char* boolpars[]=0, const char* doublepars[]=0,
62  const char* intpars[]=0, const char* stringpars[]=0 )
63  throw ( ParFileException );
64 
65  virtual void print( ostream& os=cout, const char* prefix="#: " ) const;
66 
67  bool pgetb( const char* ) const throw ( ParFileException );
68 
69  int pgeti( const char* ) const throw ( ParFileException );
70 
71  double pgetd( const char* ) const throw ( ParFileException );
72 
73  string pgetstring( const char* ) const throw ( ParFileException );
74 
75 private:
76 
77  map< string, bool, less< string > > bool_parameters;
78 
79  map< string, double, less< string > > double_parameters;
80 
81  map< string, int, less< string > > int_parameters;
82 
83  map< string, string, less< string > > string_parameters;
84 
85  void init_boolpars( ParFile& pf, const char* boolpars[] )
86  throw ( ParFileException );
87 
88  void init_doublepars( ParFile& pf, const char* doublepars[] )
89  throw ( ParFileException );
90 
91  void init_intpars( ParFile& pf, const char* intpars[] )
92  throw ( ParFileException );
93 
94  void init_stringpars( ParFile& pf, const char* stringpars[] )
95  throw ( ParFileException );
96 
97 };
98 
99 #endif
Definition: ParFileException.h:33
STL namespace.
Definition: Parameters.h:35
Definition: ParFile.h:38