GlsMenu  1.5.4
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  //------------------------------------------------------------------------
83  //------------------------------------------------------------------------
84  GlsMenuDataFactory( const std::string& name, GlsMenuDictionary& dict );
85 
86  //------------------------------------------------------------------------
90  //------------------------------------------------------------------------
91  virtual ~GlsMenuDataFactory() {}
92 
93  //------------------------------------------------------------------------
97  //------------------------------------------------------------------------
98  virtual std::istream& ReadValue( std::istream& instr );
99 
100  //------------------------------------------------------------------------
104  //------------------------------------------------------------------------
105  virtual std::ostream& WriteValue( std::ostream& outstr );
106 
107 protected:
110 
111  template<class T>
112  class Data
113  {
114  public:
115  //----------------------------------------------------------------
119  //----------------------------------------------------------------
121  const std::string& name,
122  std::istream& instr )
123  {
124  T dummy;
125  GlsMenuData_T<T>* data = new GlsMenuData_T<T>( name, dummy );
126  data->ReadValue( instr );
127  return data;
128  }
129  //----------------------------------------------------------------
134  //----------------------------------------------------------------
136  const std::string& name,
137  std::istream& instr )
138  {
139  GlsMenuDiscrete_T<T>* data = new GlsMenuDiscrete_T<T>( name, T( 0 ) );
140  data->ReadValue( instr );
141  return data;
142  }
143  };
144 
145  //------------------------------------------------------------------------
151  //------------------------------------------------------------------------
152  virtual GlsMenuData* Create( const std::string& name,
153  const std::string& type,
154  std::istream& instr );
155 
156 }; // end GlsMenuDataFactory
157 
158 #endif // GLS_MENUDATAFACTORY_H
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)