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