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