00001 #ifndef OPTIONVI_H
00002 #define OPTIONVI_H
00003
00004 #include "Event/nameVI.h"
00005 #include "Event/serverVI.h"
00006
00007 #include <string>
00008 00010
00011 <ul>
00012 <li> The derived class can declare some of its parameters as options. The parameters
00013 should be strings, doubles, integeres or bool. The derived class should rewrite the virtual
00014 method \c defineOption() to include the \c defineOption(parName, parPointer) methods
00015 with the parameter name and the pointer to this parameter. Usually \c defineOptions()
00016 is just a collection of \c defineOption(parname, parpointer).
00017 <li> The derived class or a external friend class (optionServer) can set the value
00018 of options via the methods \c setOption(parName, parContent). The options are identified
00019 with their names.
00020 <li> Note that the methods \c setOption() are not protected and they not returns information of errors.
00021 The external class that set the options should handle that.
00022 </ul>
00023 */
00024
00025
00026
00027
00028
00029 class optionVI : public nameVI
00030
00031 {
00032 friend class optionServer;
00033
00034 public:
00035
00037 optionVI() {clear();};
00039 virtual ~optionVI() {}
00040
00041 protected:
00042
00044 virtual void setName(std::string name);
00045
00047 bool search(std::string name) const;
00048
00050 virtual void defineOption() {};
00051
00053 void defineOption(std::string name, std::string* st) {m_sserver.add(name,st);}
00055 void defineOption(std::string name, double* d) {m_dserver.add(name,d);}
00057 void defineOption(std::string name, int* i) {m_iserver.add(name,i);}
00058
00060 virtual void setOption(std::string name, std::string c) {*(m_sserver.get(name)) = c;}
00062 virtual void setOption(std::string name, double c) {*(m_dserver.get(name)) = c;}
00064 virtual void setOption(std::string name, int c) {*(m_iserver.get(name)) = c;}
00065
00067 virtual void writeOutOptions() const;
00068
00070 virtual void clear() {m_sserver.clear();m_dserver.clear();m_iserver.clear();}
00071
00072 private:
00073
00075 serverVI<std::string> m_sserver;
00077 serverVI<double> m_dserver;
00079 serverVI<int> m_iserver;
00080
00081 };
00082 #endif