Parameters.h

00001 #ifndef PARAMETERS_H
00002 #define PARAMETERS_H
00003 
00004 // --8<--8<--8<--8<--
00005 //
00006 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
00007 //
00008 // This file is part of paramxx
00009 //
00010 // paramxx is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public License
00012 // as published by the Free Software Foundation; either version 2
00013 // of the License, or (at your option) any later version.
00014 //
00015 // paramxx is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU General Public License
00021 // along with this program; if not, write to the 
00022 //       Free Software Foundation, Inc. 
00023 //       51 Franklin Street, Fifth Floor
00024 //       Boston, MA  02110-1301, USA
00025 //
00026 // -->8-->8-->8-->8--
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   //: Output operator.
00042   // This operator outputs the contents of the object.
00043 
00044   friend ostream& operator << ( ostream& os, Parameters* a ) {
00045     a->print( os );
00046     return os;
00047   }
00048   //: Output operator.
00049   // This operator outputs the contents of the object.
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

Generated on Thu Oct 2 17:54:19 2008 for paramxx by  doxygen 1.5.6