vtf-logo

read-parameters.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef NMWR_GB_READ_PARAMETERS_H
00004 #define NMWR_GB_READ_PARAMETERS_H
00005 
00051 #include "mutator.h"
00052 
00053 #include <iosfwd>
00054 #include <string>
00055 
00056 // this is basically a dictionary that maps strings
00057 // to placeholders for a variable reference.
00058 // pointers to the abstract base class are used in order to profit
00059 // from polymorphism (derived classes are automatically
00060 // generated via templates in class TypedMutator).
00061 
00062 class string_table_1;
00063 class string_list;
00064 class Mutator;
00065 
00066 class MutableVars {
00067 private:
00068   //  typedef std::map<std::string, Mutator*> table_type;
00069   //table_type table;
00070   typedef string_table_1 table_type;
00071   table_type * table;
00072   string_list* unrecognized;
00073 public:
00074   MutableVars();
00075   ~MutableVars();
00076 
00077   void AddVariable(const std::string& name, Mutator* m);
00078   void AddVariable(const char*   name, Mutator* m);
00079   void ReadVariable(std::istream& is);
00080   void ReadValues(std::istream& in);
00081   void PrintValues(std::ostream& out,
00082                    const std::string& prefix = "",
00083                    const std::string& sep = " ") const;
00084   bool HasUnrecognized() const;
00085   void PrintUnrecognized(std::ostream& out) const;
00086 };
00087 
00088 // this function is necessary, because MutableVars::AddVariable
00089 // (as a member function) is not (yet) allowed to be a template function
00090 
00091 template<class T> 
00092 inline void AddVar(MutableVars& MV, const std::string& name, T& v)
00093 { MV.AddVariable(name,GetMutator(v));}
00094 
00095 
00096 template<class T> 
00097 inline void AddVar(MutableVars& MV, const char* name, T& v)
00098 { AddVar(MV,std::string(name),v);}
00099 
00100 
00101 #endif

Generated on Fri Aug 24 13:00:30 2007 for AMROC's Parameter IO - by  doxygen 1.4.7