GL Studio C++ Runtime API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 /// This method isn't pure virtual to maintain backward compatibility with existing user code.
344 /// \return The unmangled type name of the underlying storage.
345 virtual std::string Type() const
346 {
347 return "";
348 }
349
350 /// Compares name and value.
351 /// \note This can be overriden to improve speed.
352 /// \param r The attribute to compare.
353 /// \return Whether or not the attributes have the same name and value.
354 virtual DISTI_EXPORT bool operator==( const DistiAttributeBase& r );
355
356 /// Allow for generic access to some data types.
357 /// This will NOT work for types which: s << val does not work.
358 /// In general if the WriteValue is overridden, then it probably will not work.
359 /// \param val The new value to set.
360 /// \return The updated attribute (this).
361 template<class valType>
362 DistiAttributeBase& operator<<( const valType& val )
363 {
364 std::stringstream s;
365 // Ensure numeric values make it into the attribute's ReadValue implementation unmodified.
366 s.precision( MaxDigits10<long double>::value );
367 s << val;
368 ReadValue( s );
369 return *this;
370 }
371
372 /// Allows for generic access to some data types.
373 /// This will NOT work for types which: s >> val does not work.
374 /// In general if the ReadValue is overridden, then it probably will not work.
375 /// \param val The value to be returned.
376 /// \return This attribute (unmodified, unless there are side effects).
377 template<class valType>
379 {
380 std::stringstream s;
381 WriteValue( s );
382 s >> val;
383 return *this;
384 }
385
386 /// Stream out operator.
387 /// \note Internally it uses WriteValue().
388 /// \param outstr Stream to write path to.
389 /// \param attribute The value to write to the stream.
390 /// \return The stream in its current state.
391 friend DISTI_EXPORT std::ostream& operator<<( std::ostream& outstr, const DistiAttributeBase& attribute );
392
393 /// Stream in operator.
394 /// \note Internally it uses ReadValue().
395 /// \param instr The stream to read from.
396 /// \param attribute The returned value read from the stream.
397 /// \return The stream in its current state.
398 friend DISTI_EXPORT std::istream& operator>>( std::istream& instr, DistiAttributeBase& attribute );
399
400 /// Type for unique identifiers
401 typedef unsigned int CallbackID;
402
403 /** 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.
404 * DistiAttributeBase takes ownership of the observer and will delete it.
405 * \param observer the observer to notify. It is automatically unregistered and destroyed when it becomes invalid.
406 * \return an id that can be used to unregister the observer
407 */
408 virtual DISTI_EXPORT CallbackID RegisterObserver( AttributeObserver* observer );
409
410 /** Unregister an observer
411 * \param id the id returned when the observer was registered
412 */
413 virtual DISTI_EXPORT void UnregisterObserver( CallbackID id );
414
415 /** Triggers all observers to have their callbacks called. Typically called by the class that owns the DistiAttributeBase */
416 virtual DISTI_EXPORT void NotifyObservers();
417};
418
419/** Template for an AttributeCallbackBase that will call a class method whenever the attribute changes. The class must implement WeakReferenceable.
420 * Don't use this directly, use CreateAttributeMethodCallback instead.
421 */
422template<class T>
424{
425public:
426 typedef void ( T::*Callback )( DistiAttributeBase& attr ); ///< Typedef for the callback function pointer.
427
428 /// Construct a new AttributeMethodCallback object to link the callback and the class containing it.
429 /// \param object The object containing the callback method.
430 /// \param method The method to call back.
432 : _method( method )
433 , _object( object )
434 {
435 GLS_VERIFY( NULL != method );
436 GLS_VERIFY( NULL != object );
437 }
438
440 {
441 if( IsValid() )
442 {
443 ( _object.Get()->*( _method ) )( ev );
444 }
445 }
446
447 virtual bool IsValid() const DISTI_METHOD_OVERRIDE
448 {
449 return !_object.IsNull();
450 }
451
452protected:
453 Callback _method; ///< Method to call back when invoked.
454 WeakRef<T> _object; ///< The underlying object containing the callback method.
455};
456
457/// Create an AttributeMethodCallback that will call a class method whenever the attribute changes.
458/// \param obj The object to call the method on.
459/// \param method A class method pointer.
460/// \return The created AttributeMethodCallback.
461template<class Class>
463 Class* const obj,
464 const typename AttributeMethodCallback<Class>::Callback method )
465{
466 return new AttributeMethodCallback<Class>( obj, method );
467}
468
469/** Template for an AttributeCallbackBase that will set another object's attribute whenever the attribute changes. The class must implement WeakReferenceable.
470 * Don't use this directly, use CreateAttributeResourceCallback instead.
471 */
472template<class T>
474{
475public:
476 /// Construct a new AttributeResourceCallback object to link an attribute to an attribute of another object.
477 /// \param object The object containing the attribute.
478 /// \param attributeName The attribute to set.
479 AttributeResourceCallback( T* object, const AttributeName& attributeName )
480 : _attributeName( attributeName )
481 , _object( object )
482 {
483 GLS_VERIFY( NULL != object );
484 }
485
487 {
488 if( IsValid() )
489 {
490 if( DistiAttributeBase* objAttr = _object.Get()->Attributes().Get( _attributeName ) )
491 {
492 ( *objAttr ) << attr.ValueString();
493 }
494 }
495 }
496
497 virtual bool IsValid() const DISTI_METHOD_OVERRIDE
498 {
499 return !_object.IsNull();
500 }
501
502protected:
503 AttributeName _attributeName; ///< The attribute to set when invoked.
504 WeakRef<T> _object; ///< The object containing the attribute.
505};
506
507/// Create an CreateAttributeResourceCallback that will set another object's attribute whenever the attribute changes.
508/// \param obj The object to set the resource on.
509/// \param attributeName The name of the property.
510/// \return The created CreateAttributeResourceCallback.
511template<class Class>
513 Class* const obj,
514 const char* attributeName )
515{
516 return new AttributeResourceCallback<Class>( obj, AttributeName( attributeName ) );
517}
518
519/** Interface for notifying when attributes have changed */
521{
522public:
523 /** Notify the class that the attribute has changed. Observers of the attribute will have their callbacks called
524 * \param name the name of the attribute
525 */
526 virtual DISTI_EXPORT void NotifyAttributeChanged( const AttributeName& name ) = 0;
527
528 /** destructor */
530};
531
532/** helper method to notify if an attribute has changed through a setter method
533 * \param object the object to notify
534 * \param property the storage for the data that is going to be set
535 * \param newValue the new value to set
536 * \param name the attribute name
537 */
538template<class T>
539void SetAndNotifyIfChanged( AttributeChangedNotifier* object, T& property, const T& newValue, const AttributeName& name )
540{
541 if( newValue != property )
542 {
543 property = newValue;
544 object->NotifyAttributeChanged( name );
545 }
546}
547
548/** \class DistiAttribute
549 * A templated class for creating attributes.
550 */
551class DistiAttribDict;
552template<class T>
554{
555protected:
556 /** Points to the actual storage */
558 /** Allows for setting of precision for floating point numbers */
560
561public:
562 /** Constructor
563 * Keeps a pointer to the specified type
564 * \param callback The method to call when the value changes. A duplicate of the
565 * CallbackMethodCallerBase is created and stored internally.
566 * \param name The name of the attribute
567 * \param attribPtr The address of the storage.
568 */
569 DistiAttribute( CallbackMethodCallerBase* callback, const AttributeName& name, T* attribPtr )
570 : DistiAttributeBase( callback, name, false )
571 , _attribPtr( attribPtr )
572 , _precision( MaxDigits10<T>::value )
573 {
574 }
575
576 /** Constructor
577 * Actually creates storage of the specified type
578 * \param callback The method to call when the value changes. A duplicate of the
579 * CallbackMethodCallerBase is created and stored internally.
580 * \param name The name of the attribute
581 * \param initialValue The initial value of the internally stored variable.
582 */
583 DistiAttribute( CallbackMethodCallerBase* callback, const AttributeName& name, const T& initialValue )
584 : DistiAttributeBase( callback, name, true /*Because we actually have storage*/ )
585 , _attribPtr( new T( initialValue ) )
586 , _precision( MaxDigits10<T>::value )
587 {
588 }
589
590 /// \return Whether or not this attribute is copyable (which it is).
591 bool Copyable() const DISTI_METHOD_OVERRIDE { return true; }
592
593 /// \return The integer value of this attribute.
595 {
597 }
598
599 /// Set the integer value of this attribute.
600 /// \param val The integer value to set for this attribute.
602 {
604 }
605
606 /// \return The double value of this attribute.
608 {
610 }
611
612 /// Set the double value for this attribute.
613 /// \param val The double value to set for this attribute.
615 {
617 }
618
619 /// Assignment operator
620 /// \param oldClass The attribute to assign.
621 /// \return The resulting attribute (this).
623 {
624 DistiAttribute* ptr;
625
626 ptr = dynamic_cast<DistiAttribute*>( const_cast<DistiAttributeBase*>( &oldClass ) );
627 if( ptr )
628 {
629 Value( ptr->Value() );
630 }
631 else
632 {
633 return DistiAttributeBase::operator=( oldClass );
634 }
635 return *this;
636 }
637
638 /// Write this attribute's string value to the stream.
639 /// \param outstr The stream to write to.
640 /// \return The stream in its updated state.
641 std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
642 {
643 if( _precision > 0 )
644 outstr.precision( _precision );
645
646 //operator<<(outstr, *_attribPtr);
647 outstr << *_attribPtr;
648 return outstr;
649 };
650
651 /// Read from the stream, and store it in this attribute.
652 /// \param instr The stream to read from.
653 /// \return The stream in its updated state.
654 std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
655 {
656 return ReadValueImpl( instr );
657 };
658
659 /// Demangles type T.
660 /// \return String containing new name for type T.
661 /// \pre none
662 /// \post none
663 std::string Type() const DISTI_METHOD_OVERRIDE
664 {
665 return Demangle<T>();
666 }
667
668 /// Allows for type specific access to the data.
669 /// \return The underlying value of the attribute in its type.
670 virtual T Value()
671 {
672 return *_attribPtr;
673 }
674
675 /// Allows for type specific access to the data.
676 /// \param val The value to set in the attribute's type.
677 virtual void Value( const T& val )
678 {
679 *_attribPtr = val;
680 CallCallback();
681 }
682
683 /// Performs type specific comparison.
684 /// This results in faster comparisons than the base class
685 /// \param rArg The attribute to compare.
686 /// \return Whether or not the attribute names and values are the same.
688 {
689 DistiAttribute<T>* r = dynamic_cast<DistiAttribute<T>*>( const_cast<DistiAttributeBase*>( &rArg ) );
690 if( !r )
691 return false;
692
693 if( !( _name == r->_name ) )
694 return false;
695
696 return Value() == r->Value();
697 }
698
699 /** Destructor
700 * deletes local storage if we created it */
702 {
703 // Only delete it if we created it.
704 if( _localStorage )
705 {
706 delete _attribPtr;
707 }
708 _attribPtr = NULL;
709 }
710
711private:
712 std::istream& ReadValueImpl( std::istream& instr )
713 {
715 instr >> *_attribPtr;
716 CallCallback();
717
718 return instr;
719 }
720};
721
722/** Optimized ReadValueImpl for floating point types.
723 * Visual Studio 2012 (vc110) runtime performs much slower when using
724 * std::istream::operator>>( float& val )
725 */
726template<>
727inline std::istream& DistiAttribute<float>::ReadValueImpl( std::istream& instr )
728{
729 char instrBuf[ 64 ];
730 instr >> instrBuf;
731 *_attribPtr = static_cast<float>( atof( instrBuf ) );
732 CallCallback();
733
734 return instr;
735}
736
737template<>
738inline std::istream& DistiAttribute<double>::ReadValueImpl( std::istream& instr )
739{
740 char instrBuf[ 64 ];
741 instr >> instrBuf;
742 *_attribPtr = atof( instrBuf );
743 CallCallback();
744
745 return instr;
746}
747
748/** The Attribute Dictionary is a container for DistiAttributeBase derived objects */
750{
751public:
752 /** Allows for easy access to the contained class type */
754
755 typedef std::list<Attr_t> List_t; ///< Typedef for a list of attribute pointers.
756 typedef std::multimap<long, Attr_t> Map_t; ///< Typedef for a map ot attribute pointers.
757
758 typedef List_t::const_iterator const_iterator; ///< Shorthand for List_t::const_iterator.
759 typedef List_t::iterator iterator; ///< Shorthand for List_t::iterator.
760
761 /** Constructor */
762 DISTI_EXPORT DistiAttribDict();
763
764 /** Destructor */
765 DISTI_EXPORT ~DistiAttribDict();
766
767#if defined( DISTI_HAS_RVAL_REFS )
768 /// Move constructor
769 /// \param other The object to move.
770 DISTI_EXPORT DistiAttribDict( DistiAttribDict&& other )
771 {
772 *this = std::move( other );
773 }
774
775 /// Move Assignment
776 /// \param other The object to move.
777 /// \return This object, post move.
779 {
780 if( this != &other )
781 {
782 _list = std::move( other._list );
783 _map = std::move( other._map );
784 }
785 return *this;
786 }
787#endif
788
789 /** Used as needed for version specific parsing
790 * Whenever a version is parsed, the results should be stored here.
791 * This does add order dependency.
792 *
793 * Note: These are not set or used by the DistiAttribDict class
794 * they are here to be set and accessed by the derived Attributes.
795 * Since they are shared by all instances of DistiAttribDict, they
796 * are only valid while the dictionary is parsing a file.
797 */
798 static DISTI_EXPORT unsigned int _currentFileVersionMajor;
799 /** \sa _currentFileVersionMajor */
800 static DISTI_EXPORT unsigned int _currentFileVersionMinor;
801 /** \sa _currentFileVersionMajor */
802 static DISTI_EXPORT unsigned int _currentFileVersionBuild;
803
804 /** \deprecated Do not use. Will be removed in a later version. */
805 static DISTI_EXPORT double _currentFileVersionPrimary;
806 /** \deprecated Do not use. Will be removed in a later version. */
807 static DISTI_EXPORT long _currentFileVersionSecondary;
808
809 /// Copies the values for all items which have matching names between this object and \a dict.
810 /// All other values are ignored.
811 /// \param dict The dictionary to copy from.
812 /// \return The combined dictionary (this).
813 /// \deprecated Use CopyCommonValues() instead.
814 DISTI_DEPRECATED( "Renamed to CopyCommonValues() to better represent the action taken by this function." )
815 DISTI_EXPORT DistiAttribDict& operator=( const DistiAttribDict& dict )
816 {
817 CopyCommonValues( dict );
818 return *this;
819 }
820
821 /// Copies the values for all items which have matching names between this object and \a dict.
822 /// All other values are ignored.
823 /// \param dict The dictionary to copy from.
824 DISTI_EXPORT void CopyCommonValues( const DistiAttribDict& dict );
825
826 /// Equality operator
827 /// Compares length, names and values, order does not matter.
828 /// \param other The other dictionary to compare.
829 /// \return Whether or not the dictionaries are equivalent.
830 DISTI_EXPORT bool operator==( const DistiAttribDict& other );
831
832 /// Adds the specified Attribute to the list. The object passed in becomes the responsibility
833 /// of this class, and should NOT be deleted by the caller. It will be deleted by this class as needed.
834 /// \param attr The attribute to add.
835 DISTI_EXPORT void Add( DistiAttributeBase* attr );
836
837 /// \return A const iterator to the beginning of the list.
838 const_iterator Begin() const { return _list.begin(); }
839
840 /// \return A const iterator to the end of the list.
841 const_iterator End() const { return _list.end(); }
842
843 /// \return A iterator to the beginning of the list.
844 iterator Begin() { return _list.begin(); }
845
846 /// \return A iterator to the end of the list.
847 iterator End() { return _list.end(); }
848
849 /// \return The current number of elements in the dictionary.
850 int DISTI_EXPORT Count() const;
851
852 /// \param name The name of the element(s) to count up.
853 /// \return The number of elements with the same name in the dictionary.
854 int DISTI_EXPORT Count( const AttributeName& name ) const;
855
856 /** Removes all elements in the list, deleting the data as it goes */
857 void DISTI_EXPORT Clear();
858
859 /// Removes the attribute specified by name from the dictionary and deletes the data.
860 /// \param name The name of the attribute to remove.
861 /// \note This does actually delete the attribute.
862 DISTI_EXPORT void Delete( const AttributeName& name );
863
864 /// Reads a stream, expecting each line to be of the form: NAME: SomeStringValue
865 /// For each line a new DistiAttribute<std::string> is created, and the remaining line is placed as it's value.
866 /// This is intended for special uses and is not considered the 'normal' mode of operation.
867 /// \param instr The stream to read from.
868 DISTI_EXPORT void ReadStrings( std::istream& instr );
869
870 /// Writes all items in the dictionary to the stream in the form: "NAME: VALUE"
871 /// If changedDataOnly is true, only items which return ValueChanged() == true will be written.
872 /// \param outstr The stream to write to.
873 /// \param changedDataOnly Whether or not to only write items where ValueChanged() == true.
874 DISTI_EXPORT void Write( std::ostream& outstr, bool changedDataOnly = false );
875
876 /// Reads multiple attributes from the stream expecting the form: "NAME: VALUE"
877 /// \param instr The stream to read from.
878 /// \return True if something was found and set..
879 DISTI_EXPORT bool Read( std::istream& instr );
880
881 /// Reads multiple attributes from the stream expecting the form: "NAME: VALUE"
882 /// missing stream is filled with attributes that were not in the dictionary
883 /// \param instr The stream to read from.
884 /// \param missingStream The return stream to write attributes that were not found.
885 /// \return True if something was found and set.
886 DISTI_EXPORT bool ReadAndCaptureMissing( std::istream& instr, std::stringstream* missingStream );
887
888 /// \param name The name of the attribute whose value is to be returned.
889 /// \return The std::string value of the attribute specified by name, "" if not found.
890 /// \note Internally it uses ValueString() from the attribute
891 DISTI_EXPORT std::string ValueString( const AttributeName& name ) const;
892
893 /// Sets the attribute of named 'name' to the value of 'val'.
894 /// \param name The attribute name whose value is to be set.
895 /// \param val The string value to set.
896 /// \note If name is not found, there is no indication or error given.
897 DISTI_EXPORT void ValueString( const AttributeName& name, const std::string& val );
898
899 /// \param name The name of the attribute whose value is to be returned.
900 /// \return The ValueInt() of the named attribute.
901 DISTI_EXPORT long ValueInt( const AttributeName& name ) const;
902
903 /// Sets the ValueInt() of the named attribute.
904 /// \param name The attribute name whose value is to be set.
905 /// \param val The int value to set.
906 DISTI_EXPORT void ValueInt( const AttributeName& name, long val );
907
908 /// Calls WriteValue() for the attribute specified by name.
909 /// \param name The name of the attribute to write out.
910 /// \param outstr The stream to write to.
911 /// \return The stream that was written to, in its current state.
912 DISTI_EXPORT std::ostream& WriteValue( const AttributeName& name, std::ostream& outstr );
913
914 /// Calls ReadValue() for the attribute specified by name.
915 /// \param name The name of the attribute to read in.
916 /// \param instr The stream to read from.
917 /// \return The stream that was read from, in its current state.
918 DISTI_EXPORT std::istream& ReadValue( const AttributeName& name, std::istream& instr );
919
920 /// \param name The name of the attribute to return.
921 /// \return The DistiAttributeBase* for the specified name, if not found it returns NULL.
922 DISTI_EXPORT DistiAttributeBase* Get( const AttributeName& name ) const;
923
924 /// \param name The name of the attribute to compare.
925 /// \param val The value to compare the attribute value with.
926 /// \return A comparison of val with ValueInt() of the attribute looked up by name, false if not found.
927 DISTI_EXPORT bool IsEqual( const AttributeName& name, const long val ) const;
928
929 /** Static, data for formating output */
930 static DISTI_EXPORT int currentOutputSpacing; // Should be private
931
932 /** Static, Increments the current spacing */
933 static DISTI_EXPORT void SpacingInc();
934
935 /** Static, Decrements the current spacing */
936 static DISTI_EXPORT void SpacingDec();
937
938 /** Static, Sets the spacing to zero */
939 static DISTI_EXPORT void SpacingZero();
940
941 /// \note static
942 /// \return A string containing the current spacing.
943 static DISTI_EXPORT std::string SpacingString();
944
945 /// Static method used for parsing a stream.
946 /// Used internally and exposed here so others can use it.
947 /// \param instr The stream to read from.
948 /// \param result The returned string that was parsed.
949 /// \return True if parse was successful.
950 static DISTI_EXPORT bool ScanToken( std::istream& instr, std::string& result );
951
952 /// Removes the attribute specified by name.
953 /// \param name The name of the attribute to remove.
954 /// \note This does NOT actually delete the attribute, just removes it from the dictionary.
955 DISTI_EXPORT void Remove( const AttributeName& name );
956
957private:
958 List_t _list;
959 Map_t _map;
960
961 /** Disable copy construction.
962 * \note copy-assignment will also be disabled in the future.
963 * \sa CopyCommonValues(). */
965};
966
967/// Iterator interface for use in range-for loops etc.
968/// \param dict The DistiAttribDict whose iterator is to be returned.
969/// \return A const iterator to the beginning of the list.
970inline DistiAttribDict::const_iterator begin( const DistiAttribDict& dict ) { return dict.Begin(); }
971
972/// Iterator interface for use in range-for loops etc.
973/// \param dict The DistiAttribDict whose iterator is to be returned.
974/// \return A const iterator to the end of the list.
975inline DistiAttribDict::const_iterator end( const DistiAttribDict& dict ) { return dict.End(); }
976
977/// Iterator interface for use in range-for loops etc.
978/// \param dict The DistiAttribDict whose iterator is to be returned.
979/// \return An iterator to the beginning of the list.
980inline DistiAttribDict::iterator begin( DistiAttribDict& dict ) { return dict.Begin(); }
981
982/// Iterator interface for use in range-for loops etc.
983/// \param dict The DistiAttribDict whose iterator is to be returned.
984/// \return An iterator to the end of the list.
985inline DistiAttribDict::iterator end( DistiAttribDict& dict ) { return dict.End(); }
986
987////////////////////////////////////////////////////////////
988// Some useful derivations
989////////////////////////////////////////////////////////////
990
991/** \class DistiAttributeEnumStringPair
992 * A string to enumeration mapping
993 */
994typedef struct
995{
996 char _string[ 64 ]; ///< String value for enumeration.
997 int _enum; ///< Integer value for enumeration.
999
1000/** A list of enumeration definitions */
1001class DistiAttributeEnumDefList : public std::list<DistiAttributeEnumStringPair*>
1002{
1003public:
1004 /// Create a new DistiAttributeEnumDefList object.
1005 /// \param stringVal The first string value of the list.
1006 DISTI_EXPORT DistiAttributeEnumDefList( char* stringVal, ... );
1007
1008 /// Return the associated integer value with the enumeration string
1009 /// \param string The string whose enum value is to be returned.
1010 /// \return The enumeration value, 0 if the string isn't present in the list.
1011 virtual DISTI_EXPORT int EnumToInt( const std::string& string );
1012
1013 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
1014};
1015
1016/** \class DistiAttributeEnum
1017 * A Disti Attribute which reads and writes enumerations.
1018 */
1019template<class containerClass, class setType, class getType>
1021{
1022public:
1023 typedef void ( containerClass::*SetMethodType )( setType ); ///< Typedef for the set method function pointer.
1024 typedef getType ( containerClass::*GetMethodType )(); ///< Typedef for the get method function pointer.
1025
1026 DistiAttributeEnumDefList* _pairList; ///< A list of name value pairs describing the enumeration.
1027 containerClass* _object; ///< Object that contains the attribute.
1028
1029 SetMethodType _setMethod; ///< Set method member function pointer.
1030 GetMethodType _getMethod; ///< Get method member function pointer.
1031
1032 /// Create a new DistiAttributeEnum object, able to convert string and int enum values between one another.
1033 /// \param object The object containing the enumeration.
1034 /// \param setMethod The set method pointer for the property.
1035 /// \param getMethod The get method pointer for the property.
1036 /// \param name The name of the attribute to contain the enumeration.
1037 DistiAttributeEnum( containerClass* object, SetMethodType setMethod, GetMethodType getMethod, const AttributeName& name )
1038 : DistiAttributeBase( NULL, name, false )
1039 , _object( object )
1040 , _setMethod( setMethod )
1041 , _getMethod( getMethod )
1042 {
1043 GLS_ASSERT( setMethod );
1044 GLS_ASSERT( getMethod );
1045 }
1046
1047 virtual ~DistiAttributeEnum()
1048 {
1049 }
1050
1051 /// \return The integer value via the underlying get method.
1053 {
1054 return (long)( _object->*_getMethod )();
1055 }
1056
1057 /// Set the integer value via the underlying set method.
1058 /// \param val The new integer value to set.
1059 virtual void ValueInt( long val ) DISTI_METHOD_OVERRIDE
1060 {
1061 ( _object->*_setMethod )( (setType)val );
1062 };
1063
1064 /// Assignment operator.
1065 /// \param oldClass The attribute to assign to.
1066 /// \return The resulting attribute (this).
1068 {
1070 if( ptr )
1071 {
1072 ValueInt( ptr->ValueInt() );
1073 }
1074 else
1075 {
1076 return DistiAttributeBase::operator=( oldClass );
1077 }
1078 return *this;
1079 }
1080
1081 /// Write this attribute's string value to the stream.
1082 /// \param outstr The stream to write to.
1083 /// \return The stream in its updated state.
1084 virtual std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
1085 {
1086 bool foundIt = false;
1087 getType value = ( _object->*_getMethod )();
1088 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1089 while( item != _pairList->end() && *item )
1090 {
1091 if( ( *item )->_enum == value )
1092 {
1093 outstr << ( *item )->_string;
1094 foundIt = true;
1095 break;
1096 }
1097 ++item;
1098 }
1099 if( !foundIt )
1100 {
1101 //Didn't find it so just write the number
1102 outstr << value;
1103 }
1104 return outstr;
1105 }
1106
1107 /// Return the associated integer value with the enumeration string.
1108 /// \param string The string whose enum value is to be returned.
1109 /// \return The enumeration value, 0 if the string isn't present in the list.
1110 int EnumToInt( std::string& string )
1111 {
1112 int returnVal = 0;
1113 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1114
1115 while( item != _pairList->end() && *item )
1116 {
1117 if( strcmp( ( *item )->_string, string.c_str() ) == 0 )
1118 {
1119 returnVal = ( *item )->_enum;
1120 break;
1121 }
1122 ++item;
1123 }
1124 return returnVal;
1125 }
1126
1127 /// Read from the stream, and store it in this attribute.
1128 /// \param instr The stream to read from.
1129 /// \return The stream in its updated state.
1130 virtual std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
1131 {
1132 char value[ 64 ];
1133 instr >> value;
1134
1135 bool foundIt = false;
1136 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1137
1138 // First look by enumeration
1139 while( item != _pairList->end() && *item )
1140 {
1141 if( strcmp( ( *item )->_string, value ) == 0 )
1142 {
1143 ( _object->*_setMethod )( (setType)( *item )->_enum );
1144
1145 foundIt = true;
1146 break;
1147 }
1148 ++item;
1149 }
1150
1151 // If not found, assume that the numerical value is specified.
1152 if( !foundIt )
1153 {
1154 ( _object->*_setMethod )( (setType)atoi( value ) );
1155 }
1156 return instr;
1157 }
1158};
1159
1160} // namespace disti
1161
1162#if defined( WIN32 )
1163# pragma warning( pop )
1164#endif
1165
1166#endif
Definition: disti_metadata.h:521
virtual void NotifyAttributeChanged(const AttributeName &name)=0
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:529
Definition: disti_metadata.h:424
AttributeMethodCallback(T *object, Callback method)
Definition: disti_metadata.h:431
WeakRef< T > _object
The underlying object containing the callback method.
Definition: disti_metadata.h:454
Callback _method
Method to call back when invoked.
Definition: disti_metadata.h:453
virtual bool IsValid() const override
Definition: disti_metadata.h:447
void(T::* Callback)(DistiAttributeBase &attr)
Typedef for the callback function pointer.
Definition: disti_metadata.h:426
void Call(DistiAttributeBase &ev) override
Definition: disti_metadata.h:439
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:474
WeakRef< T > _object
The object containing the attribute.
Definition: disti_metadata.h:504
AttributeName _attributeName
The attribute to set when invoked.
Definition: disti_metadata.h:503
virtual bool IsValid() const override
Definition: disti_metadata.h:497
void Call(DistiAttributeBase &attr) override
Definition: disti_metadata.h:486
AttributeResourceCallback(T *object, const AttributeName &attributeName)
Definition: disti_metadata.h:479
Definition: callback_caller_base.h:56
Definition: disti_metadata.h:750
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:758
std::multimap< long, Attr_t > Map_t
Typedef for a map ot attribute pointers.
Definition: disti_metadata.h:756
static long _currentFileVersionSecondary
Definition: disti_metadata.h:807
static void SpacingDec()
iterator Begin()
Definition: disti_metadata.h:844
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:847
std::istream & ReadValue(const AttributeName &name, std::istream &instr)
List_t::iterator iterator
Shorthand for List_t::iterator.
Definition: disti_metadata.h:759
DistiAttribDict & operator=(DistiAttribDict &&other)
Definition: disti_metadata.h:778
static unsigned int _currentFileVersionMinor
Definition: disti_metadata.h:800
DistiAttributeBase * Get(const AttributeName &name) const
std::list< Attr_t > List_t
Typedef for a list of attribute pointers.
Definition: disti_metadata.h:755
std::string ValueString(const AttributeName &name) const
void Add(DistiAttributeBase *attr)
const_iterator End() const
Definition: disti_metadata.h:841
DistiAttributeBase * Attr_t
Definition: disti_metadata.h:753
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:798
static int currentOutputSpacing
Definition: disti_metadata.h:930
bool ReadAndCaptureMissing(std::istream &instr, std::stringstream *missingStream)
static unsigned int _currentFileVersionBuild
Definition: disti_metadata.h:802
const_iterator Begin() const
Definition: disti_metadata.h:838
static double _currentFileVersionPrimary
Definition: disti_metadata.h:805
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:378
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:362
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:401
virtual std::string Type() const
Definition: disti_metadata.h:345
Definition: disti_metadata.h:1002
DistiAttributeEnumDefList(char *stringVal,...)
virtual int EnumToInt(const std::string &string)
Definition: disti_metadata.h:1021
DistiAttributeEnum(containerClass *object, SetMethodType setMethod, GetMethodType getMethod, const AttributeName &name)
Definition: disti_metadata.h:1037
virtual void ValueInt(long val) override
Definition: disti_metadata.h:1059
void(containerClass::* SetMethodType)(setType)
Typedef for the set method function pointer.
Definition: disti_metadata.h:1023
GetMethodType _getMethod
Get method member function pointer.
Definition: disti_metadata.h:1030
int EnumToInt(std::string &string)
Definition: disti_metadata.h:1110
DistiAttributeEnumDefList * _pairList
A list of name value pairs describing the enumeration.
Definition: disti_metadata.h:1026
SetMethodType _setMethod
Set method member function pointer.
Definition: disti_metadata.h:1029
getType(containerClass::* GetMethodType)()
Typedef for the get method function pointer.
Definition: disti_metadata.h:1024
virtual std::istream & ReadValue(std::istream &instr) override
Definition: disti_metadata.h:1130
virtual long ValueInt() override
Definition: disti_metadata.h:1052
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass) override
Definition: disti_metadata.h:1067
containerClass * _object
Object that contains the attribute.
Definition: disti_metadata.h:1027
virtual std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:1084
Definition: disti_metadata.h:554
void ValueFloat(double val) override
Definition: disti_metadata.h:614
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:569
T * _attribPtr
Definition: disti_metadata.h:557
virtual T Value()
Definition: disti_metadata.h:670
std::istream & ReadValue(std::istream &instr) override
Definition: disti_metadata.h:654
std::string Type() const override
Definition: disti_metadata.h:663
std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:641
long ValueInt() override
Definition: disti_metadata.h:594
DistiAttributeBase & operator=(const DistiAttributeBase &oldClass) override
Definition: disti_metadata.h:622
void ValueInt(long val) override
Definition: disti_metadata.h:601
~DistiAttribute() override
Definition: disti_metadata.h:701
bool operator==(const DistiAttributeBase &rArg) override
Definition: disti_metadata.h:687
bool Copyable() const override
Definition: disti_metadata.h:591
virtual void Value(const T &val)
Definition: disti_metadata.h:677
int _precision
Definition: disti_metadata.h:559
double ValueFloat() override
Definition: disti_metadata.h:607
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, const T &initialValue)
Definition: disti_metadata.h:583
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:970
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:462
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:539
DistiAttribDict::const_iterator end(const DistiAttribDict &dict)
Definition: disti_metadata.h:975
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:512
A smart pointer with unique ownership – poor man's std::unique_ptr.
Definition: disti_metadata.h:995
int _enum
Integer value for enumeration.
Definition: disti_metadata.h:997
Definition: gls_cpp_lang_support.h:468
The DistiUnhideGlobalsDummyClass class.
weak reference and related classes
weak reference and related classes