GlsMenu  1.5.4
gls_menu_data.h
Go to the documentation of this file.
1 
41 #if !defined( GLS_MENUDATA_H )
42 # define GLS_MENUDATA_H
43 
44 # ifdef WIN32
45 # pragma warning( disable : 4786 )
46 # endif
47 
48 # include "gls_functor.h"
49 # include <iomanip>
50 # include <iostream>
51 # include <stdio.h>
52 # include <string>
53 
54 # include "disti_metadata.h"
55 
56 //============================================================================
64 //============================================================================
65 class GlsMenuData : public disti::DistiAttributeBase
66 {
67 public:
68  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
76  GlsMenuData( const std::string& name, bool localStorage );
77 
78  //------------------------------------------------------------------------
82  //------------------------------------------------------------------------
83  virtual ~GlsMenuData();
84 
85  //------------------------------------------------------------------------
90  //------------------------------------------------------------------------
91  virtual void Inc( long amount = 1 );
92 
93 private:
94 }; // end GlsMenuData
95 
96 //============================================================================
102 //============================================================================
103 template<class T>
105 {
106 public:
107  //------------------------------------------------------------------------
112  //------------------------------------------------------------------------
113  GlsMenuData_T( const std::string& name, T* data );
114 
115  //------------------------------------------------------------------------
120  //------------------------------------------------------------------------
121  GlsMenuData_T( const std::string& name, const T& value );
122 
123  //------------------------------------------------------------------------
129  //------------------------------------------------------------------------
130  GlsMenuData_T( const std::string& name );
131 
132  //------------------------------------------------------------------------
136  //------------------------------------------------------------------------
137  virtual ~GlsMenuData_T();
138 
139  //------------------------------------------------------------------------
145  //------------------------------------------------------------------------
146  virtual void Attach( T*& data );
147 
148  //------------------------------------------------------------------------
154  //------------------------------------------------------------------------
155  virtual bool ReferTo( T& data );
156 
157  //------------------------------------------------------------------------
161  //------------------------------------------------------------------------
162  virtual bool ValueChanged();
163 
164  //------------------------------------------------------------------------
168  //------------------------------------------------------------------------
169  virtual void ResetValueChanged();
170 
171  //------------------------------------------------------------------------
175  //------------------------------------------------------------------------
176  virtual std::ostream& WriteValue( std::ostream& outstr );
177 
178  //------------------------------------------------------------------------
186  //------------------------------------------------------------------------
187  virtual std::istream& ReadValue( std::istream& instr );
188 
189  //------------------------------------------------------------------------
194  //------------------------------------------------------------------------
195  void SetPrecision( int outputPrecision );
196 
197  //------------------------------------------------------------------------
201  //------------------------------------------------------------------------
202  virtual const T& Value() const;
203 
204  //------------------------------------------------------------------------
208  //------------------------------------------------------------------------
209  virtual T& Value();
210 
211  //------------------------------------------------------------------------
215  //------------------------------------------------------------------------
216  virtual void Value( const T& val );
217 
218 protected:
220  T* _data;
221 
224 
227 
230 
231 }; // end GlsMenuData_T
232 
233 // Specializations for output of floats and doubles
234 template<>
235 inline std::ostream& GlsMenuData_T<float>::WriteValue( std::ostream& outstr )
236 {
237  outstr << std::fixed << std::showpoint
238  << std::setprecision( _precision ) << Value();
239  return outstr;
240 };
241 template<>
242 inline std::ostream& GlsMenuData_T<double>::WriteValue( std::ostream& outstr )
243 {
244  outstr << std::fixed << std::showpoint
245  << std::setprecision( _precision ) << Value();
246  return outstr;
247 };
248 
249 //============================================================================
255 //============================================================================
256 template<class T>
258 {
259 public:
260  //------------------------------------------------------------------------
265  //------------------------------------------------------------------------
266  GlsMenuDiscrete_T( const std::string& name, T* data );
267 
268  //------------------------------------------------------------------------
273  //------------------------------------------------------------------------
274  GlsMenuDiscrete_T( const std::string& name, const T& value );
275 
276  //------------------------------------------------------------------------
280  //------------------------------------------------------------------------
281  virtual ~GlsMenuDiscrete_T();
282 
283  //------------------------------------------------------------------------
287  //------------------------------------------------------------------------
288  virtual void Inc( long amount = 1 );
289 
290 }; // end GlsMenuDiscrete_T
291 
292 //============================================================================
299 //============================================================================
300 class GlsMenuLine : public GlsMenuData_T<std::string>
301 {
302 public:
303  //------------------------------------------------------------------------
308  //------------------------------------------------------------------------
309  GlsMenuLine( const std::string& name, std::string* data );
310 
311  //------------------------------------------------------------------------
316  //------------------------------------------------------------------------
317  GlsMenuLine( const std::string& name, const std::string& initialVal = "" );
318 
319  //------------------------------------------------------------------------
323  //------------------------------------------------------------------------
324  virtual ~GlsMenuLine();
325 
326  //------------------------------------------------------------------------
330  //------------------------------------------------------------------------
331  virtual bool OkToWrite();
332 
333  //------------------------------------------------------------------------
337  //------------------------------------------------------------------------
338  virtual std::istream& ReadValue( std::istream& instr );
339 
340 }; // end GlsMenuLine
341 
342 //============================================================================
349 //============================================================================
350 template<class T>
352 {
353 public:
354  //------------------------------------------------------------------------
359  //------------------------------------------------------------------------
360  GlsMenuDataContainer_T( const std::string& name, T* data );
361 
362  //------------------------------------------------------------------------
367  //------------------------------------------------------------------------
368  GlsMenuDataContainer_T( const std::string& name, const T& value );
369 
370  //------------------------------------------------------------------------
376  //------------------------------------------------------------------------
377  GlsMenuDataContainer_T( const std::string& name );
378 
379  //------------------------------------------------------------------------
383  //------------------------------------------------------------------------
384  virtual ~GlsMenuDataContainer_T();
385 
386  //------------------------------------------------------------------------
392  //------------------------------------------------------------------------
393  virtual void Attach( T*& data );
394 
395  //------------------------------------------------------------------------
401  //------------------------------------------------------------------------
402  virtual bool ReferTo( T& data );
403 
404  //------------------------------------------------------------------------
408  //------------------------------------------------------------------------
409  virtual bool ValueChanged();
410 
411  //------------------------------------------------------------------------
415  //------------------------------------------------------------------------
416  virtual void ResetValueChanged();
417 
418  //------------------------------------------------------------------------
422  //------------------------------------------------------------------------
423  virtual std::ostream& WriteValue( std::ostream& outstr );
424 
425  //------------------------------------------------------------------------
433  //------------------------------------------------------------------------
434  virtual std::istream& ReadValue( std::istream& instr );
435 
436  //------------------------------------------------------------------------
441  //------------------------------------------------------------------------
442  void SetPrecision( int outputPrecision );
443 
444  //------------------------------------------------------------------------
448  //------------------------------------------------------------------------
449  virtual const T& Value() const;
450 
451  //------------------------------------------------------------------------
455  //------------------------------------------------------------------------
456  virtual T& Value();
457 
458  //------------------------------------------------------------------------
462  //------------------------------------------------------------------------
463  virtual void Value( const T& val );
464 
465 protected:
467  T* _data;
468 
471 
474 
477 
478 }; // end GlsMenuDataContainer_T
479 
480 //============================================================================
485 //============================================================================
486 template<class MapT>
488 {
489 public:
490  //------------------------------------------------------------------------
495  //------------------------------------------------------------------------
497  const std::string& name,
498  MapT* map,
499  GlsFunctor_T<GlsMenuData*>& CreateFunction );
500 
501  //------------------------------------------------------------------------
507  //------------------------------------------------------------------------
509  const std::string& name,
510  GlsFunctor_T<GlsMenuData*>& CreateFunction );
511 
512  //------------------------------------------------------------------------
516  //------------------------------------------------------------------------
517  virtual ~GlsMenuDataMap_T();
518 
519  //------------------------------------------------------------------------
523  //------------------------------------------------------------------------
524  virtual std::ostream& WriteValue( std::ostream& outstr );
525 
526  //------------------------------------------------------------------------
534  //------------------------------------------------------------------------
535  virtual std::istream& ReadValue( std::istream& instr );
536 
537 protected:
539  MapT* _dataMap;
540 
543 
544 }; // end GlsMenuDataMap_T
545 
546 //----------------------------------------------------------------------------
553 //----------------------------------------------------------------------------
554 bool GetQuoted( std::istream& instr, std::string& theString );
555 
556  //============================================================================
557  // Include inline method definitions
558  //============================================================================
559 # include "gls_menu_data.inl"
560 
561 #endif
virtual std::ostream & WriteValue(std::ostream &outstr)
GlsMenuDiscrete_T(const std::string &name, T *data)
void SetPrecision(int outputPrecision)
virtual void Attach(T *&data)
virtual std::ostream & WriteValue(std::ostream &outstr)
virtual std::ostream & WriteValue(std::ostream &outstr)
virtual const T & Value() const
virtual void Attach(T *&data)
virtual ~GlsMenuLine()
GlsMenuDataContainer_T(const std::string &name, T *data)
bool GetQuoted(std::istream &instr, std::string &theString)
virtual ~GlsMenuDataContainer_T()
T _prevValue
The previous meta-data value.
bool _prevValueValid
Whether or not the previous value should be considered.
virtual std::istream & ReadValue(std::istream &instr)
T _prevValue
The previous meta-data value.
virtual ~GlsMenuDataMap_T()
virtual bool ValueChanged()
virtual bool OkToWrite()
virtual std::istream & ReadValue(std::istream &instr)
GlsFunctor_T< GlsMenuData * > & CreateDataItem
Functor that creates new data items.
virtual bool ReferTo(T &data)
virtual std::istream & ReadValue(std::istream &instr)
virtual ~GlsMenuData_T()
virtual bool ValueChanged()
This file defines generic function object (functor) classes.
void SetPrecision(int outputPrecision)
T * _data
Storage for the meta-data.
virtual void Inc(long amount=1)
MapT * _dataMap
Map Storage for the meta-data.
virtual const T & Value() const
int _precision
Allows for setting of precision for floating point numbers.
GlsMenuDataMap_T(const std::string &name, MapT *map, GlsFunctor_T< GlsMenuData * > &CreateFunction)
GlsMenuData_T(const std::string &name, T *data)
virtual std::istream & ReadValue(std::istream &instr)
bool _prevValueValid
Whether or not the previous value should be considered.
GlsMenuLine(const std::string &name, std::string *data)
virtual void ResetValueChanged()
virtual void ResetValueChanged()
T * _data
Storage for the meta-data.
virtual bool ReferTo(T &data)
virtual ~GlsMenuDiscrete_T()
int _precision
Allows for setting of precision for floating point numbers.
virtual void Inc(long amount=1)
GlsMenuData(const std::string &name, bool localStorage)
virtual ~GlsMenuData()