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