GL Studio API
gls_metadata_attributes.h
Go to the documentation of this file.
1 /*! \file
2  \brief Defines templated metadata classes for DisplayObjects and other uses.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef _GLS_METADATA_ATTRIBUTES_H
41 #define _GLS_METADATA_ATTRIBUTES_H
42 
43 #include "disti_metadata.h"
44 #include <sstream>
45 #include <stdlib.h>
46 #include <limits.h>
47 #ifndef SGI
48 #include <cctype>
49 #endif
50 #include "gls_include.h"
51 
52 #include "vertex.h"
53 #include "util.h"
54 #include <string.h>
55 #include <stdarg.h>
56 #include "list.h"
57 #include "material.h"
58 #include "display.h"
59 #include "dynamic_array.h"
60 #include <assert.h>
61 
62 namespace disti
63 {
64 
65 // Force the attribute classes to be instanciated
66 // so that they will be exported from the dll
67 // NOTE: These are not necessary if the class is instanciated or specialized elsewhere - BB
68 //template class DistiAttribute<unsigned char>;
69 
70 // DistiAttribute<bool> Specialization
71 template <>
72 inline long DistiAttribute<bool>::ValueInt() { return (long)*_attribPtr; }
73 template <>
74 inline void DistiAttribute<bool>::ValueInt(long val) { *_attribPtr = (val != 0);CallCallback(); }
75 
76 template <>
77 inline std::ostream& DistiAttribute<bool>::WriteValue(std::ostream &outstr)
78 {
79  outstr << *_attribPtr;
80 
81  return outstr;
82 }
83 
84 // helper function used to remove converting int to bool performance warning on certain compilers
85 template< class T >
86 T ConvertToIntOrBool( int value )
87 {
88  return value;
89 }
90 template<>
91 inline bool ConvertToIntOrBool( int value )
92 {
93  return value != 0;
94 }
95 
96 template< class T >
97 T ReadValueAsIntOrBool( std::istream &instr )
98 {
99  std::string value;
100  instr >> value;
101  T temp;
102  if( strcasecmp( value.c_str(), "TRUE" ) == 0 )
103  {
104  temp = true;
105  }
106  else if ( strcasecmp( value.c_str(), "FALSE" ) == 0 )
107  {
108  temp = false;
109  }
110  else
111  {
112  // Check based on an integer value
113  temp = ConvertToIntOrBool<T>( atoi( value.c_str() ) );
114  }
115  return temp;
116 }
117 
118 template <>
119 inline std::istream& DistiAttribute<bool>::ReadValue(std::istream &instr)
120 {
121  *_attribPtr = ReadValueAsIntOrBool< bool >( instr );
122  CallCallback();
123  return instr;
124 }
125 
126 // DistiAttribute<int> Specialization
127 template <>
128 inline long DistiAttribute<int>::ValueInt() { return (long)*_attribPtr; }
129 template <>
130 inline void DistiAttribute<int>::ValueInt(long val) { *_attribPtr = (int)val; CallCallback();}
131 
132 // DistiAttribute<short> Specialization
133 template <>
134 inline long DistiAttribute<short>::ValueInt() { return (long)*_attribPtr; }
135 template <>
136 inline void DistiAttribute<short>::ValueInt(long val) { *_attribPtr = (short)val; CallCallback();}
137 
138 // DistiAttribute<unsigned short> Specialization
139 template <>
140 inline long DistiAttribute<unsigned short>::ValueInt() { return (long)*_attribPtr; }
141 template <>
142 inline void DistiAttribute<unsigned short>::ValueInt(long val) { *_attribPtr = (unsigned short)val; CallCallback();}
143 
144 // DistiAttribute<unsigned char> Specialization
145 template <>
146 inline long DistiAttribute<unsigned char>::ValueInt() { return (long)*_attribPtr; }
147 template <>
148 inline void DistiAttribute<unsigned char>::ValueInt(long val) { *_attribPtr = (unsigned char)val; CallCallback();}
149 
150 template <>
151 inline std::ostream& DistiAttribute<unsigned char>::WriteValue(std::ostream &outstr)
152 {
153  // If we don't cast to int, an actual character will be written. We want a number.
154  outstr << (int)*_attribPtr;
155  return outstr;
156 }
157 
158 template <>
159 inline std::istream& DistiAttribute<unsigned char>::ReadValue( std::istream& instr )
160 {
161  // If we don't cast to int, an actual character will be read. We want a number.
162  // Also, integer types should be able to read as TRUE or FALSE to preserve backwards compatibility for certain attributes (formerly handled by DistiAttributeUCharOrBool)
163  *_attribPtr = static_cast<unsigned char>( ReadValueAsIntOrBool<int>( instr ) );
164  CallCallback();
165  return instr;
166 }
167 
168 template <>
169 inline std::istream& DistiAttribute<int>::ReadValue( std::istream& instr )
170 {
171  // integer types should be able to read as TRUE or FALSE to preserve backwards compatibility for certain attributes (formerly handled by DistiAttributeUCharOrBool)
172  *_attribPtr = ReadValueAsIntOrBool<int>( instr );
173  CallCallback();
174  return instr;
175 }
176 
177 template <>
178 inline std::istream& DistiAttribute<unsigned int>::ReadValue( std::istream& instr )
179 {
180  // integer types should be able to read as TRUE or FALSE to preserve backwards compatibility for certain attributes (formerly handled by DistiAttributeUCharOrBool)
181  *_attribPtr = ReadValueAsIntOrBool<unsigned int>( instr );
182  CallCallback();
183  return instr;
184 }
185 
186 // DistiAttribute<float> Specialization
187 template <>
188 inline long DistiAttribute<float>::ValueInt() { return (long)*_attribPtr; }
189 
190 template <>
191 inline void DistiAttribute<float>::ValueInt(long val) { *_attribPtr = (float)val; CallCallback();}
192 
193 
194 /** Special case for transitioning from a bool to an int
195  * Reads True or False, or integers.
196  * Writes only integers.
197  */
198 class DistiAttributeUCharOrBool : public DistiAttribute<unsigned char>
199 {
200 public:
201  GLS_EXPORT DistiAttributeUCharOrBool(CallbackMethodCallerBase* callback, const AttributeName &name, unsigned char *attribPtr);
202  GLS_EXPORT DistiAttributeUCharOrBool(CallbackMethodCallerBase* callback, const AttributeName &name, unsigned char value);
203 
204  virtual GLS_EXPORT DistiAttributeBase& operator = (const DistiAttributeBase & oldClass);
205 
206  virtual GLS_EXPORT long ValueInt();
207  virtual GLS_EXPORT void ValueInt(long val);
208 
209  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
210  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
211 };
212 
213 /** For fixed length float arrays
214  */
216 {
217  float *_array;
218  int _length;
219 public:
220  GLS_EXPORT DistiAttributeFloatArray(CallbackMethodCallerBase* callback, const AttributeName &name, float *floatArray, int length);
221  virtual GLS_EXPORT ~DistiAttributeFloatArray();
222 
223  virtual GLS_EXPORT bool OkToWrite() const;
224 
225  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
226  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
227 };
228 
229 /** For fixed length double arrays
230  */
232 {
233  double *_array;
234  int _length;
235 public:
236  GLS_EXPORT DistiAttributeDoubleArray(CallbackMethodCallerBase* callback, const AttributeName &name, double *doubleArray, int length);
237  virtual GLS_EXPORT ~DistiAttributeDoubleArray();
238 
239  virtual GLS_EXPORT bool OkToWrite() const;
240 
241  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
242  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
243 };
244 
245 /** An enumeration for Texture Mode */
246 static DistiAttributeEnumDefList TextureModeEnumList(
247  (char *)"TEXTURE_MAP_MODULATE",TEXTURE_MAP_MODULATE,
248  (char *)"TEXTURE_MAP_DECAL", TEXTURE_MAP_DECAL,
249  (char *)"TEXTURE_MAP_BLEND", TEXTURE_MAP_BLEND,
250  (char *)"TEXTURE_MAP_REPLACE", TEXTURE_MAP_REPLACE,
251  NULL);
252 
253 /** Disti Attribute Texture Mode Enum */
254 template<class containerClass> class DistiAttributeTextureModeEnum : public DistiAttributeEnum<containerClass,const int,int>
255 {
256 public:
258  using _BaseClass::_pairList;
259 
260  typedef void (containerClass::*SetMethodType)(const int);
261  typedef int (containerClass::*GetMethodType)();
262 
263  DistiAttributeTextureModeEnum<containerClass>(containerClass* frame,SetMethodType setMethod,GetMethodType getMethod,const AttributeName &name) :
264  DistiAttributeEnum<containerClass,const int,int>(frame,setMethod,getMethod,name)
265  {
266  _pairList = &TextureModeEnumList;
267  }
268 };
269 
270 /** An enumeration for Texture Filter */
271 static DistiAttributeEnumDefList TextureFilterEnumList(
272  (char *)"TEXTURE_FILTER_NEAREST", TEXTURE_FILTER_NEAREST,
273  (char *)"TEXTURE_FILTER_LINEAR", TEXTURE_FILTER_LINEAR,
274  (char *)"TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST", TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST,
275  (char *)"TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR", TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR,
276  (char *)"TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR", TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR,
277  (char *)"TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST", TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST,
278  NULL);
279 
280 /** Disti Attribute Texture Filter Enum */
281 template<class containerClass> class DistiAttributeTextureFilterEnum : public DistiAttributeEnum<containerClass,const int,int>
282 {
283 public:
285  using _BaseClass::_pairList;
286 
287  typedef void (containerClass::*SetMethodType)(const int);
288  typedef int (containerClass::*GetMethodType)();
289 
290  DistiAttributeTextureFilterEnum<containerClass>(containerClass* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name) :
291  DistiAttributeEnum<containerClass,const int,int>(frame,setMethod,getMethod,name)
292  {
293  _pairList = &TextureFilterEnumList;
294  }
295 };
296 
297 /** An enumeration for Polygon Mode */
298 static DistiAttributeEnumDefList PolyModeEnumList(
299  (char *)"POLY_MODE_UNDEFINED", POLY_MODE_UNDEFINED,
300  (char *)"POLY_MODE_POINTS", POLY_MODE_POINTS,
301  (char *)"POLY_MODE_OUTLINE", POLY_MODE_OUTLINE,
302  (char *)"POLY_MODE_FILLED", POLY_MODE_FILLED,
303  (char *)"POLY_MODE_FILL_AND_OUTLINE",POLY_MODE_FILL_AND_OUTLINE,
304  NULL);
305 
306 /** Disti Attribute Poly Mode Enum */
307 template<class containerClass> class DistiAttributePolyModeEnum : public DistiAttributeEnum<containerClass,const int,int>
308 {
309 public:
311  using _BaseClass::_pairList;
312 
313  typedef void (containerClass::*SetMethodType)(const int);
314  typedef int (containerClass::*GetMethodType)();
315 
316  DistiAttributePolyModeEnum<containerClass>(containerClass* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name) :
317  DistiAttributeEnum<containerClass,const int,int>(frame,setMethod,getMethod,name)
318  {
319  _pairList = &PolyModeEnumList;
320  }
321 };
322 
323 /** An enumeration for Polygon End Mode */
324 static DistiAttributeEnumDefList PolyEndEnumList(
325  (char *)"POLY_OPEN", POLY_OPEN,
326  (char *)"POLY_CLOSED", POLY_CLOSED,
327  NULL);
328 
329 /** Disti Attribute Poly End Enum */
330 template<class containerClass> class DistiAttributePolyEndEnum : public DistiAttributeEnum<containerClass,int,int>
331 {
332 public:
334  using _BaseClass::_pairList;
335 
336  typedef void (containerClass::*SetMethodType)(int);
337  typedef int (containerClass::*GetMethodType)();
338 
339  DistiAttributePolyEndEnum<containerClass>(containerClass* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name) :
340  DistiAttributeEnum<containerClass,int,int>(frame, setMethod,getMethod,name)
341  {
342  _pairList = &PolyEndEnumList;
343  }
344 };
345 
346 /** An enumeration for Shading enum */
347 static DistiAttributeEnumDefList ShadingEnumList(
348  (char *)"FLAT", SHADING_FLAT,
349  (char *)"GOURAUD", SHADING_GOURAUD,
350  NULL);
351 
352 /** Disti Attribute Shading Enum */
353 template<class containerClass> class DistiAttributeShadingEnum : public DistiAttributeEnum<containerClass,const int,int>
354 {
355 public:
357  using _BaseClass::_pairList;
358 
359  typedef void (containerClass::*SetMethodType)(const int);
360  typedef int (containerClass::*GetMethodType)();
361 
362  DistiAttributeShadingEnum<containerClass>(containerClass* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name) :
363  DistiAttributeEnum<containerClass,const int,int>(frame,setMethod,getMethod,name)
364  {
365  _pairList = &ShadingEnumList;
366  }
367 };
368 
369 /** An enumeration for ColorMaterialMode enum */
370 template<class containerClass> class DistiAttributeColorMaterialModeEnum : public DistiAttributeEnum<containerClass,const int,int>
371 {
372 public:
374  using _BaseClass::_pairList;
375 
376  typedef void (containerClass::*SetMethodType)(const int);
377  typedef int (containerClass::*GetMethodType)();
378 
379  DistiAttributeColorMaterialModeEnum<containerClass>(containerClass* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name) :
380  DistiAttributeEnum<containerClass,const int,int>(frame,setMethod,getMethod,name)
381  {
382  static DistiAttributeEnumDefList ColorMaterialModeEnum(
383  (char *)"NO_COLOR_MATERIAL", NO_COLOR_MATERIAL,
384  (char *)"DIFFUSE_COLOR_MATERIAL", DIFFUSE_COLOR_MATERIAL,
385  (char *)"AMBIENT_COLOR_MATERIAL", AMBIENT_COLOR_MATERIAL,
386  (char *)"DIFFUSE_AND_AMBIENT_COLOR_MATERIAL", DIFFUSE_AND_AMBIENT_COLOR_MATERIAL,
387  (char *)"EMISSION_COLOR_MATERIAL", EMISSION_COLOR_MATERIAL,
388  (char *)"SPECULAR_COLOR_MATERIAL", SPECULAR_COLOR_MATERIAL,
389  NULL);
390 
391  _pairList = &ColorMaterialModeEnum;
392  }
393 
394  virtual GLS_EXPORT bool OkToWrite() const { return false; }
395 };
396 
397 /** An enumeration for Protection */
398 template<class containerClass> class DistiAttributeProtectionEnum : public DistiAttributeEnum<containerClass,const int,int>
399 {
400 public:
402  using _BaseClass::_pairList;
403 
404  typedef void (containerClass::*SetMethodType)(const int);
405  typedef int (containerClass::*GetMethodType)();
406 
407  DistiAttributeProtectionEnum<containerClass>(containerClass* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name) :
408  DistiAttributeEnum<containerClass,const int,int>(frame,setMethod,getMethod,name)
409  {
410  static DistiAttributeEnumDefList ProtectionEnumList(
411  (char *)"PUBLIC", PUBLIC,
412  (char *)"PRIVATE", PRIVATE,
413  (char *)"PROTECTED", PROTECTED,
414  NULL);
415  _pairList = &ProtectionEnumList;
416 }
417 };
418 
419 /** An enumeration for Alpha Mode */
420 static DistiAttributeEnumDefList AlphaModeEnumList(
421  (char *)"ALPHA_MODE_UNDEFINED", ALPHA_MODE_UNDEFINED,
422  (char *)"ALPHA_MODE_OPAQUE", ALPHA_MODE_OPAQUE,
423  (char *)"ALPHA_MODE_2_LEVEL", ALPHA_MODE_2_LEVEL,
424  (char *)"ALPHA_MODE_256_LEVEL", ALPHA_MODE_256_LEVEL,
425  NULL);
426 
427 /** Disti Attribute Alpha Mode Enum */
428 template<class containerClass> class DistiAttributeAlphaModeEnum : public DistiAttributeEnum<containerClass,const int,int>
429 {
430 public:
432  using _BaseClass::_pairList;
433 
434  typedef void (containerClass::*SetMethodType)(const int);
435  typedef int (containerClass::*GetMethodType)();
436 
437  DistiAttributeAlphaModeEnum<containerClass>(containerClass* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name) :
438  DistiAttributeEnum<containerClass,const int,int>(frame,setMethod,getMethod,name)
439  {
440  _pairList = &AlphaModeEnumList;
441  }
442 };
443 
444 /** An attribute for a char* string
445  */
447 {
448  char* _local;
449 protected:
450  char** _attribPtr;
451 public:
452 
453  // This constructor makes the bold assumption that it can modify the contents
454  // of the supplied char*, by realocating the memory.
455  GLS_EXPORT DistiAttributeString(CallbackMethodCallerBase* callback, const AttributeName &name, char **attribPtr);
456 
457  // Creates local storage, and will resize as needed
458  GLS_EXPORT DistiAttributeString(CallbackMethodCallerBase* callback, const AttributeName &name, char *initialValue);
459  virtual GLS_EXPORT ~DistiAttributeString();
460 
461  // Be careful with this
462  GLS_EXPORT char* LocalStorageString();
463  virtual GLS_EXPORT bool OkToWrite() const;
464 
465  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
466  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
467 };
468 
469 /** Derived from DistiAttributeString, the only difference is that it
470  * reads and writes encoded strings instead of clear strings.
471  */
473 {
474 public:
475  GLS_EXPORT DistiAttributeEncodedString(CallbackMethodCallerBase* callback, const AttributeName &name, char **attribPtr);
476 
477  // Creates local storage, and will resize as needed
478  GLS_EXPORT DistiAttributeEncodedString(CallbackMethodCallerBase* callback, const AttributeName &name, char *initialValue);
479 
480  // Normally ValueString just returns the value of WriteValue, but for encoded strings
481  // this is probably not what we want, so have ValueString work with the unencoded string
482  virtual GLS_EXPORT std::string ValueString();
483  virtual GLS_EXPORT void ValueString(const std::string& s);
484 
485  virtual GLS_EXPORT std::ostream & WriteValue(std::ostream &outstr);
486  virtual GLS_EXPORT std::istream & ReadValue(std::istream &instr);
487 };
488 
489 /** Derived from DistiAttributeStdString, the only difference is that it
490  * reads and writes encoded strings instead of clear strings.
491  */
493 {
494 public:
495  GLS_EXPORT DistiAttributeEncodedStdString(CallbackMethodCallerBase* callback, const AttributeName &name, std::string *attribPtr);
496 
497  // Creates local storage, and will resize as needed
498  GLS_EXPORT DistiAttributeEncodedStdString(CallbackMethodCallerBase* callback, const AttributeName &name, std::string initialValue);
499 
500  virtual GLS_EXPORT bool OkToWrite() const;
501 
502  // Normally ValueString just returns the value of WriteValue, but for encoded strings
503  // this is probably not what we want, so have ValueString work with the unencoded string
504  virtual GLS_EXPORT std::string ValueString();
505  virtual GLS_EXPORT void ValueString(const std::string& s);
506 
507  virtual GLS_EXPORT std::ostream & WriteValue(std::ostream &outstr);
508  virtual GLS_EXPORT std::istream & ReadValue(std::istream &instr);
509 };
510 /** For fixed length char array */
512 {
513  char *_string;
514  int _length;
515 public:
516  GLS_EXPORT DistiAttributeFixedString(CallbackMethodCallerBase* callback, const AttributeName &name, char *string, int length);
517  virtual GLS_EXPORT ~DistiAttributeFixedString();
518 
519  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
520  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
521 };
522 
523 /** Attribute for std::string */
524 class DistiAttributeStdString : public DistiAttribute<std::string>
525 {
526  std::string _localStorageString;
527 public:
528  // This constructor has the storage external
529  GLS_EXPORT DistiAttributeStdString(CallbackMethodCallerBase* callback, const AttributeName &name, std::string *attribPtr);
530 
531  // Creates local storage, and will resize as needed
532  GLS_EXPORT DistiAttributeStdString(CallbackMethodCallerBase* callback, const AttributeName &name, std::string initialValue);
533  virtual GLS_EXPORT ~DistiAttributeStdString();
534 
535  // Be carefull with this
536  GLS_EXPORT std::string* LocalStorageString();
537 
538  virtual GLS_EXPORT bool OkToWrite() const;
539 
540  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
541  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
542 };
543 
544 /** Attribute for Location */
546 {
547 public:
548  GLS_EXPORT DistiAttributeLocation(CallbackMethodCallerBase* callback, const AttributeName &name, Vertex *attribPtr);
549  virtual GLS_EXPORT ~DistiAttributeLocation();
550 
551  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
552  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
553 };
554 
555 /** Attribute for a dictionary of attributes */
557 {
558 protected:
559  DistiAttribDict *_dict;
560 public:
561  GLS_EXPORT DistiAttributeDictionaryAttribute(const AttributeName &name, DistiAttribDict* dict );
562 
563  virtual GLS_EXPORT bool OkToWrite() const;
564 
565  virtual void Add(DistiAttributeBase* attr) { _dict->Add(attr); }
566  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
567  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
568 };
569 
570 /** Attribute for a dictionary of attributes that cares for its siblings */
572 {
573 protected:
574  DistiAttribDict *_dict;
575  DistiAttributeBase* _sibling;
576  bool _hasRead;
577 public:
579 
580  virtual GLS_EXPORT bool OkToWrite() const;
581 
582  virtual void Add(DistiAttributeBase* attr) { _dict->Add(attr); }
583  virtual GLS_EXPORT std::ostream& WriteValue(std::ostream &outstr);
584  virtual GLS_EXPORT std::istream& ReadValue(std::istream &instr);
585 };
586 
587 //----------------------------------------------------------------------------
588 //----------------------------------------------------------------------------
589 /** \class DistiAttributeStdMap
590  * An attribute for a std::map
591  */
592 template<class Map_t>
594 {
595  Map_t* _attribPtr;
596 
597 public:
598  //------------------------------------------------------------------------
600  CallbackMethodCallerBase* callback, const AttributeName &name, Map_t* attribPtr) :
601  DistiAttributeBase(callback, name, false),
602  _attribPtr(attribPtr)
603  {
604  }
605  //------------------------------------------------------------------------
607  DistiAttributeBase(callback, name, true),
608  _attribPtr( new Map_t() )
609  {
610  }
611  //------------------------------------------------------------------------
612  virtual ~DistiAttributeStdMap()
613  {
614  if (_localStorage)
615  delete _attribPtr;
616  _attribPtr = NULL;
617  }
618  //------------------------------------------------------------------------
619  virtual bool OkToWrite() const
620  {
621  return _attribPtr != 0 && _attribPtr->size();
622  }
623  //------------------------------------------------------------------------
624  virtual std::ostream& WriteValue(std::ostream& outstr)
625  {
626  outstr << "\n" << DistiAttribDict::SpacingString() << "{\n";
627  DistiAttribDict::SpacingInc();
628 
629  if (_attribPtr)
630  {
631  typename Map_t::iterator i;
632  for (i = _attribPtr->begin(); i != _attribPtr->end(); ++i)
633  {
634  outstr << DistiAttribDict::SpacingString()
635  << i->first << " " << i->second << std::endl;
636  }
637  }
638 
639  DistiAttribDict::SpacingDec();
640  outstr << DistiAttribDict::SpacingString() << "}\n";
641 
642  return outstr;
643  }
644  //------------------------------------------------------------------------
645  virtual std::istream& ReadValue(std::istream& instr)
646  {
647  instr.ignore(INT_MAX, '{');
648 
649  if (instr.good())
650  {
651  std::stringstream fontStream;
652  instr.get(*fontStream.rdbuf(), '}');
653  if (instr.good())
654  {
655  instr.ignore(1);
656  while (fontStream.good())
657  {
658  // Get rid of all the leading white space before reading the key
659 #ifdef _WIN32
660  std::stringstream::char_type c;
661 #else
662  // std::stringstream::char_type c; causes a parse error before `;' on Linux
663  char c;
664 #endif
665  do
666  {
667  c = fontStream.get();
668  } while (fontStream.good() && isspace(c));
669 
670  if (fontStream.good())
671  {
672  fontStream.putback(c);
673 
674  typename Map_t::key_type key;
675  typename Map_t::mapped_type value;
676 
677  fontStream >> key >> value;
678  (*_attribPtr)[key] = value;
679  }
680  }
681  }
682  }
683  return instr;
684  }
685 }; // end DistiAttributeStdMap
686 
687 
688 /** \class DistiAttributeVertexArray
689  * An attribute for either a Vector or Vertex
690  */
691 template< class T > // Either Vector or Vertex
693 {
694 protected:
695  T** _attribPtr;
696  typedef T* Tptr;
697  unsigned int *_numVertices;
698  unsigned int _numElements;
699  bool _fixedArray;
700  bool _compatabilityMode;
701 public:
702  void SetCompatabilityMode(bool mode) { _compatabilityMode = mode; }
703  // For variable length arrays
704  DistiAttributeVertexArray(CallbackMethodCallerBase* callback, const AttributeName &name, T **attribPtr, unsigned int *numVertices ) :
705  DistiAttributeBase(callback,name,false),
706  _attribPtr(attribPtr),
707  _numVertices(numVertices),
708  _numElements(0),
709  _fixedArray(false)
710  {
711  _compatabilityMode = true;
712  }
713  // For fixed arrays
714  DistiAttributeVertexArray(CallbackMethodCallerBase* callback, const AttributeName &name, T* attribPtr, unsigned int numElements) :
715  DistiAttributeBase(callback,name,true),
716  _attribPtr( new Tptr(attribPtr) ),
717  _numVertices(NULL),
718  _numElements(numElements),
719  _fixedArray(true)
720  {
721  _compatabilityMode = true;
722  }
723 
724 
725  virtual ~DistiAttributeVertexArray()
726  {
727  if ((_fixedArray || _localStorage) &&
728  _attribPtr)
729  delete _attribPtr;
730  _attribPtr = NULL;
731  }
732 
733  virtual bool OkToWrite() const
734  {
735  return (*_attribPtr != NULL);
736  }
737 
738  virtual std::ostream & WriteValue(std::ostream &outstr)
739  {
740  if (*_attribPtr != NULL)
741  {
742  unsigned int numVerts = _numElements;
743  if (!_fixedArray)
744  {
745  outstr << *_numVertices;
746  numVerts = *_numVertices;
747  }
748  DistiAttribDict::SpacingInc();
749  for (unsigned int i = 0 ; i < numVerts; i++ )
750  {
751  outstr << std::endl;
752  outstr << (*_attribPtr)[i];
753  }
754  DistiAttribDict::SpacingDec();
755 
756  }
757  return outstr;
758  }
759  virtual std::istream & ReadValue(std::istream &instr)
760  {
761  unsigned int numVerts = _numElements;
762 
763  if (!_fixedArray)
764  {
765  instr >> numVerts;
766  *_numVertices = numVerts;
767 
768  // Remove old storage if any
769  if (*_attribPtr != NULL)
770  delete [] *_attribPtr;
771 
772  // Create new storage
773  if(numVerts>0)
774  *_attribPtr = new T[numVerts];
775  else
776  *_attribPtr = NULL;
777  }
778 
779  if (!_compatabilityMode)
780  {
781  char buf[1024];
782  // Get newline character
783  instr.getline(buf,1024);
784  }
785 
786  for (unsigned int i = 0 ; i < numVerts; i++ )
787  {
788  if (!_compatabilityMode)
789  {
790  char buf[1024];
791  instr.getline(buf,1024);
792 #ifdef GLS_DEBUG
793  int count =
794 #endif
795  sscanf(buf,"%f %f %f",
796  &((*_attribPtr)[i].x),
797  &((*_attribPtr)[i].y),
798  &((*_attribPtr)[i].z));
799 #ifdef GLS_DEBUG
800  assert (3 == count);
801 #endif
802  }
803  else
804  {
805  instr >> (*_attribPtr)[i];
806  }
807  }
808  CallCallback();
809  return instr;
810  }
811 
812  virtual bool operator==(const DistiAttributeBase& rArg)
813  {
814  DistiAttributeVertexArray< T >* r = dynamic_cast< DistiAttributeVertexArray< T >* >( const_cast<DistiAttributeBase*>(&rArg) );
815  if( !r )
816  {
817  return DistiAttributeBase::operator==( rArg );
818  }
819 
820  if (!(_name == r->_name) || _numElements != r->_numElements )
821  return false;
822 
823  for( unsigned int i = 0u; i < _numElements; ++i )
824  {
825  T leftVert = (*_attribPtr)[i];
826  T rightVert = (*r->_attribPtr)[i];
827  if( !disti::Equal( leftVert.x, rightVert.x ) || !disti::Equal( leftVert.y, rightVert.y ) || !disti::Equal( leftVert.z, rightVert.z ) )
828  {
829  return false;
830  }
831  }
832 
833  return true;
834  }
835 };
836 
837 /** An attribute for either a Vector or Vertex */
838 template<>
840 {
841 protected:
842  Vertex** _attribPtr;
843  typedef Vertex* Tptr;
844  unsigned int *_numVertices;
845  unsigned int _numElements;
846  bool _fixedArray;
847  bool _compatabilityMode;
848 public:
849  void SetCompatabilityMode(bool mode) { _compatabilityMode = mode; }
850  // For variable length arrays
851  DistiAttributeVertexArray(CallbackMethodCallerBase* callback, const AttributeName &name, Vertex **attribPtr, unsigned int *numVertices ) :
852  DistiAttributeBase(callback,name,false),
853  _attribPtr(attribPtr),
854  _numVertices(numVertices),
855  _numElements(0),
856  _fixedArray(false)
857  {
858  _compatabilityMode = true;
859  }
860  // For fixed arrays
861  DistiAttributeVertexArray(CallbackMethodCallerBase* callback, const AttributeName &name, Vertex* attribPtr, unsigned int numElements) :
862  DistiAttributeBase(callback,name,true),
863  _attribPtr( new Tptr(attribPtr) ),
864  _numVertices(NULL),
865  _numElements(numElements),
866  _fixedArray(true)
867  {
868  _compatabilityMode = true;
869  }
870 
871 
872  virtual ~DistiAttributeVertexArray()
873  {
874  if ((_fixedArray || _localStorage) &&
875  _attribPtr)
876  delete _attribPtr;
877  _attribPtr = NULL;
878  }
879 
880  virtual bool OkToWrite() const
881  {
882  return (*_attribPtr != NULL);
883  }
884 
885  virtual std::ostream & WriteValue(std::ostream &outstr)
886  {
887  if (*_attribPtr != NULL)
888  {
889  unsigned int numVerts = _numElements;
890  if (!_fixedArray)
891  {
892  outstr << *_numVertices;
893  numVerts = *_numVertices;
894  }
895  DistiAttribDict::SpacingInc();
896  for (unsigned int i = 0 ; i < numVerts; i++ )
897  {
898  outstr << std::endl;
899  outstr << (*_attribPtr)[i];
900  }
901  DistiAttribDict::SpacingDec();
902 
903  }
904  return outstr;
905  }
906  virtual std::istream & ReadValue(std::istream &instr)
907  {
908  unsigned int numVerts = _numElements;
909 
910  if (!_fixedArray)
911  {
912  instr >> numVerts;
913  *_numVertices = numVerts;
914 
915  // Remove old storage if any
916  if (*_attribPtr != NULL)
917  delete [] *_attribPtr;
918 
919  // Create new storage
920  *_attribPtr = new Vertex[numVerts];
921  }
922 
923  if (!_compatabilityMode)
924  {
925  char buf[1024];
926  // Get newline character
927  instr.getline(buf,1024);
928  }
929 
930  for (unsigned int i = 0 ; i < numVerts; i++ )
931  {
932  if (!_compatabilityMode)
933  {
934  char buf[1024];
935  instr.getline(buf,1024);
936  int r,g,b,a;
937 #ifdef GLS_DEBUG
938  int count =
939 #endif
940  sscanf(buf,"%f %f %f %d %d %d %d",
941  &((*_attribPtr)[i].x),
942  &((*_attribPtr)[i].y),
943  &((*_attribPtr)[i].z),
944  &r,&g,&b,&a);
945 #ifdef GLS_DEBUG
946  assert (7 == count);
947 #endif
948 
949  (*_attribPtr)[i].color.RGBA((unsigned char)r,(unsigned char)g,(unsigned char)b,(unsigned char)a);
950  }
951  else
952  {
953  instr >> (*_attribPtr)[i];
954  }
955  }
956  CallCallback();
957  return instr;
958  }
959 
960  virtual bool operator==(const DistiAttributeBase& rArg)
961  {
963  if( !r )
964  {
965  return DistiAttributeBase::operator==( rArg );
966  }
967 
968  if (!(_name == r->_name) || _numElements != r->_numElements )
969  return false;
970 
971  for( unsigned int i = 0u; i < _numElements; ++i )
972  {
973  Vertex leftVert = (*_attribPtr)[i];
974  Vertex rightVert = (*r->_attribPtr)[i];
975  if( !disti::Equal( leftVert.x, rightVert.x ) || !disti::Equal( leftVert.y, rightVert.y ) || !disti::Equal( leftVert.z, rightVert.z ) || leftVert.color != rightVert.color )
976  {
977  return false;
978  }
979  }
980 
981  return true;
982  }
983 };
984 
985 /** This is used specifically for changing from TexturePoints as Vertexs to TexturePoints as Vectors.
986  * It uses file version information to decide when expect what.
987  */
989 {
990 public:
991  // For fixed arrays
992  DistiAttributeTexturePointArray(CallbackMethodCallerBase* callback, const AttributeName &name, Vector* attribPtr, unsigned int numElements) :
993  DistiAttributeVertexArray<Vector>(callback, name, attribPtr, numElements)
994  {
995  }
996 
997  virtual std::ostream & WriteValue(std::ostream &outstr)
998  {
999  unsigned int numVerts = _numElements;
1000 
1001  for (unsigned int i = 0 ; i < numVerts; i++ )
1002  {
1003  outstr << std::endl;
1004  outstr << (*_attribPtr)[i];
1005  }
1006  return outstr;
1007  }
1008 
1009  virtual std::istream & ReadValue(std::istream &instr)
1010  {
1011  unsigned int numVerts = _numElements;
1012 
1013  for (unsigned int i = 0 ; i < numVerts; i++ )
1014  {
1015  // Get the whole line and then stream it into the Vector.
1016  // Before version 3.0, GL Studio files had full Vertex data
1017  // including color information stored after the location.
1018  // Reading whole lines comsumes this color information which is
1019  // then discarded.
1020  std::string line;
1021  std::getline(instr, line);
1022  // There must have been a leading newline, so read the first line again
1023  if (i == 0 && line.length()==0)
1024  std::getline(instr, line);
1025 
1026  std::stringstream strm(line);
1027  strm >> (*_attribPtr)[i];
1028  }
1029  CallCallback();
1030  return instr;
1031  }
1032 
1033 };
1034 
1035 /** \class DistiAttributeNeverWrite
1036  * Allows for the normal template to be used to load a value but never write it out
1037  * This is used for compatability mostly.
1038  */
1039 template <class T>
1041 {
1042 public:
1043  DistiAttributeNeverWrite(CallbackMethodCallerBase* callback, const AttributeName &name, T *attribPtr):
1044  DistiAttribute<T>(callback, name, attribPtr)
1045  {
1046  }
1047  DistiAttributeNeverWrite(CallbackMethodCallerBase* callback, const AttributeName &name, const T& initialValue):
1048  DistiAttribute<T>(callback, name, initialValue)
1049  {
1050  }
1051 
1052  virtual bool OkToWrite() const { return false; }
1053 };
1054 
1055 /** \class DistiAttributeAlias
1056  * Give an alternate name.
1057  * This is used for compatability mostly.
1058  */
1060 {
1061 public:
1062  DistiAttributeAlias(CallbackMethodCallerBase* callback, const AttributeName &name, const AttributeName &originalName, DistiAttribDict *dict):
1063  DistiAttributeBase(callback, name, false),
1064  _originalAttribName(originalName),
1065  _dictionary(dict)
1066  {
1067  }
1068 
1069  virtual std::ostream & WriteValue(std::ostream &outstr)
1070  {
1071  DistiAttributeBase *originalAttrib = _dictionary->Get(_originalAttribName);
1072  if(originalAttrib)
1073  {
1074  return originalAttrib->WriteValue(outstr);
1075  }
1076 
1077  return outstr;
1078  }
1079 
1080  /** Reads the data from the stream
1081  * The ReadValue call shall consume only what it needs. It is the responsibility of
1082  * the calling function to read to the end of line, or to clean up from a bad read.
1083  * The calling function will also ensure that the data starts as the next byte in the stream. */
1084  virtual std::istream & ReadValue(std::istream &instr)
1085  {
1086  DistiAttributeBase *originalAttrib = _dictionary->Get(_originalAttribName);
1087  if(originalAttrib)
1088  {
1089  originalAttrib->ReadValue(instr);
1090  // the alias could have a separate callback of its own
1091  CallCallback();
1092  }
1093 
1094  return instr;
1095  }
1096 
1097  virtual bool OkToWrite() const { return false; }
1098 
1099  /** \see DistiAttributeBase */
1100  DISTI_EXPORT CallbackID RegisterObserver( AttributeObserver* callback ) DISTI_METHOD_OVERRIDE;
1101  /** \see DistiAttributeBase */
1102  DISTI_EXPORT void UnregisterObserver( CallbackID id ) DISTI_METHOD_OVERRIDE;
1103  /** \see DistiAttributeBase */
1104  DISTI_EXPORT void NotifyObservers() DISTI_METHOD_OVERRIDE;
1105 
1106 protected:
1107  AttributeName _originalAttribName;
1108  DistiAttribDict *_dictionary;
1109 };
1110 
1111 /** \class DistiAttributeDynamicArray
1112  * An attribute for a dynamic array
1113  * T must be related to DynamicArray
1114  */
1115 template <class T, bool showIndex /* In the output */>
1117 {
1118  T* _attribPtr;
1119 
1120 public:
1121  DistiAttributeDynamicArray(CallbackMethodCallerBase* callback, const AttributeName &name, T* attribPtr) :
1122  DistiAttributeBase(callback,name,false),
1123  _attribPtr(attribPtr)
1124  {
1125  }
1126  // Create a new DynamicArray
1128  DistiAttributeBase(callback,name,true),
1129  _attribPtr( new T() )
1130  {
1131  }
1132  virtual ~DistiAttributeDynamicArray()
1133  {
1134  if (_localStorage)
1135  delete _attribPtr;
1136  _attribPtr = NULL;
1137  }
1138 
1139  virtual bool OkToWrite() const
1140  {
1141  return ( _attribPtr != NULL &&
1142  _attribPtr->Size());
1143  }
1144 
1145  virtual std::ostream & WriteValue(std::ostream &outstr)
1146  {
1147  if (_attribPtr != NULL)
1148  {
1149  int numEntries = _attribPtr->Count();
1150  outstr << numEntries;
1151 
1152  DistiAttribDict::SpacingInc();
1153 
1154  for (int i = 0 ; i < numEntries; i++ )
1155  {
1156  outstr << std::endl;
1157 
1158  if (showIndex)
1159  {
1160  outstr << DistiAttribDict::SpacingString() <<i<<" ";
1161  }
1162  outstr.width(1);
1163  outstr << DistiAttribDict::SpacingString() <<(*_attribPtr)[i]<<" ";
1164 
1165  }
1166  DistiAttribDict::SpacingDec();
1167 
1168  }
1169  return outstr;
1170  }
1171  virtual std::istream & ReadValue(std::istream &instr)
1172  {
1173  int numEntries = 0;
1174  instr >> numEntries;
1175 
1176  _attribPtr->Count(numEntries); // Set count of objects in
1177  int entry;
1178  for (int i = 0 ; i < numEntries; i++ )
1179  {
1180  entry = i;
1181  if (showIndex)
1182  {
1183  instr >>entry;
1184  }
1185  instr >> (*_attribPtr)[entry];
1186  }
1187  CallCallback();
1188  return instr;
1189  }
1190 };
1191 
1192 
1193 
1194 /** \class DistiAttributeStdVector
1195  * An attribute for a std::vector
1196  * T must be related to std::vector
1197  */
1198 template <class T, bool showIndex /* In the output */>
1200 {
1201 private:
1202  T* _attribPtr;
1203 
1205 
1206 public:
1207 
1208  DistiAttributeStdVector(CallbackMethodCallerBase* callback, const AttributeName &name, T* attribPtr) :
1209  DistiAttributeBase(callback,name,false),
1210  _attribPtr(attribPtr)
1211  {
1212  }
1213 
1214  // Create a new std::vector
1216  DistiAttributeBase(callback,name,true),
1217  _attribPtr( new T() )
1218  {
1219  }
1220 
1221  virtual ~DistiAttributeStdVector()
1222  {
1223  if (_localStorage)
1224  {
1225  delete _attribPtr;
1226  }
1227  _attribPtr = NULL;
1228  }
1229 
1230  virtual bool OkToWrite() const
1231  {
1232  return ( _attribPtr != NULL && _attribPtr->size() );
1233  }
1234 
1235  virtual std::ostream & WriteValue(std::ostream &outstr)
1236  {
1237  if (_attribPtr != NULL)
1238  {
1239  int numEntries = _attribPtr->size();
1240  outstr << numEntries;
1241 
1242  DistiAttribDict::SpacingInc();
1243 
1244  for (int i = 0 ; i < numEntries; i++ )
1245  {
1246  outstr << std::endl;
1247 
1248  if (showIndex)
1249  {
1250  outstr << DistiAttribDict::SpacingString() <<i<<" ";
1251  }
1252  outstr.width(1);
1253  outstr << DistiAttribDict::SpacingString() <<(*_attribPtr)[i]<<" ";
1254 
1255  }
1256  DistiAttribDict::SpacingDec();
1257 
1258  }
1259  return outstr;
1260  }
1261 
1262  virtual std::istream & ReadValue(std::istream &instr)
1263  {
1264  if( _attribPtr != NULL )
1265  {
1266  int numEntries;
1267  instr >> numEntries;
1268 
1269  _attribPtr->resize(numEntries); // Set count of objects in
1270  int entry;
1271  for (int i = 0 ; i < numEntries; i++ )
1272  {
1273  entry = i;
1274  if (showIndex)
1275  {
1276  instr >>entry;
1277  }
1278  instr >> (*_attribPtr)[entry];
1279  }
1280  CallCallback();
1281  }
1282 
1283  return instr;
1284  }
1285 };
1286 
1287 /** An attribute for a DynamicArray of homogeneous items
1288  * T must have ReadValue and WriteValue methods
1289  * Replacement for DistiAttributeHomogeneousAttributeArray
1290  */
1291 template <class T>
1293 {
1294 public:
1295  typedef T* (*CreateItemCb)();
1296 
1297 protected:
1298  DynamicArray<T*> *_array;
1299  CreateItemCb _createCb;
1300 public:
1301  // Constructor requires a dynamic array of T*.
1303  (const AttributeName &name, DynamicArray<T*> *array, CreateItemCb createCb) :
1304  DistiAttributeBase(NULL,name,false),
1305  _array(array),
1306  _createCb(createCb)
1307  {
1308  }
1310 
1311  virtual bool OkToWrite() const { return _array && _array->Size(); }
1312 
1313  virtual std::ostream & WriteValue(std::ostream &outstr)
1314  {
1315  outstr << "\n" <<
1316  DistiAttribDict::SpacingString() << "{\n";
1317  DistiAttribDict::SpacingInc();
1318  for (unsigned int i = 0; i < _array->Count(); i++)
1319  {
1320  if ((*_array)[i])
1321  {
1322  outstr << DistiAttribDict::SpacingString();
1323  outstr <<"Item: "; // Everything in the list is called Item
1324  ((*_array)[i])->WriteValue(outstr);
1325  outstr << "\n";
1326  }
1327  }
1328  DistiAttribDict::SpacingDec();
1329  outstr << DistiAttribDict::SpacingString() << "}\n";
1330  return outstr;
1331  }
1332  virtual std::istream & ReadValue(std::istream &instr)
1333  {
1334  // Scan through the token including the ':'
1335  std::string buf;
1336 
1337  while (DistiAttribDict::ScanToken(instr, buf))
1338  {
1339  if (!buf.length())
1340  continue;
1341 
1342  if (buf == "Item")
1343  {
1344  // Eat the space between the : and the data
1345  instr.get();
1346  // Dynamically create it, and add it to the end of the list
1347  T* temp = dynamic_cast<T*>(_createCb());
1348  if (temp)
1349  {
1350  _array->InsertObject( temp );
1351  (*_array)[_array->Count()-1]->ReadValue(instr);
1352  }
1353  }
1354 
1355  }
1356  return instr;
1357  }
1358 
1359 };
1360 /** The attribute used in generated code for accessing class properties
1361  * It can have a get method, set method, and an attribute pointer, or almost
1362  * any combination of the three.
1363  * T must have a default constructor, even if it doesn't initialize.
1364  * SetArgT is the argument type for the SetMethodType.
1365  * Specify this if the argument for the Set call is not "const &T".
1366  * The get and set methods are called when the attribute interface is used for access.
1367  * If the methods are not provided, the attribute stream operators are used instead.
1368  * If the property does not have a method or attribute pointer, it will not be able to read/write its value.
1369  */
1370 template <class containerT, class T, class SetArgT = const T&>
1372 {
1373 public:
1374  typedef DistiAttribute<T> _BaseClass;
1375  typedef void (containerT::*SetMethodType)(SetArgT);
1376  typedef T (containerT::*GetMethodType)();
1377  typedef T (containerT::*GetMethodConstType)() const;
1378 
1379  float _precision;
1380  //T* _attribPtr;
1381  containerT* _container;
1382  SetMethodType _setMethod;
1383  GetMethodType _getMethod;
1384 
1385  // NULLs are OK
1386  DistiAttributeProperty(const AttributeName &name, containerT* frame, T* attribPtr, SetMethodType setMethod, GetMethodType getMethod) :
1387  _BaseClass(NULL,name,attribPtr),
1388  _precision(0),
1389  _container(frame),
1390  _setMethod(setMethod),
1391  _getMethod(getMethod)
1392  {
1393  // Automatically use some precision for floats
1394  if ( typeid( T ) == typeid( float ) ||
1395  typeid( T ) == typeid( double )||
1396  typeid( T ) == typeid( long double ))
1397  {
1398  _precision = 10;
1399  }
1400  }
1401 
1402  virtual bool OkToWrite() const DISTI_METHOD_OVERRIDE
1403  {
1404  return (this->_attribPtr || _getMethod);
1405  }
1406 
1407  // The DistiAttribute<> classes override the DistiAttributeBase implementation for these methods. Here, we revert back to the DistiAttributeBase implementation
1408 
1409  virtual std::string ValueString() DISTI_METHOD_OVERRIDE { return DistiAttributeBase::ValueString(); }
1410  virtual void ValueString(const std::string& s) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueString( s ); }
1411 
1412  virtual long ValueInt() DISTI_METHOD_OVERRIDE { return DistiAttributeBase::ValueInt(); }
1413  virtual void ValueInt(long val) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueInt( val ); }
1414 
1415  virtual double ValueFloat() DISTI_METHOD_OVERRIDE { return DistiAttributeBase::ValueFloat(); }
1416  virtual void ValueFloat(double val) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueFloat( val ); }
1417 
1418  virtual std::ostream & WriteValue(std::ostream &outstr) DISTI_METHOD_OVERRIDE
1419  {
1420 
1421  if (_precision > 0)
1422  outstr.precision(int(_precision));
1423 
1424  if (_getMethod && _container)
1425  {
1426  // Save the current _attribPtr
1427  T* tempAttribPtr = this->_attribPtr;
1428 
1429  // Get the value from the method
1430  T temp( (_container->*_getMethod)() );
1431 
1432  // Temporarily change the _attribPtr
1433  this->_attribPtr = &temp;
1434 
1435  // Call the base class to format the _attribPtr
1436  _BaseClass::WriteValue(outstr);
1437 
1438  // Put the _attribPtr back to where it belongs
1439  this->_attribPtr = tempAttribPtr;
1440  }
1441  else if (this->_attribPtr)
1442  {
1443  _BaseClass::WriteValue(outstr);
1444  }
1445 
1446  return outstr;
1447  }
1448 
1449  virtual std::istream & ReadValue(std::istream &instr) DISTI_METHOD_OVERRIDE
1450  {
1451  if (_setMethod && _container)
1452  {
1453  // Save the current _attribPtr
1454  T* tempAttribPtr = this->_attribPtr;
1455  T temp;
1456 
1457  // Set _attribPtr to the temp variable;
1458  this->_attribPtr = &temp;
1459 
1460  // Call the base class to format the input
1461  _BaseClass::ReadValue(instr);
1462 
1463  // Call the method
1464  (_container->*_setMethod)( temp );
1465 
1466  this->_attribPtr = tempAttribPtr;
1467  }
1468  else if (this->_attribPtr)
1469  {
1470  _BaseClass::ReadValue(instr);
1471  }
1472 
1473  return instr;
1474  }
1475 
1476  virtual T Value() DISTI_METHOD_OVERRIDE
1477  {
1478  if (_getMethod && _container)
1479  {
1480  // Get the value from the method
1481  return (_container->*_getMethod)();
1482 
1483  }
1484  else if (this->_attribPtr)
1485  {
1486  return _BaseClass::Value();
1487  }
1488  else
1489  {
1490  return T();
1491  }
1492  }
1493 
1494  virtual void Value( const T& val ) DISTI_METHOD_OVERRIDE // this has to match the base class's prototype so we override it, ie can't use SetArgT here
1495  {
1496  if( _setMethod && _container )
1497  {
1498  ( _container->*_setMethod )( val );
1499  }
1500  else if( this->_attribPtr )
1501  {
1502  _BaseClass::Value( val );
1503  }
1504  }
1505 };
1506 
1507 /** Overloaded helper function to create a DistiAttributeProperty where the setter param is of type Type and the getter is non-const. (See other varians below.)
1508  * \tparam Type The type of the property (int, float, glsColor, etc.)
1509  * \tparam Class The class of the object that owns this parameter (typically a subclass of DisplayObject)
1510  * \param attrName The attribute name for this property.
1511  * \param obj The display object instance associated with this property.
1512  * \param setMethod The setter method for the property (can be NULL)
1513  * \param getMethod The getter method for the property (can be NULL)
1514  * \return The DistiAttributeProperty instance, which is owned by the caller.
1515  * \code
1516  * Attributes().Add( CreateDistiAttributeProperty<int>( MetaTextureIndex, this, &DisplayObject::TextureIndex, &DisplayObject::TextureIndex ) );
1517  * \endcode
1518  */
1519 template <typename Type, class Class>
1521  const AttributeName& attrName,
1522  Class* const obj,
1524  const typename DistiAttributeProperty<Class, Type, Type>::GetMethodType getMethod = NULL )
1525 {
1526  return new DistiAttributeProperty<Class, Type, Type>( attrName, obj, NULL, setMethod, getMethod );
1527 }
1528 
1529 /** Overloaded helper function to create a DistiAttributeProperty where the getter is const. */
1530 template <typename Type, class Class>
1532  const AttributeName& attrName,
1533  Class* const obj,
1536 {
1537  return new DistiAttributeProperty<Class, Type, Type>( attrName, obj, NULL, setMethod,
1538  reinterpret_cast<typename DistiAttributeProperty<Class, Type>::GetMethodType>( getMethod ) );
1539 }
1540 
1541 /** Overloaded helper function to create a DistiAttributeProperty where there is no setter method and the getter is const. */
1542 template <typename Type, class Class>
1544  const AttributeName& attrName,
1545  Class* const obj,
1547 {
1548  return new DistiAttributeProperty<Class, Type>( attrName, obj, NULL, NULL,
1549  reinterpret_cast<typename DistiAttributeProperty<Class, Type>::GetMethodType>( getMethod ) );
1550 }
1551 
1552 /** Overloaded helper function to create a DistiAttributeProperty where there is no setter method and the getter is non-const. */
1553 template <typename Type, class Class>
1555  const AttributeName& attrName,
1556  Class* const obj,
1557  const typename DistiAttributeProperty<Class, Type>::GetMethodType getMethod )
1558 {
1559  return new DistiAttributeProperty<Class, Type>( attrName, obj, NULL, NULL, getMethod );
1560 }
1561 
1562 /** Overloaded helper function to create a DistiAttributeProperty where the setter param is of type const Type& and the getter is non-const. */
1563 template <typename Type, class Class>
1565  const AttributeName& attrName,
1566  Class* const obj,
1568  const typename DistiAttributeProperty<Class, Type, const Type&>::GetMethodType getMethod = NULL )
1569 {
1570  return new DistiAttributeProperty<Class, Type, const Type&>( attrName, obj, NULL, setMethod, getMethod );
1571 }
1572 
1573 /** Overloaded helper function to create a DistiAttributeProperty where the setter param is of type const Type& and the getter is const. */
1574 template <typename Type, class Class>
1576  const AttributeName& attrName,
1577  Class* const obj,
1580 {
1581  return new DistiAttributeProperty<Class, Type, const Type&>( attrName, obj, NULL, setMethod,
1582  reinterpret_cast<typename DistiAttributeProperty<Class, Type, const Type&>::GetMethodType>( getMethod ) );
1583 }
1584 
1585 /** An empty attribute used where a reference to an attribute
1586  * must be returned, but needs to be blank
1587  */
1589 {
1590 public:
1592  DistiAttributeBase(NULL, AttributeName("EmptyAttribute"), false)
1593  {
1594  }
1595 
1596  /** Write nothing */
1597  virtual std::ostream & WriteValue(std::ostream &outstr)
1598  {
1599  return outstr;
1600  }
1601  /** Read nothing */
1602  virtual std::istream & ReadValue(std::istream &instr)
1603  {
1604  return instr;
1605  }
1606 
1607 };
1608 
1609 
1610 /** \class DistiAttributeEnumDirect
1611  * A Disti Attribute which reads and writes enumerations directly, bypassing method calls.
1612  */
1613 template<class enumType>
1615 {
1616 protected:
1617  enumType *_attribPtr;
1618 public:
1619 
1620  DistiAttributeEnumDefList *_pairList;
1621 
1622  DistiAttributeEnumDirect(CallbackMethodCallerBase* callback, const AttributeName &name, enumType *attribPtr, DistiAttributeEnumDefList *pairList) :
1623  DistiAttributeBase(callback,name,false),
1624  _attribPtr(attribPtr),
1625  _pairList(pairList)
1626  {
1627 
1628  }
1629  DistiAttributeEnumDirect(CallbackMethodCallerBase* callback, const AttributeName &name, const enumType& value, DistiAttributeEnumDefList *pairList) :
1630  DistiAttributeBase(callback,name,true),
1631  _attribPtr(new enumType(value)),
1632  _pairList(pairList)
1633  {
1634  }
1635 
1636  virtual ~DistiAttributeEnumDirect()
1637  {
1638  if (_localStorage && _attribPtr)
1639  delete _attribPtr;
1640  //delete _pairList; // This must point to persistant
1641  }
1642 
1643  virtual long ValueInt() { return (long)*_attribPtr; };
1644  virtual void ValueInt(long val) { *_attribPtr = (enumType)val; };
1645 
1646  virtual DistiAttributeBase& operator = (const DistiAttributeBase & oldClass)
1647  {
1648  DistiAttributeEnumDirect* ptr=dynamic_cast<DistiAttributeEnumDirect*>(const_cast<DistiAttributeBase*>(&oldClass));
1649  if (ptr)
1650  {
1651  *_attribPtr = (enumType)*(ptr->_attribPtr);
1652  CallCallback();
1653  }
1654  else
1655  {
1656  return DistiAttributeBase::operator = (oldClass);
1657  }
1658  return *this;
1659  }
1660  virtual std::ostream & WriteValue(std::ostream &outstr)
1661  {
1662  bool foundIt = false;
1663 #ifndef __VXWORKS__
1664  typename DistiAttributeEnumDefList::iterator item = _pairList->begin();
1665  while (item != _pairList->end())
1666  {
1667  if ((*item)->_enum == *_attribPtr)
1668  {
1669  outstr << (*item)->_string;
1670  foundIt = true;
1671  break;
1672  }
1673  ++item;
1674  }
1675  if (!foundIt)
1676  {
1677  //Didn't find it so just write the number
1678  outstr << (int)*_attribPtr;
1679  }
1680 #endif
1681 
1682  return outstr;
1683  }
1684  virtual std::istream & ReadValue(std::istream &instr)
1685  {
1686 #ifndef __VXWORKS__
1687  char value[64];
1688  instr >> value;
1689 
1690  bool foundIt = false;
1691  typename DistiAttributeEnumDefList::iterator item = _pairList->begin();
1692 
1693  // First look by enumeration
1694  while (item != _pairList->end())
1695  {
1696  if (strcmp((*item)->_string, value) == 0)
1697  {
1698  *_attribPtr = (enumType)(*item)->_enum;
1699  CallCallback();
1700 
1701  foundIt = true;
1702  break;
1703  }
1704  ++item;
1705  }
1706 
1707  // If not found, assume that the numerical value is specified.
1708  if (!foundIt)
1709  {
1710  *_attribPtr = (enumType) atoi(value);
1711  CallCallback();
1712  }
1713 #endif
1714 
1715  return instr;
1716  }
1717 };
1718 
1719 
1720 
1721 ////////////////////////////////////////////////////////////////////////////////
1722 /// A macro for boilerplate code to setup a DisplayObject callback.
1723 /// \param instance The DisplayObject instance.
1724 /// \param Class The current class name, derived from DisplayObject.
1725 /// \param Method The class's method name for the callback.
1726 /// \code{.cpp}
1727 /// // Given a class ScrollList that inherits from DisplayObject...
1728 /// ScrollList::ScrollList()
1729 /// {
1730 /// DISTI_REGISTER_METHOD_CALLBACK( this, &ScrollList::EventCallback );
1731 /// }
1732 ///
1733 /// int ScrollList::EventCallback( Group* self, DisplayEvent* ev )
1734 /// {
1735 /// // ... event handler code ...
1736 /// }
1737 /// \endcode
1738 ////////////////////////////////////////////////////////////////////////////////
1739 #define DISTI_REGISTER_METHOD_CALLBACK( instance, Class, Method ) \
1740  { \
1741  typedef CallbackMethodCallerTemplate< Class, Class > Caller; \
1742  typedef typename Caller::MethodType1 MethodType; \
1743  const MethodType callback = reinterpret_cast<MethodType>( Method ); \
1744  ThisClass::CallbackCaller( new Caller( callback, instance ) ); \
1745  }
1746 
1747 ////////////////////////////////////////////////////////////////////////////////
1748 /// A macro for boilerplate code to setup a DisplayObject method caller for
1749 /// MethodType 1.
1750 /// \param object The DisplayObject instance.
1751 /// \param method The method that should be called.
1752 /// \param parent The parent to the object
1753 ////////////////////////////////////////////////////////////////////////////////
1754 #define DISTI_SET_OBJECT_CALLBACK1( object, method, parent ) \
1755  (object)->CallbackCaller( \
1756  new CallbackMethodCallerTemplate< DisplayObject, DisplayObject >( \
1757  ( disti::CallbackMethodCallerTemplate<DisplayObject, DisplayObject>::MethodType1 ) \
1758  (method), (parent) ) );
1759 
1760 ////////////////////////////////////////////////////////////////////////////////
1761 /// A macro for boilerplate code to setup a DisplayObject attribute.
1762 /// \param Type The type of the attribute.
1763 /// \param name The unique string name identifying the attribute.
1764 /// \param memberVarAddr A pointer to the member variable of type \a Type.
1765 /// Can be NULL if no member variable is desired.
1766 /// \sa DISTI_ADD_ATTRIBUTE_CALLBACK
1767 /// \sa DISTI_ADD_ATTRIBUTE_SET_GET
1768 ////////////////////////////////////////////////////////////////////////////////
1769 #define DISTI_ADD_ATTRIBUTE( Type, name, memberVarAddr ) \
1770  { \
1771  static const AttributeName attr( name ); \
1772  CallbackAttributeNotifier< ThisClass > cb( this, attr ); \
1773  this->Attributes().Add( new DistiAttribute<Type>(&cb, (attr), (memberVarAddr) ) ); \
1774  }
1775 
1776 ////////////////////////////////////////////////////////////////////////////////
1777 /// A macro for boilerplate code to setup a DisplayObject attribute that has a
1778 /// callback function.
1779 /// \param Type The type of the attribute.
1780 /// \param name The unique string name identifying the attribute.
1781 /// \param memberVarAddr A pointer to the member variable of type \a Type.
1782 /// Can be NULL if no member variable is desired.
1783 /// \param callback A member function pointer to the function called when this
1784 /// attribute is changed.
1785 /// \sa DISTI_ADD_ATTRIBUTE
1786 /// \sa DISTI_ADD_ATTRIBUTE_SET_GET
1787 ////////////////////////////////////////////////////////////////////////////////
1788 #define DISTI_ADD_ATTRIBUTE_CALLBACK( Type, name, memberVarAddr, callbackFunction ) \
1789  { \
1790  typedef void (ThisClass::*Method)(); /* Member function pointer */ \
1791  static const AttributeName attr( name ); \
1792  CallbackAttributeNotifier< ThisClass > cb( this, attr, reinterpret_cast<Method>( callbackFunction ) ); \
1793  this->Attributes().Add( new DistiAttribute<Type>( &cb, (attr), (memberVarAddr) ) ); \
1794  }
1795 
1796 ////////////////////////////////////////////////////////////////////////////////
1797 /// A macro for boilerplate code to setup a DisplayObject attribute that has a
1798 /// setter and a getter function.
1799 /// \param Type The type of the attribute.
1800 /// \param name The unique string name identifying the attribute.
1801 /// \param setter A member function pointer to the setter function (can be NULL)
1802 /// \param getter A member function pointer to the getter function (can be NULL)
1803 /// \sa DISTI_ADD_ATTRIBUTE
1804 /// \sa DISTI_ADD_ATTRIBUTE_CALLBACK
1805 ////////////////////////////////////////////////////////////////////////////////
1806 #define DISTI_ADD_ATTRIBUTE_SET_GET( Type, name, setter, getter) \
1807  { \
1808  static const AttributeName attr( name ); \
1809  this->Attributes().Add( CreateDistiAttributeProperty<Type>( attr, this, setter, getter ) ); \
1810  }
1811 
1812 ////////////////////////////////////////////////////////////////////////////////
1813 /// A macro for boilerplate code to setup a string as a DisplayObject attribute.
1814 /// \param name The unique string name identifying the attribute.
1815 /// \param memberVarAddr A pointer to the member variable of type std::string.
1816 /// Can be NULL if no member variable is desired.
1817 /// \sa DISTI_ADD_ATTRIBUTE_STRING_CALLBACK
1818 ////////////////////////////////////////////////////////////////////////////////
1819 #define DISTI_ADD_ATTRIBUTE_STRING( name, memberVarAddr ) \
1820  { \
1821  static const AttributeName attr( name ); \
1822  CallbackAttributeNotifier< ThisClass > cb( this, attr ); \
1823  this->Attributes().Add( new DistiAttributeEncodedStdString( &cb, attr, memberVarAddr ) ); \
1824  }
1825 
1826 ////////////////////////////////////////////////////////////////////////////////
1827 /// A macro for boilerplate code to setup a string as a DisplayObject attribute
1828 /// with a callback
1829 /// \param name The unique string name identifying the attribute.
1830 /// \param memberVarAddr A pointer to the member variable of type std::string.
1831 /// Can be NULL if no member variable is desired.
1832 /// \param callbackFunction The function that gets called when the attribute changes.
1833 /// \sa DISTI_ADD_ATTRIBUTE_STRING
1834 ////////////////////////////////////////////////////////////////////////////////
1835 #define DISTI_ADD_ATTRIBUTE_STRING_CALLBACK( name, memberVarAddr, callbackFunction ) \
1836  { \
1837  typedef void (ThisClass::*Method)(); /* Member function pointer */ \
1838  static const AttributeName attr( name ); \
1839  CallbackAttributeNotifier< ThisClass > cb( this, attr, reinterpret_cast<Method>( callbackFunction ) ); \
1840  this->Attributes().Add( new DistiAttributeEncodedStdString( &cb, attr, memberVarAddr ) ); \
1841  }
1842 
1843 } // namespace disti
1844 
1845 #endif
1846 
Definition: display_types.h:76
Definition: gls_metadata_attributes.h:215
Definition: gls_metadata_attributes.h:545
Definition: gls_metadata_attributes.h:231
Definition: display_types.h:101
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1313
Definition: display_types.h:74
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1171
Definition: gls_metadata_attributes.h:1588
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:738
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:997
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1084
Definition: vertex.h:365
The disti metadata.
The disti::Material class.
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1069
Definition: gls_metadata_attributes.h:524
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:759
Definition: gls_metadata_attributes.h:254
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:885
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1009
DistiAttributeProperty< Class, Type, const Type & > * CreateDistiAttributeProperty(const AttributeName &attrName, Class *const obj, const typename DistiAttributeProperty< Class, Type, const Type & >::SetMethodType setMethod, const typename DistiAttributeProperty< Class, Type, const Type & >::GetMethodConstType getMethod)
Definition: gls_metadata_attributes.h:1575
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
Definition: gls_metadata_attributes.h:1199
Definition: gls_metadata_attributes.h:198
Definition: gls_metadata_attributes.h:428
Definition: gls_metadata_attributes.h:353
Definition: display_types.h:153
Definition: gls_metadata_attributes.h:472
Definition: gls_metadata_attributes.h:593
virtual long ValueInt()
Definition: gls_metadata_attributes.h:1643
Definition: display_types.h:151
Definition: display_types.h:92
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:619
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1097
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1139
Definition: display_types.h:104
Definition: gls_metadata_attributes.h:1614
Definition: display_types.h:93
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:569
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: gls_metadata_attributes.h:960
virtual T Value()
Definition: gls_metadata_attributes.h:1476
Definition: gls_metadata_attributes.h:988
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:583
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:624
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1262
Definition: display_types.h:103
virtual std::string ValueString()
Definition: gls_metadata_attributes.h:1409
void InsertObject(const T &obj, unsigned int loc)
Definition: dynamic_array.h:231
Definition: display_types.h:111
A file for all GL Studio files to include.
Definition: display_types.h:64
Definition: display_types.h:117
The disti::DisplayObject class and global enumerations.
Definition: gls_metadata_attributes.h:839
virtual void ValueString(const std::string &s)
Definition: gls_metadata_attributes.h:1410
Definition: display_types.h:91
Definition: gls_metadata_attributes.h:1116
Definition: gls_metadata_attributes.h:1292
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1332
Definition: gls_metadata_attributes.h:281
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:394
Definition: gls_metadata_attributes.h:1059
Definition: display_types.h:102
Definition: disti_metadata.h:881
Definition: display_types.h:124
virtual void ValueInt(long val)
Definition: gls_metadata_attributes.h:1644
The List_c class. Generic linked list.
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1597
void Count(const unsigned int count)
Definition: dynamic_array.h:120
virtual void Add(DistiAttributeBase *attr)
Definition: display_types.h:152
Definition: display_types.h:65
Definition: display_types.h:63
Definition: gls_metadata_attributes.h:1040
Definition: disti_metadata.h:466
The disti::Vertex class. A class for manipulating 3D vertices.
Generally useful defines, macros, enumerations and function prototypes.
Definition: gls_metadata_attributes.h:1371
Definition: gls_metadata_attributes.h:398
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1660
Definition: disti_metadata.h:179
virtual long ValueInt()
Definition: disti_metadata.h:524
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1418
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:906
Definition: disti_metadata.h:162
Definition: display_types.h:62
Definition: gls_metadata_attributes.h:446
virtual double ValueFloat()
Definition: gls_metadata_attributes.h:1415
Definition: disti_metadata.h:661
Definition: disti_metadata.h:869
Definition: callback_caller_base.h:56
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1311
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1602
Definition: display_types.h:95
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1449
bool Equal(T1 x, T2 y, float precision=0.001f)
Definition: util.h:239
Definition: display_types.h:72
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1145
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1402
Definition: display_types.h:150
Definition: gls_metadata_attributes.h:556
AttributeName _name
Definition: disti_metadata.h:185
virtual long ValueInt()
Definition: gls_metadata_attributes.h:1412
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:880
Definition: display_types.h:118
Definition: vertex.h:84
virtual void ValueFloat(double val)
Definition: gls_metadata_attributes.h:1416
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:645
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1235
Definition: display_types.h:94
Definition: gls_metadata_attributes.h:511
Definition: gls_metadata_attributes.h:692
Definition: display_types.h:75
Definition: display_types.h:71
virtual void Value(const T &val)
Definition: gls_metadata_attributes.h:1494
Definition: display_types.h:73
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1052
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1684
Definition: gls_metadata_attributes.h:571
Definition: gls_metadata_attributes.h:370
Definition: gls_metadata_attributes.h:492
Definition: display_types.h:154
Definition: gls_metadata_attributes.h:307
Definition: disti_metadata.h:83
Definition: display_types.h:126
Definition: display_types.h:125
Definition: gls_metadata_attributes.h:330
unsigned int Size() const
Definition: dynamic_array.h:138
Definition: bmpimage.h:46
Definition: display_types.h:149
virtual std::istream & ReadValue(std::istream &instr)=0
virtual void ValueInt(long val)
Definition: gls_metadata_attributes.h:1413
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1230
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: gls_metadata_attributes.h:812
Definition: display_types.h:110
virtual std::ostream & WriteValue(std::ostream &outstr)=0
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:733