AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

control-device.h

Go to the documentation of this file.
00001 #ifndef NMWR_GB_CONTROLLER_H
00002 #define NMWR_GB_CONTROLLER_H
00003 
00004 
00011 #include "stl_CompConf.h"
00012 #include "string_CompConf.h"
00013 
00014 #include "IO/mutator.h"
00015 
00022 class control_device_impl : public controlable {
00023 public:
00024   virtual void update() = 0;
00025   virtual void add(const string&, Mutator*) = 0;
00026 
00027   // virtual void set(const string&, Mutator*) = 0;
00028   // virtual void remove(const string&, Mutator*) = 0;
00029 
00030   virtual void print_values(ostream&) const = 0;
00031   virtual void print_unrecognized(ostream&) const = 0;
00032 
00033   virtual void attach_to(istream& in) = 0;
00034   virtual control_device_impl* get_sub_device(const string& nm) = 0;
00035 
00036   virtual string name() const = 0;
00037   virtual ~control_device_impl() {}
00038 };
00039 
00047 class ControlDevice  {
00048 public:
00049   ControlDevice(control_device_impl* imp = 0) : impl(imp) {}
00050 
00051   void add(const string& nm,Mutator* value_ref);
00052   void add(const char*   nm,Mutator* value_ref);
00053   //  void remove(const string& name);
00054   //  void set(const string& name,Mutator* value_ref);
00055 
00056   void update();
00057   void print_values(ostream&) const;
00058   void print_unrecognized(ostream&) const;
00059   void attach_to(istream& in);
00060 
00061   void register_at(ControlDevice&, const string& prefix);
00062 
00063   string name() const;
00064 
00065   ControlDevice getSubDevice(const string& name);
00066   ControlDevice getSubDevice(const char*   name);
00067 private:
00068   control_device_impl* impl;
00069 };
00070 
00071 
00072 template<class T>
00073 inline void RegisterAt(ControlDevice& Ctrl, const string& name, T& t)
00074 { 
00075   TypedMutator<T>* p = new TypedMutator<T>(t);
00076   Ctrl.add(name, p); 
00077 }
00078 
00079 template<class T>
00080 inline void RegisterAt(ControlDevice& Ctrl, const char*   name, T& t)
00081 {  Ctrl.add(name, new TypedMutator<T>(t)); }
00082 
00083 
00084 
00085 // a simple ControlDevice that reads name-value-pairs from a file
00086 extern ControlDevice GetStreamDevice(istream* in, const string& name = "");
00087 //extern ControlDevice GetFileControlDevice(const string& filename, const string& name);
00088 extern ControlDevice GetFileControlDevice(const char*   filename, const string& name);
00089 
00090 extern ControlDevice GetCommandlineAndFileControlDevice(int argc, char* argv[],
00091                                                         const string& filename, 
00092                                                         const string& name);
00093 
00094 
00095 extern ControlDevice GetDuplexControlDevice(istream& in2,
00096                                             const char* filename, const string& name);
00097 extern ControlDevice GetDuplexControlDevice(istream& in2,
00098                                             const string& filename, const string& name);
00099 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04