GlsMenu
gls_menu_data_factory.h
Go to the documentation of this file.
1 
42 #if !defined(GLS_MENUDATAFACTORY_H)
43 #define GLS_MENUDATAFACTORY_H
44 
45 #ifdef WIN32
46 #pragma warning (disable:4786)
47 #endif
48 
49 #include <string>
50 
51 #include "gls_menu_data.h"
52 
53 class GlsMenuDictionary;
54 
55 //----------------------------------------------------------------------------
75 //----------------------------------------------------------------------------
77 {
78 public:
79 
80  //------------------------------------------------------------------------
84  //------------------------------------------------------------------------
85  GlsMenuDataFactory(const std::string& name, GlsMenuDictionary& dict);
86 
87  //------------------------------------------------------------------------
91  //------------------------------------------------------------------------
92  virtual ~GlsMenuDataFactory() {}
93 
94  //------------------------------------------------------------------------
98  //------------------------------------------------------------------------
99  virtual std::istream& ReadValue(std::istream& instr);
100 
101  //------------------------------------------------------------------------
105  //------------------------------------------------------------------------
106  virtual std::ostream& WriteValue(std::ostream& outstr);
107 
108 
109 protected:
110 
113 
114  template<class T>
115  class Data
116  {
117  public:
118  //----------------------------------------------------------------
122  //----------------------------------------------------------------
124  const std::string& name,
125  std::istream& instr)
126  {
127  T dummy;
128  GlsMenuData_T<T>* data = new GlsMenuData_T<T>(name, dummy);
129  data->ReadValue(instr);
130  return data;
131  }
132  //----------------------------------------------------------------
137  //----------------------------------------------------------------
139  const std::string& name,
140  std::istream& instr)
141  {
142  GlsMenuDiscrete_T<T>* data =
143  new GlsMenuDiscrete_T<T>(name, T(0));
144  data->ReadValue(instr);
145  return data;
146  }
147  };
148 
149  //------------------------------------------------------------------------
155  //------------------------------------------------------------------------
156  virtual GlsMenuData* Create(const std::string& name,
157  const std::string& type,
158  std::istream& instr);
159 
160 }; // end GlsMenuDataFactory
161 
162 
163 
164 #endif // GLS_MENUDATAFACTORY_H
165 
This file defines all menu meta-data classes.
virtual GlsMenuData * Create(const std::string &name, const std::string &type, std::istream &instr)
GlsMenuDictionary & _dict
Data dictionary to add items into.
static GlsMenuData * Create(const std::string &name, std::istream &instr)
virtual std::istream & ReadValue(std::istream &instr)
static GlsMenuData * CreateDiscrete(const std::string &name, std::istream &instr)
virtual std::istream & ReadValue(std::istream &instr)
virtual std::ostream & WriteValue(std::ostream &outstr)
GlsMenuDataFactory(const std::string &name, GlsMenuDictionary &dict)