GL Studio C++ Runtime API
disti_metadata.h
Go to the documentation of this file.
1/// \file
2/// \brief The disti metadata.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 11301 Corporate Blvd; Suite 100<br>
8/// Orlando, Florida 32817<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef INCLUDED_DISTI_METADATA_H
40#define INCLUDED_DISTI_METADATA_H
41
42#if defined( WIN32 )
43# pragma warning( push )
44# pragma warning( disable : 4786 )
45# pragma warning( disable : 4251 ) // This may hide non-exported code.
46#endif
47
48#include "disti_include.h"
49#include "dynamic_array.h"
51#include "scoped_ptr.h"
52#include "unhide_globals.h"
53#include "weak_reference.h"
55
56#include <cfloat>
57#include <cstdarg>
58#include <cstring>
59#include <iostream>
60#include <list>
61#include <map>
62#include <sstream>
63
64#if defined( LINUX )
65# include <cstdlib>
66# include <typeinfo>
67#endif
68
69/// Macro to exclude attribute name debug code when not used.
70#if GLS_DEBUG_ATTRIBUTE_NAMES
71# define IF_GLS_DEBUG_ATTRIBUTE_NAMES( x ) x
72#else
73# define IF_GLS_DEBUG_ATTRIBUTE_NAMES( x )
74#endif
75
76namespace disti
77{
78class CallbackMethodCallerBase;
79const int MAX_ATTRIBUTE_NAME_LENGTH = 128; ///< Unused, remains for backward compatibility.
80
81/** AttributeName class can be treated like a std::string in some instances
82 * It creates static storage for any referenced name.
83 * This results in only one copy for each name which saves memory
84 * Very fast comparison between references to names
85 */
87{
88public:
89 /// Constructor
90 /// Explicit because construction of an AttributeName is an
91 /// expensive operation. If possible you should use a static
92 /// AttrbuteName object rather than constructing a new
93 /// one each time it is needed.
94 /// \param name The desired name.
95 DISTI_EXPORT explicit AttributeName( const std::string& name );
96
97 /// Constructor
98 /// See comments on AttributeName(const std::string &name)
99 /// \param name The desired name.
100 DISTI_EXPORT explicit AttributeName( const char* name );
101
102 /// Constructor
103 /// \param stringIndex The index into the string map.
104 DISTI_EXPORT explicit AttributeName( long stringIndex );
105
106 /// Copy constructor
107 /// \param other The object to copy from.
109 : _stringIndex( other._stringIndex )
110 {
111 IF_GLS_DEBUG_ATTRIBUTE_NAMES( _name = *this );
112 }
113
114 /// Copy assignment operator
115 /// \param other The object to copy from.
116 /// \return The resulting object (this).
118 {
119 _stringIndex = other._stringIndex;
120 IF_GLS_DEBUG_ATTRIBUTE_NAMES( _name = *this );
121 return *this;
122 }
123
124 /// \return The index to the string associate with this instance.
125 long StringIndex() const { return _stringIndex; }
126
127 /// Defines the cast operator to make this look like a std::string for reading
128 DISTI_EXPORT operator std::string() const;
129
130private:
131 long _stringIndex;
132
133 // for easier debugging
134 IF_GLS_DEBUG_ATTRIBUTE_NAMES( std::string _name; )
135
136 /** Attempts to find the specified name.
137 * If found _stringIndex is set to its index
138 * otherwise a new one is created and its index is saved */
139 void Initialize( const char* name );
140};
141
142/// Stream out operator.
143/// \param outstr The stream to write to.
144/// \param name The value to write to the stream.
145/// \return The stream in its current state.
146DISTI_EXPORT std::ostream& operator<<( std::ostream& outstr, const AttributeName& name );
147
148/// Compares this string to the specified AttributeName.
149/// This compare is very fast compared to doing string compares, and is
150/// one of the primary reasons for creating this class
151/// \param attr1 A name to compare.
152/// \param attr2 The other name to compare.
153/// \return Whether or not the names are the same.
154inline bool operator==( const AttributeName& attr1, const AttributeName& attr2 )
155{
156 return attr1.StringIndex() == attr2.StringIndex();
157}
158
159/// Compares this string for inequality to the specified AttributeName.
160/// This compare is very fast compared to doing string compares, and is
161/// one of the primary reasons for creating this class
162/// \param attr1 A name to compare.
163/// \param attr2 The other name to compare.
164/// \return Whether or not the names are not the same.
165inline bool operator!=( const AttributeName& attr1, const AttributeName& attr2 )
166{
167 return !( attr1 == attr2 );
168}
169
170/// Compare two attribute names in various formats.
171/// \param lName A name to compare.
172/// \param rName The other name to compare.
173/// \return Whether or not the names are the same.
174DISTI_EXPORT bool operator==( const AttributeName& lName, const char* rName );
175
176/// Compare two attribute names in various formats.
177/// \param lName A name to compare.
178/// \param rName The other name to compare.
179/// \return Whether or not the names are the same.
180DISTI_EXPORT bool operator==( const char* lName, const AttributeName& rName );
181
182/// Compare two attribute names in various formats.
183/// \param lName A name to compare.
184/// \param rName The other name to compare.
185/// \return Whether or not the names are the same.
186DISTI_EXPORT bool operator==( const std::string& lName, const AttributeName& rName );
187
188/// Compare two attribute names in various formats.
189/// \param lName A name to compare.
190/// \param rName The other name to compare.
191/// \return Whether or not the names are the same.
192DISTI_EXPORT bool operator==( const AttributeName& lName, const std::string& rName );
193
194/// Add a string literal suffix operator to allow "MyAttribute"_Attr for creation of attributes.
195DISTI_IF_HAS_USER_DEFINED_LITERAL( inline AttributeName operator""_Attr( const char* str, std::size_t ) { return AttributeName( str ); } )
196
197class DistiAttributeBase;
198
199/** Class used to call a callback method that takes a DistiAttributeBase */
201{
202public:
203 /// Call the callback with the provided display event.
204 /// \param attr The attribute associated with this callback.
205 virtual void Call( DistiAttributeBase& attr ) = 0;
206
207 /// When IsValid is false, then this AttributeObserver can be deleted.
208 /// \return Whether or not this observer is attached to a valid attribute.
209 virtual bool IsValid() const = 0;
210
211 virtual ~AttributeObserver() {}
212};
213
214class DistiAttributeObserverList;
215
216/** \class DistiAttributeBase
217 * This is the base class for all Disti Attributes.
218 */
220{
221private:
223
224protected:
225 /** The name of this attribute */
227 /** The callback which is called when the value of this object changes */
229
230 /** The list of observers to be notified when this property changes. */
232
233 /** _localStorage is true if this attributes data should be copied.
234 * It would typically be set false if the data is stored externally,
235 * and there is no need to copy the data through metadata.
236 * It is also used to determine if storage should be deleted.*/
238
239public:
240 /** Constructor
241 * \param callback The method to call when the value changes. A duplicate of the
242 CallbackMethodCallerBase is created and stored internally.
243 * \param name The name of the attribute
244 * \param localStorage True if this DistiAttribute contains actual storage,
245 rather than just a pointer to somebody elses storage*/
246 DISTI_EXPORT DistiAttributeBase( CallbackMethodCallerBase* callback, const AttributeName& name, bool localStorage );
247
248 /// This will perform the copy using ReadValue() and WriteValue()
249 /// It can be overridden by any dervied classes to do a smarter more efficent copy.
250 /// \param oldClass The object to copy from.
251 /// \return The resulting object (this).
252 virtual DISTI_EXPORT DistiAttributeBase& operator=( const DistiAttributeBase& oldClass );
253
254 virtual DISTI_EXPORT ~DistiAttributeBase();
255
256 /// \return The name of this object.
257 DISTI_EXPORT const AttributeName& Name() const;
258
259 /// \returns The name of this object.
260 DISTI_EXPORT AttributeName& Name();
261
262 /// \return True if this object has local storage.
263 DISTI_EXPORT bool LocalStorage() const;
264
265 /// It is not a word, but it means it is able to be copied.
266 /// \note By default, will only copy if it contains local storage
267 /// \return True if it makes sense for the data to be copied.
268 virtual DISTI_EXPORT bool Copyable() const;
269
270 /// This SHOULD be overriden by any derived objects that may not be ready to write at any point.
271 /// The reason for this is the data is often written "NAME: VALUE".
272 /// If Value is not available, we don't want to write "NAME: " first, so before
273 /// writing "NAME: ", OkToWrite() can be called to see if it will have a valid value.
274 /// \return True if this object is ready to have its WriteValue() called.
275 virtual DISTI_EXPORT bool OkToWrite() const;
276
277 /// \note This is not implmented in the base class and will always return true if not overridden.
278 /// \return True if the object's value has changed since calling ResetValueChanged().
279 virtual DISTI_EXPORT bool ValueChanged();
280
281 /// Saves the current value for later comparison by ValueChanged().
282 /// \note This does nothing in the base class.
283 virtual DISTI_EXPORT void ResetValueChanged();
284
285 /// Here in the base class it uses WriteValue().
286 /// If this particular attribute's underlying type is a string, this returns the unencoded value, suitable for users.
287 /// If a file encoded value is required, call WriteValue instead.
288 /// \return The std::string version of the attribute data.
289 virtual DISTI_EXPORT std::string ValueString();
290
291 /// Sets the value from a std::string argument.
292 /// Here in the base class it uses ReadValue().
293 /// If this particular attribute's underlying type is a string, this should not be set to an encoded value.
294 /// If needing to set from an encoded value, call ReadValue instead.
295 /// \param s The string value to set.
296 virtual DISTI_EXPORT void ValueString( const std::string& s );
297
298 /// Allows for faster access to integer types than the more generic stream operators.
299 /// \note This is only faster if it is overridden.
300 /// \return The integer value of this attribute.
301 virtual DISTI_EXPORT long ValueInt();
302
303 /// Allows for faster access to integer types than the more generic stream operator.
304 /// \note This is only faster if it is overridden.
305 /// \param val The new integer value to set.
306 virtual DISTI_EXPORT void ValueInt( long val );
307
308 /// Allows for faster access to floating-point types than the more generic stream operators.
309 /// \note This is only faster if it is overridden.
310 /// \return The double value of this attribute.
311 virtual DISTI_EXPORT double ValueFloat();
312
313 /// Allows for faster access to floating-point types than the more generic stream operator.
314 /// \note This is only faster if it is overridden.
315 /// \param val The new double value to set.
316 virtual DISTI_EXPORT void ValueFloat( double val );
317
318 /// Calls callback CallType3 if it has been set.
319 virtual DISTI_EXPORT void CallCallback();
320
321 /// Pure virtual because this is specific to the data type to be contained.
322 /// This should be overridden to write the data to the stream.
323 /// The value written could be encoded for writing to a file as a single string,
324 /// or have its own special encoding specific to its underlying type.
325 /// In the case of attribute strings, this will be the GLS file encoded value.
326 /// The user is responsible for decoding the value themselves, or using ReadValue
327 /// which should perform decoding to maintain symmetry.
328 /// \param outstr The stream to write to.
329 /// \return The output stream in its current state.
330 virtual std::ostream& WriteValue( std::ostream& outstr ) = 0;
331
332 /// Pure virtual because this is specific to the data type to be contained.
333 /// This should be overridden to read the data from the stream.
334 /// The value read could be encoded for being read from a file as a single string,
335 /// or have its own special encoding specific to its underlying type.
336 /// In the case of attribute strings, this will be the GLS file encoded value.
337 /// The user is responsible for encoding the value themselves, or using WriteValue
338 /// which should perform encoding to maintain symmetry.
339 /// \param instr The stream to read from.
340 /// \return The input stream in its current state.
341 virtual std::istream& ReadValue( std::istream& instr ) = 0;
342
343 /// Compares name and value.
344 /// \note This can be overriden to improve speed.
345 /// \param r The attribute to compare.
346 /// \return Whether or not the attributes have the same name and value.
347 virtual DISTI_EXPORT bool operator==( const DistiAttributeBase& r );
348
349 /// Allow for generic access to some data types.
350 /// This will NOT work for types which: s << val does not work.
351 /// In general if the WriteValue is overridden, then it probably will not work.
352 /// \param val The new value to set.
353 /// \return The updated attribute (this).
354 template<class valType>
355 DistiAttributeBase& operator<<( const valType& val )
356 {
357 std::stringstream s;
358 // Ensure numeric values make it into the attribute's ReadValue implementation unmodified.
359 s.precision( MaxDigits10<long double>::value );
360 s << val;
361 ReadValue( s );
362 return *this;
363 }
364
365 /// Allows for generic access to some data types.
366 /// This will NOT work for types which: s >> val does not work.
367 /// In general if the ReadValue is overridden, then it probably will not work.
368 /// \param val The value to be returned.
369 /// \return This attribute (unmodified, unless there are side effects).
370 template<class valType>
372 {
373 std::stringstream s;
374 WriteValue( s );
375 s >> val;
376 return *this;
377 }
378
379 /// Stream out operator.
380 /// \note Internally it uses WriteValue().
381 /// \param outstr Stream to write path to.
382 /// \param attribute The value to write to the stream.
383 /// \return The stream in its current state.
384 friend DISTI_EXPORT std::ostream& operator<<( std::ostream& outstr, const DistiAttributeBase& attribute );
385
386 /// Stream in operator.
387 /// \note Internally it uses ReadValue().
388 /// \param instr The stream to read from.
389 /// \param attribute The returned value read from the stream.
390 /// \return The stream in its current state.
391 friend DISTI_EXPORT std::istream& operator>>( std::istream& instr, DistiAttributeBase& attribute );
392
393 /// Type for unique identifiers
394 typedef unsigned int CallbackID;
395
396 /** Register a callback that is called when the value of the attribute changes. If multiple oservers are registered, they will be notified in the order they registered.
397 * DistiAttributeBase takes ownership of the observer and will delete it.
398 * \param observer the observer to notify. It is automatically unregistered and destroyed when it becomes invalid.
399 * \return an id that can be used to unregister the observer
400 */
401 virtual DISTI_EXPORT CallbackID RegisterObserver( AttributeObserver* observer );
402
403 /** Unregister an observer
404 * \param id the id returned when the observer was registered
405 */
406 virtual DISTI_EXPORT void UnregisterObserver( CallbackID id );
407
408 /** Triggers all observers to have their callbacks called. Typically called by the class that owns the DistiAttributeBase */
409 virtual DISTI_EXPORT void NotifyObservers();
410};
411
412/** Template for an AttributeCallbackBase that will call a class method whenever the attribute changes. The class must implement WeakReferenceable.
413 * Don't use this directly, use CreateAttributeMethodCallback instead.
414 */
415template<class T>
417{
418public:
419 typedef void ( T::*Callback )( DistiAttributeBase& attr ); ///< Typedef for the callback function pointer.
420
421 /// Construct a new AttributeMethodCallback object to link the callback and the class containing it.
422 /// \param object The object containing the callback method.
423 /// \param method The method to call back.
425 : _method( method )
426 , _object( object )
427 {
428 GLS_VERIFY( NULL != method );
429 GLS_VERIFY( NULL != object );
430 }
431
433 {
434 if( IsValid() )
435 {
436 ( _object.Get()->*( _method ) )( ev );
437 }
438 }
439
440 virtual bool IsValid() const DISTI_METHOD_OVERRIDE
441 {
442 return !_object.IsNull();
443 }
444
445protected:
446 Callback _method; ///< Method to call back when invoked.
447 WeakRef<T> _object; ///< The underlying object containing the callback method.
448};
449
450/// Create an AttributeMethodCallback that will call a class method whenever the attribute changes.
451/// \param obj The object to call the method on.
452/// \param method A class method pointer.
453/// \return The created AttributeMethodCallback.
454template<class Class>
456 Class* const obj,
457 const typename AttributeMethodCallback<Class>::Callback method )
458{
459 return new AttributeMethodCallback<Class>( obj, method );
460}
461
462/** Template for an AttributeCallbackBase that will set another object's attribute whenever the attribute changes. The class must implement WeakReferenceable.
463 * Don't use this directly, use CreateAttributeResourceCallback instead.
464 */
465template<class T>
467{
468public:
469 /// Construct a new AttributeResourceCallback object to link an attribute to an attribute of another object.
470 /// \param object The object containing the attribute.
471 /// \param attributeName The attribute to set.
472 AttributeResourceCallback( T* object, const AttributeName& attributeName )
473 : _attributeName( attributeName )
474 , _object( object )
475 {
476 GLS_VERIFY( NULL != object );
477 }
478
480 {
481 if( IsValid() )
482 {
483 if( DistiAttributeBase* objAttr = _object.Get()->Attributes().Get( _attributeName ) )
484 {
485 ( *objAttr ) << attr.ValueString();
486 }
487 }
488 }
489
490 virtual bool IsValid() const DISTI_METHOD_OVERRIDE
491 {
492 return !_object.IsNull();
493 }
494
495protected:
496 AttributeName _attributeName; ///< The attribute to set when invoked.
497 WeakRef<T> _object; ///< The object containing the attribute.
498};
499
500/// Create an CreateAttributeResourceCallback that will set another object's attribute whenever the attribute changes.
501/// \param obj The object to set the resource on.
502/// \param attributeName The name of the property.
503/// \return The created CreateAttributeResourceCallback.
504template<class Class>
506 Class* const obj,
507 const char* attributeName )
508{
509 return new AttributeResourceCallback<Class>( obj, AttributeName( attributeName ) );
510}
511
512/** Interface for notifying when attributes have changed */
514{
515public:
516 /** Notify the class that the attribute has changed. Observers of the attribute will have their callbacks called
517 * \param name the name of the attribute
518 */
519 virtual DISTI_EXPORT void NotifyAttributeChanged( const AttributeName& name ) = 0;
520
521 /** destructor */
523};
524
525/** helper method to notify if an attribute has changed through a setter method
526 * \param object the object to notify
527 * \param property the storage for the data that is going to be set
528 * \param newValue the new value to set
529 * \param name the attribute name
530 */
531template<class T>
532void SetAndNotifyIfChanged( AttributeChangedNotifier* object, T& property, const T& newValue, const AttributeName& name )
533{
534 if( newValue != property )
535 {
536 property = newValue;
537 object->NotifyAttributeChanged( name );
538 }
539}
540
541/** \class DistiAttribute
542 * A templated class for creating attributes.
543 */
544class DistiAttribDict;
545template<class T>
547{
548protected:
549 /** Points to the actual storage */
551 /** Allows for setting of precision for floating point numbers */
553
554public:
555 /** Constructor
556 * Keeps a pointer to the specified type
557 * \param callback The method to call when the value changes. A duplicate of the
558 * CallbackMethodCallerBase is created and stored internally.
559 * \param name The name of the attribute
560 * \param attribPtr The address of the storage.
561 */
562 DistiAttribute( CallbackMethodCallerBase* callback, const AttributeName& name, T* attribPtr )
563 : DistiAttributeBase( callback, name, false )
564 , _attribPtr( attribPtr )
565 , _precision( MaxDigits10<T>::value )
566 {
567 }
568
569 /** Constructor
570 * Actually creates storage of the specified type
571 * \param callback The method to call when the value changes. A duplicate of the
572 * CallbackMethodCallerBase is created and stored internally.
573 * \param name The name of the attribute
574 * \param initialValue The initial value of the internally stored variable.
575 */
576 DistiAttribute( CallbackMethodCallerBase* callback, const AttributeName& name, const T& initialValue )
577 : DistiAttributeBase( callback, name, true /*Because we actually have storage*/ )
578 , _attribPtr( new T( initialValue ) )
579 , _precision( MaxDigits10<T>::value )
580 {
581 }
582
583 /// \return Whether or not this attribute is copyable (which it is).
584 bool Copyable() const DISTI_METHOD_OVERRIDE { return true; }
585
586 /// \return The integer value of this attribute.
588 {
590 }
591
592 /// Set the integer value of this attribute.
593 /// \param val The integer value to set for this attribute.
595 {
597 }
598
599 /// \return The double value of this attribute.
601 {
603 }
604
605 /// Set the double value for this attribute.
606 /// \param val The double value to set for this attribute.
608 {
610 }
611
612 /// Assignment operator
613 /// \param oldClass The attribute to assign.
614 /// \return The resulting attribute (this).
616 {
617 DistiAttribute* ptr;
618
619 ptr = dynamic_cast<DistiAttribute*>( const_cast<DistiAttributeBase*>( &oldClass ) );
620 if( ptr )
621 {
622 Value( ptr->Value() );
623 }
624 else
625 {
626 return DistiAttributeBase::operator=( oldClass );
627 }
628 return *this;
629 }
630
631 /// Write this attribute's string value to the stream.
632 /// \param outstr The stream to write to.
633 /// \return The stream in its updated state.
634 std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
635 {
636 if( _precision > 0 )
637 outstr.precision( _precision );
638
639 //operator<<(outstr, *_attribPtr);
640 outstr << *_attribPtr;
641 return outstr;
642 };
643
644 /// Read from the stream, and store it in this attribute.
645 /// \param instr The stream to read from.
646 /// \return The stream in its updated state.
647 std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
648 {
649 return ReadValueImpl( instr );
650 };
651
652 /// Allows for type specific access to the data.
653 /// \return The underlying value of the attribute in its type.
654 virtual T Value()
655 {
656 return *_attribPtr;
657 }
658
659 /// Allows for type specific access to the data.
660 /// \param val The value to set in the attribute's type.
661 virtual void Value( const T& val )
662 {
663 *_attribPtr = val;
664 CallCallback();
665 }
666
667 /// Performs type specific comparison.
668 /// This results in faster comparisons than the base class
669 /// \param rArg The attribute to compare.
670 /// \return Whether or not the attribute names and values are the same.
672 {
673 DistiAttribute<T>* r = dynamic_cast<DistiAttribute<T>*>( const_cast<DistiAttributeBase*>( &rArg ) );
674 if( !r )
675 return false;
676
677 if( !( _name == r->_name ) )
678 return false;
679
680 return Value() == r->Value();
681 }
682
683 /** Destructor
684 * deletes local storage if we created it */
686 {
687 // Only delete it if we created it.
688 if( _localStorage )
689 {
690 delete _attribPtr;
691 }
692 _attribPtr = NULL;
693 }
694
695private:
696 std::istream& ReadValueImpl( std::istream& instr )
697 {
699 instr >> *_attribPtr;
700 CallCallback();
701
702 return instr;
703 }
704};
705
706/** Optimized ReadValueImpl for floating point types.
707 * Visual Studio 2012 (vc110) runtime performs much slower when using
708 * std::istream::operator>>( float& val )
709 */
710template<>
711inline std::istream& DistiAttribute<float>::ReadValueImpl( std::istream& instr )
712{
713 char instrBuf[ 64 ];
714 instr >> instrBuf;
715 *_attribPtr = static_cast<float>( atof( instrBuf ) );
716 CallCallback();
717
718 return instr;
719}
720
721template<>
722inline std::istream& DistiAttribute<double>::ReadValueImpl( std::istream& instr )
723{
724 char instrBuf[ 64 ];
725 instr >> instrBuf;
726 *_attribPtr = atof( instrBuf );
727 CallCallback();
728
729 return instr;
730}
731
732/** The Attribute Dictionary is a container for DistiAttributeBase derived objects */
734{
735public:
736 /** Allows for easy access to the contained class type */
738
739 typedef std::list<Attr_t> List_t; ///< Typedef for a list of attribute pointers.
740 typedef std::multimap<long, Attr_t> Map_t; ///< Typedef for a map ot attribute pointers.
741
742 typedef List_t::const_iterator const_iterator; ///< Shorthand for List_t::const_iterator.
743 typedef List_t::iterator iterator; ///< Shorthand for List_t::iterator.
744
745 /** Constructor */
746 DISTI_EXPORT DistiAttribDict();
747
748 /** Destructor */
749 DISTI_EXPORT ~DistiAttribDict();
750
751#if defined( DISTI_HAS_RVAL_REFS )
752 /// Move constructor
753 /// \param other The object to move.
754 DISTI_EXPORT DistiAttribDict( DistiAttribDict&& other )
755 {
756 *this = std::move( other );
757 }
758
759 /// Move Assignment
760 /// \param other The object to move.
761 /// \return This object, post move.
763 {
764 if( this != &other )
765 {
766 _list = std::move( other._list );
767 _map = std::move( other._map );
768 }
769 return *this;
770 }
771#endif
772
773 /** Used as needed for version specific parsing
774 * Whenever a version is parsed, the results should be stored here.
775 * This does add order dependency.
776 *
777 * Note: These are not set or used by the DistiAttribDict class
778 * they are here to be set and accessed by the derived Attributes.
779 * Since they are shared by all instances of DistiAttribDict, they
780 * are only valid while the dictionary is parsing a file.
781 */
782 static DISTI_EXPORT unsigned int _currentFileVersionMajor;
783 /** \sa _currentFileVersionMajor */
784 static DISTI_EXPORT unsigned int _currentFileVersionMinor;
785 /** \sa _currentFileVersionMajor */
786 static DISTI_EXPORT unsigned int _currentFileVersionBuild;
787
788 /** \deprecated Do not use. Will be removed in a later version. */
789 static DISTI_EXPORT double _currentFileVersionPrimary;
790 /** \deprecated Do not use. Will be removed in a later version. */
791 static DISTI_EXPORT long _currentFileVersionSecondary;
792
793 /// Copies the values for all items which have matching names between this object and \a dict.
794 /// All other values are ignored.
795 /// \param dict The dictionary to copy from.
796 /// \return The combined dictionary (this).
797 /// \deprecated Use CopyCommonValues() instead.
798 DISTI_DEPRECATED( "Renamed to CopyCommonValues() to better represent the action taken by this function." )
799 DISTI_EXPORT DistiAttribDict& operator=( const DistiAttribDict& dict )
800 {
801 CopyCommonValues( dict );
802 return *this;
803 }
804
805 /// Copies the values for all items which have matching names between this object and \a dict.
806 /// All other values are ignored.
807 /// \param dict The dictionary to copy from.
808 DISTI_EXPORT void CopyCommonValues( const DistiAttribDict& dict );
809
810 /// Equality operator
811 /// Compares length, names and values, order does not matter.
812 /// \param other The other dictionary to compare.
813 /// \return Whether or not the dictionaries are equivalent.
814 DISTI_EXPORT bool operator==( const DistiAttribDict& other );
815
816 /// Adds the specified Attribute to the list. The object passed in becomes the responsibility
817 /// of this class, and should NOT be deleted by the caller. It will be deleted by this class as needed.
818 /// \param attr The attribute to add.
819 DISTI_EXPORT void Add( DistiAttributeBase* attr );
820
821 /// \return A const iterator to the beginning of the list.
822 const_iterator Begin() const { return _list.begin(); }
823
824 /// \return A const iterator to the end of the list.
825 const_iterator End() const { return _list.end(); }
826
827 /// \return A iterator to the beginning of the list.
828 iterator Begin() { return _list.begin(); }
829
830 /// \return A iterator to the end of the list.
831 iterator End() { return _list.end(); }
832
833 /// \return The current number of elements in the dictionary.
834 int DISTI_EXPORT Count() const;
835
836 /// \param name The name of the element(s) to count up.
837 /// \return The number of elements with the same name in the dictionary.
838 int DISTI_EXPORT Count( const AttributeName& name ) const;
839
840 /** Removes all elements in the list, deleting the data as it goes */
841 void DISTI_EXPORT Clear();
842
843 /// Removes the attribute specified by name from the dictionary and deletes the data.
844 /// \param name The name of the attribute to remove.
845 /// \note This does actually delete the attribute.
846 DISTI_EXPORT void Delete( const AttributeName& name );
847
848 /// Reads a stream, expecting each line to be of the form: NAME: SomeStringValue
849 /// For each line a new DistiAttribute<std::string> is created, and the remaining line is placed as it's value.
850 /// This is intended for special uses and is not considered the 'normal' mode of operation.
851 /// \param instr The stream to read from.
852 DISTI_EXPORT void ReadStrings( std::istream& instr );
853
854 /// Writes all items in the dictionary to the stream in the form: "NAME: VALUE"
855 /// If changedDataOnly is true, only items which return ValueChanged() == true will be written.
856 /// \param outstr The stream to write to.
857 /// \param changedDataOnly Whether or not to only write items where ValueChanged() == true.
858 DISTI_EXPORT void Write( std::ostream& outstr, bool changedDataOnly = false );
859
860 /// Reads multiple attributes from the stream expecting the form: "NAME: VALUE"
861 /// \param instr The stream to read from.
862 /// \return True if something was found and set..
863 DISTI_EXPORT bool Read( std::istream& instr );
864
865 /// Reads multiple attributes from the stream expecting the form: "NAME: VALUE"
866 /// missing stream is filled with attributes that were not in the dictionary
867 /// \param instr The stream to read from.
868 /// \param missingStream The return stream to write attributes that were not found.
869 /// \return True if something was found and set.
870 DISTI_EXPORT bool ReadAndCaptureMissing( std::istream& instr, std::stringstream* missingStream );
871
872 /// \param name The name of the attribute whose value is to be returned.
873 /// \return The std::string value of the attribute specified by name, "" if not found.
874 /// \note Internally it uses ValueString() from the attribute
875 DISTI_EXPORT std::string ValueString( const AttributeName& name ) const;
876
877 /// Sets the attribute of named 'name' to the value of 'val'.
878 /// \param name The attribute name whose value is to be set.
879 /// \param val The string value to set.
880 /// \note If name is not found, there is no indication or error given.
881 DISTI_EXPORT void ValueString( const AttributeName& name, const std::string& val );
882
883 /// \param name The name of the attribute whose value is to be returned.
884 /// \return The ValueInt() of the named attribute.
885 DISTI_EXPORT long ValueInt( const AttributeName& name ) const;
886
887 /// Sets the ValueInt() of the named attribute.
888 /// \param name The attribute name whose value is to be set.
889 /// \param val The int value to set.
890 DISTI_EXPORT void ValueInt( const AttributeName& name, long val );
891
892 /// Calls WriteValue() for the attribute specified by name.
893 /// \param name The name of the attribute to write out.
894 /// \param outstr The stream to write to.
895 /// \return The stream that was written to, in its current state.
896 DISTI_EXPORT std::ostream& WriteValue( const AttributeName& name, std::ostream& outstr );
897
898 /// Calls ReadValue() for the attribute specified by name.
899 /// \param name The name of the attribute to read in.
900 /// \param instr The stream to read from.
901 /// \return The stream that was read from, in its current state.
902 DISTI_EXPORT std::istream& ReadValue( const AttributeName& name, std::istream& instr );
903
904 /// \param name The name of the attribute to return.
905 /// \return The DistiAttributeBase* for the specified name, if not found it returns NULL.
906 DISTI_EXPORT DistiAttributeBase* Get( const AttributeName& name ) const;
907
908 /// \param name The name of the attribute to compare.
909 /// \param val The value to compare the attribute value with.
910 /// \return A comparison of val with ValueInt() of the attribute looked up by name, false if not found.
911 DISTI_EXPORT bool IsEqual( const AttributeName& name, const long val ) const;
912
913 /** Static, data for formating output */
914 static DISTI_EXPORT int currentOutputSpacing; // Should be private
915
916 /** Static, Increments the current spacing */
917 static DISTI_EXPORT void SpacingInc();
918
919 /** Static, Decrements the current spacing */
920 static DISTI_EXPORT void SpacingDec();
921
922 /** Static, Sets the spacing to zero */
923 static DISTI_EXPORT void SpacingZero();
924
925 /// \note static
926 /// \return A string containing the current spacing.
927 static DISTI_EXPORT std::string SpacingString();
928
929 /// Static method used for parsing a stream.
930 /// Used internally and exposed here so others can use it.
931 /// \param instr The stream to read from.
932 /// \param result The returned string that was parsed.
933 /// \return True if parse was successful.
934 static DISTI_EXPORT bool ScanToken( std::istream& instr, std::string& result );
935
936 /// Removes the attribute specified by name.
937 /// \param name The name of the attribute to remove.
938 /// \note This does NOT actually delete the attribute, just removes it from the dictionary.
939 DISTI_EXPORT void Remove( const AttributeName& name );
940
941private:
942 List_t _list;
943 Map_t _map;
944
945 /** Disable copy construction.
946 * \note copy-assignment will also be disabled in the future.
947 * \sa CopyCommonValues(). */
949};
950
951/// Iterator interface for use in range-for loops etc.
952/// \param dict The DistiAttribDict whose iterator is to be returned.
953/// \return A const iterator to the beginning of the list.
954inline DistiAttribDict::const_iterator begin( const DistiAttribDict& dict ) { return dict.Begin(); }
955
956/// Iterator interface for use in range-for loops etc.
957/// \param dict The DistiAttribDict whose iterator is to be returned.
958/// \return A const iterator to the end of the list.
959inline DistiAttribDict::const_iterator end( const DistiAttribDict& dict ) { return dict.End(); }
960
961/// Iterator interface for use in range-for loops etc.
962/// \param dict The DistiAttribDict whose iterator is to be returned.
963/// \return An iterator to the beginning of the list.
964inline DistiAttribDict::iterator begin( DistiAttribDict& dict ) { return dict.Begin(); }
965
966/// Iterator interface for use in range-for loops etc.
967/// \param dict The DistiAttribDict whose iterator is to be returned.
968/// \return An iterator to the end of the list.
969inline DistiAttribDict::iterator end( DistiAttribDict& dict ) { return dict.End(); }
970
971////////////////////////////////////////////////////////////
972// Some useful derivations
973////////////////////////////////////////////////////////////
974
975/** \class DistiAttributeEnumStringPair
976 * A string to enumeration mapping
977 */
978typedef struct
979{
980 char _string[ 64 ]; ///< String value for enumeration.
981 int _enum; ///< Integer value for enumeration.
983
984/** A list of enumeration definitions */
985class DistiAttributeEnumDefList : public std::list<DistiAttributeEnumStringPair*>
986{
987public:
988 /// Create a new DistiAttributeEnumDefList object.
989 /// \param stringVal The first string value of the list.
990 DISTI_EXPORT DistiAttributeEnumDefList( char* stringVal, ... );
991
992 /// Return the associated integer value with the enumeration string
993 /// \param string The string whose enum value is to be returned.
994 /// \return The enumeration value, 0 if the string isn't present in the list.
995 virtual DISTI_EXPORT int EnumToInt( const std::string& string );
996
997 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
998};
999
1000/** \class DistiAttributeEnum
1001 * A Disti Attribute which reads and writes enumerations.
1002 */
1003template<class containerClass, class setType, class getType>
1005{
1006public:
1007 typedef void ( containerClass::*SetMethodType )( setType ); ///< Typedef for the set method function pointer.
1008 typedef getType ( containerClass::*GetMethodType )(); ///< Typedef for the get method function pointer.
1009
1010 DistiAttributeEnumDefList* _pairList; ///< A list of name value pairs describing the enumeration.
1011 containerClass* _object; ///< Object that contains the attribute.
1012
1013 SetMethodType _setMethod; ///< Set method member function pointer.
1014 GetMethodType _getMethod; ///< Get method member function pointer.
1015
1016 /// Create a new DistiAttributeEnum object, able to convert string and int enum values between one another.
1017 /// \param object The object containing the enumeration.
1018 /// \param setMethod The set method pointer for the property.
1019 /// \param getMethod The get method pointer for the property.
1020 /// \param name The name of the attribute to contain the enumeration.
1021 DistiAttributeEnum( containerClass* object, SetMethodType setMethod, GetMethodType getMethod, const AttributeName& name )
1022 : DistiAttributeBase( NULL, name, false )
1023 , _object( object )
1024 , _setMethod( setMethod )
1025 , _getMethod( getMethod )
1026 {
1027 GLS_ASSERT( setMethod );
1028 GLS_ASSERT( getMethod );
1029 }
1030
1031 virtual ~DistiAttributeEnum()
1032 {
1033 }
1034
1035 /// \return The integer value via the underlying get method.
1037 {
1038 return (long)( _object->*_getMethod )();
1039 }
1040
1041 /// Set the integer value via the underlying set method.
1042 /// \param val The new integer value to set.
1043 virtual void ValueInt( long val ) DISTI_METHOD_OVERRIDE
1044 {
1045 ( _object->*_setMethod )( (setType)val );
1046 };
1047
1048 /// Assignment operator.
1049 /// \param oldClass The attribute to assign to.
1050 /// \return The resulting attribute (this).
1052 {
1054 if( ptr )
1055 {
1056 ValueInt( ptr->ValueInt() );
1057 }
1058 else
1059 {
1060 return DistiAttributeBase::operator=( oldClass );
1061 }
1062 return *this;
1063 }
1064
1065 /// Write this attribute's string value to the stream.
1066 /// \param outstr The stream to write to.
1067 /// \return The stream in its updated state.
1068 virtual std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
1069 {
1070 bool foundIt = false;
1071 getType value = ( _object->*_getMethod )();
1072 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1073 while( item != _pairList->end() && *item )
1074 {
1075 if( ( *item )->_enum == value )
1076 {
1077 outstr << ( *item )->_string;
1078 foundIt = true;
1079 break;
1080 }
1081 ++item;
1082 }
1083 if( !foundIt )
1084 {
1085 //Didn't find it so just write the number
1086 outstr << value;
1087 }
1088 return outstr;
1089 }
1090
1091 /// Return the associated integer value with the enumeration string.
1092 /// \param string The string whose enum value is to be returned.
1093 /// \return The enumeration value, 0 if the string isn't present in the list.
1094 int EnumToInt( std::string& string )
1095 {
1096 int returnVal = 0;
1097 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1098
1099 while( item != _pairList->end() && *item )
1100 {
1101 if( strcmp( ( *item )->_string, string.c_str() ) == 0 )
1102 {
1103 returnVal = ( *item )->_enum;
1104 break;
1105 }
1106 ++item;
1107 }
1108 return returnVal;
1109 }
1110
1111 /// Read from the stream, and store it in this attribute.
1112 /// \param instr The stream to read from.
1113 /// \return The stream in its updated state.
1114 virtual std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
1115 {
1116 char value[ 64 ];
1117 instr >> value;
1118
1119 bool foundIt = false;
1120 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1121
1122 // First look by enumeration
1123 while( item != _pairList->end() && *item )
1124 {
1125 if( strcmp( ( *item )->_string, value ) == 0 )
1126 {
1127 ( _object->*_setMethod )( (setType)( *item )->_enum );
1128
1129 foundIt = true;
1130 break;
1131 }
1132 ++item;
1133 }
1134
1135 // If not found, assume that the numerical value is specified.
1136 if( !foundIt )
1137 {
1138 ( _object->*_setMethod )( (setType)atoi( value ) );
1139 }
1140 return instr;
1141 }
1142};
1143
1144} // namespace disti
1145
1146#if defined( WIN32 )
1147# pragma warning( pop )
1148#endif
1149
1150#endif
Definition: disti_metadata.h:514
virtual void NotifyAttributeChanged(const AttributeName &name)=0
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:522
Definition: disti_metadata.h:417
AttributeMethodCallback(T *object, Callback method)
Definition: disti_metadata.h:424
WeakRef< T > _object
The underlying object containing the callback method.
Definition: disti_metadata.h:447
Callback _method
Method to call back when invoked.
Definition: disti_metadata.h:446
virtual bool IsValid() const override
Definition: disti_metadata.h:440
void(T::* Callback)(DistiAttributeBase &attr)
Typedef for the callback function pointer.
Definition: disti_metadata.h:419
void Call(DistiAttributeBase &ev) override
Definition: disti_metadata.h:432
Definition: disti_metadata.h:87
AttributeName & operator=(const AttributeName &other)
Definition: disti_metadata.h:117
AttributeName(const AttributeName &other)
Definition: disti_metadata.h:108
long StringIndex() const
Definition: disti_metadata.h:125
AttributeName(const std::string &name)
Definition: disti_metadata.h:201
virtual void Call(DistiAttributeBase &attr)=0
virtual bool IsValid() const =0
Definition: disti_metadata.h:467
WeakRef< T > _object
The object containing the attribute.
Definition: disti_metadata.h:497
AttributeName _attributeName
The attribute to set when invoked.
Definition: disti_metadata.h:496
virtual bool IsValid() const override
Definition: disti_metadata.h:490
void Call(DistiAttributeBase &attr) override
Definition: disti_metadata.h:479
AttributeResourceCallback(T *object, const AttributeName &attributeName)
Definition: disti_metadata.h:472
Definition: callback_caller_base.h:56
Definition: disti_metadata.h:734
static bool ScanToken(std::istream &instr, std::string &result)
static void SpacingInc()
bool Read(std::istream &instr)
List_t::const_iterator const_iterator
Shorthand for List_t::const_iterator.
Definition: disti_metadata.h:742
std::multimap< long, Attr_t > Map_t
Typedef for a map ot attribute pointers.
Definition: disti_metadata.h:740
static long _currentFileVersionSecondary
Definition: disti_metadata.h:791
static void SpacingDec()
iterator Begin()
Definition: disti_metadata.h:828
bool IsEqual(const AttributeName &name, const long val) const
void CopyCommonValues(const DistiAttribDict &dict)
void Write(std::ostream &outstr, bool changedDataOnly=false)
iterator End()
Definition: disti_metadata.h:831
std::istream & ReadValue(const AttributeName &name, std::istream &instr)
List_t::iterator iterator
Shorthand for List_t::iterator.
Definition: disti_metadata.h:743
DistiAttribDict & operator=(DistiAttribDict &&other)
Definition: disti_metadata.h:762
static unsigned int _currentFileVersionMinor
Definition: disti_metadata.h:784
DistiAttributeBase * Get(const AttributeName &name) const
std::list< Attr_t > List_t
Typedef for a list of attribute pointers.
Definition: disti_metadata.h:739
std::string ValueString(const AttributeName &name) const
void Add(DistiAttributeBase *attr)
const_iterator End() const
Definition: disti_metadata.h:825
DistiAttributeBase * Attr_t
Definition: disti_metadata.h:737
void ReadStrings(std::istream &instr)
static void SpacingZero()
void Remove(const AttributeName &name)
long ValueInt(const AttributeName &name) const
std::ostream & WriteValue(const AttributeName &name, std::ostream &outstr)
static unsigned int _currentFileVersionMajor
Definition: disti_metadata.h:782
static int currentOutputSpacing
Definition: disti_metadata.h:914
bool ReadAndCaptureMissing(std::istream &instr, std::stringstream *missingStream)
static unsigned int _currentFileVersionBuild
Definition: disti_metadata.h:786
const_iterator Begin() const
Definition: disti_metadata.h:822
static double _currentFileVersionPrimary
Definition: disti_metadata.h:789
static std::string SpacingString()
bool operator==(const DistiAttribDict &other)
void Delete(const AttributeName &name)
Definition: disti_metadata.h:220
virtual bool ValueChanged()
bool _localStorage
Definition: disti_metadata.h:237
const AttributeName & Name() const
virtual double ValueFloat()
virtual void NotifyObservers()
virtual CallbackID RegisterObserver(AttributeObserver *observer)
virtual std::string ValueString()
ScopedPtr< DistiAttributeObserverList > _observerList
Definition: disti_metadata.h:231
virtual bool operator==(const DistiAttributeBase &r)
CallbackMethodCallerBase * _callback
Definition: disti_metadata.h:228
virtual std::ostream & WriteValue(std::ostream &outstr)=0
virtual bool OkToWrite() const
virtual void CallCallback()
Calls callback CallType3 if it has been set.
virtual void ResetValueChanged()
virtual bool Copyable() const
virtual void UnregisterObserver(CallbackID id)
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:371
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:355
AttributeName _name
Definition: disti_metadata.h:226
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
virtual std::istream & ReadValue(std::istream &instr)=0
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:394
Definition: disti_metadata.h:986
DistiAttributeEnumDefList(char *stringVal,...)
virtual int EnumToInt(const std::string &string)
Definition: disti_metadata.h:1005
DistiAttributeEnum(containerClass *object, SetMethodType setMethod, GetMethodType getMethod, const AttributeName &name)
Definition: disti_metadata.h:1021
virtual void ValueInt(long val) override
Definition: disti_metadata.h:1043
void(containerClass::* SetMethodType)(setType)
Typedef for the set method function pointer.
Definition: disti_metadata.h:1007
GetMethodType _getMethod
Get method member function pointer.
Definition: disti_metadata.h:1014
int EnumToInt(std::string &string)
Definition: disti_metadata.h:1094
DistiAttributeEnumDefList * _pairList
A list of name value pairs describing the enumeration.
Definition: disti_metadata.h:1010
SetMethodType _setMethod
Set method member function pointer.
Definition: disti_metadata.h:1013
getType(containerClass::* GetMethodType)()
Typedef for the get method function pointer.
Definition: disti_metadata.h:1008
virtual std::istream & ReadValue(std::istream &instr) override
Definition: disti_metadata.h:1114
virtual long ValueInt() override
Definition: disti_metadata.h:1036
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass) override
Definition: disti_metadata.h:1051
containerClass * _object
Object that contains the attribute.
Definition: disti_metadata.h:1011
virtual std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:1068
Definition: disti_metadata.h:547
void ValueFloat(double val) override
Definition: disti_metadata.h:607
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:562
T * _attribPtr
Definition: disti_metadata.h:550
virtual T Value()
Definition: disti_metadata.h:654
std::istream & ReadValue(std::istream &instr) override
Definition: disti_metadata.h:647
std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:634
long ValueInt() override
Definition: disti_metadata.h:587
DistiAttributeBase & operator=(const DistiAttributeBase &oldClass) override
Definition: disti_metadata.h:615
void ValueInt(long val) override
Definition: disti_metadata.h:594
~DistiAttribute() override
Definition: disti_metadata.h:685
bool operator==(const DistiAttributeBase &rArg) override
Definition: disti_metadata.h:671
bool Copyable() const override
Definition: disti_metadata.h:584
virtual void Value(const T &val)
Definition: disti_metadata.h:661
int _precision
Definition: disti_metadata.h:552
double ValueFloat() override
Definition: disti_metadata.h:600
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, const T &initialValue)
Definition: disti_metadata.h:576
Definition: weak_reference.h:92
Definition: weak_referenceable_mixin.h:53
#define GLS_ASSERT(exp)
Definition: disti_assert.h:150
#define GLS_VERIFY(exp)
Definition: disti_assert.h:170
A file for all GL Studio files to include.
#define IF_GLS_DEBUG_ATTRIBUTE_NAMES(x)
Macro to exclude attribute name debug code when not used.
Definition: disti_metadata.h:73
The disti::DynamicArray class. A templated array of objects capable of dynamically growing.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_IF_HAS_USER_DEFINED_LITERAL(x)
Macro to wrap user defined literals, removed on compilers that don't support them.
Definition: gls_cpp_lang_support.h:247
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_FINAL
Macro to wrap the final keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:216
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
#define DISTI_FUNC_NOEXCEPT
Macro to wrap the noexcept keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:229
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
DistiAttribDict::const_iterator begin(const DistiAttribDict &dict)
Definition: disti_metadata.h:954
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
bool operator!=(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:165
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:455
bool operator==(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:154
void SetAndNotifyIfChanged(AttributeChangedNotifier *object, T &property, const T &newValue, const AttributeName &name)
Definition: disti_metadata.h:532
DistiAttribDict::const_iterator end(const DistiAttribDict &dict)
Definition: disti_metadata.h:959
const int MAX_ATTRIBUTE_NAME_LENGTH
Unused, remains for backward compatibility.
Definition: disti_metadata.h:79
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:505
A smart pointer with unique ownership – poor man's std::unique_ptr.
Definition: disti_metadata.h:979
int _enum
Integer value for enumeration.
Definition: disti_metadata.h:981
Definition: gls_cpp_lang_support.h:468
The DistiUnhideGlobalsDummyClass class.
weak reference and related classes
weak reference and related classes