Go to Overview over all GrAL packages.
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

IO/control-device.h

Go to the documentation of this file.
00001 #ifndef NMWR_GB_CONTROLLER_H
00002 #define NMWR_GB_CONTROLLER_H
00003 
00004 
00005 
00006 // $LICENSE
00007 
00008 
00009 #include <iostream.h>
00010 #include <string> 
00011 
00012 #include "IO/mutator.h"
00013 
00014 
00031 
00032 class control_device_impl : public controlable {
00033 public:
00034   virtual void update() = 0;
00035   virtual void add(std::string const&, Mutator*) = 0;
00036 
00037   virtual void print_values(std::ostream&) const = 0;
00038 
00039 
00040   virtual void print_unrecognized(std::ostream&) const = 0;
00041   virtual void print_unrecognized(std::ostream&, std::string const&) const = 0;
00042 
00043   virtual void attach_to(std::istream& in) = 0;
00044   virtual control_device_impl* get_sub_device(std::string const& nm) = 0;
00045 
00046   virtual std::string name() const = 0;
00047   virtual ~control_device_impl() {}
00048 };
00049 
00051 class ControlDevice  {
00052 public:
00053   ControlDevice(control_device_impl* imp = 0) : impl(imp) {}
00054 
00055   void add(std::string const& nm, Mutator* value_ref);
00056   void add(char        const* nm, Mutator* value_ref);
00057 
00058   void update();
00059   void print_values      (std::ostream&) const;
00060   void print_unrecognized(std::ostream&) const;
00061   void attach_to         (std::istream& in);
00062 
00063 
00064   void register_at(ControlDevice&, std::string const& prefix);
00065 
00066   std::string name() const;
00067 
00068   ControlDevice getSubDevice(std::string const& name);
00069   ControlDevice getSubDevice(char        const* name);
00070 private:
00071   control_device_impl* impl;
00072 };
00073 
00074 
00076 template<class T>
00077 inline void RegisterAt(ControlDevice& Ctrl, std::string const& name, T& t)
00078 { 
00079   TypedMutator<T>* p = new TypedMutator<T>(t);
00080   Ctrl.add(name, p); 
00081 }
00082 
00084 template<class T>
00085 inline void RegisterAt(ControlDevice& Ctrl, char const*   name, T& t)
00086 {  Ctrl.add(name, new TypedMutator<T>(t)); }
00087 
00088 
00089 
00091 extern ControlDevice GetStreamDevice(istream* in, 
00092                                      std::string const& name = "");
00093 
00094 
00096 extern ControlDevice GetFileControlDevice(char const*   filename, 
00097                                           std::string const& name);
00098 
00100 extern ControlDevice GetCommandlineAndFileControlDevice(int argc, char* argv[],
00101                                                         std::string const& filename, 
00102                                                         std::string const& name);
00103 
00105 extern ControlDevice GetDuplexControlDevice(std::istream     & in2,
00106                                             char        const* filename, 
00107                                             std::string const& name);
00108 extern ControlDevice GetDuplexControlDevice(std::istream     & in2,
00109                                             std::string const& filename, 
00110                                             std::string const& name);
00111 #endif

Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 15:57:06 2002 for External control by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000