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