39 #ifndef INCLUDED_DISTI_METADATA_H
40 #define INCLUDED_DISTI_METADATA_H
43 # pragma warning( push )
44 # pragma warning( disable : 4786 )
45 # pragma warning( disable : 4251 ) // This may hide non-exported code.
69 #define GLS_DEBUG_ATTRIBUTE_NAMES 0
70 #if GLS_DEBUG_ATTRIBUTE_NAMES
71 # define IF_GLS_DEBUG_ATTRIBUTE_NAMES( x ) x
73 # define IF_GLS_DEBUG_ATTRIBUTE_NAMES( x )
78 class CallbackMethodCallerBase;
79 const int MAX_ATTRIBUTE_NAME_LENGTH = 128;
94 DISTI_EXPORT
explicit AttributeName(
const std::string& name );
107 : _stringIndex( other._stringIndex )
109 IF_GLS_DEBUG_ATTRIBUTE_NAMES( _name = *
this );
113 AttributeName&
operator=(
const AttributeName& other ) DISTI_FUNC_NOEXCEPT
115 _stringIndex = other._stringIndex;
116 IF_GLS_DEBUG_ATTRIBUTE_NAMES( _name = *
this );
124 DISTI_EXPORT
operator std::string()
const;
130 IF_GLS_DEBUG_ATTRIBUTE_NAMES( std::string _name; )
135 void Initialize(
const char* name );
139 DISTI_EXPORT std::ostream&
operator<<( std::ostream& outstr,
const AttributeName& name );
144 inline bool operator==(
const AttributeName& attr1,
const AttributeName& attr2 )
152 inline bool operator!=(
const AttributeName& attr1,
const AttributeName& attr2 )
154 return !( attr1 == attr2 );
158 DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const char* rName );
159 DISTI_EXPORT
bool operator==(
const char* lName,
const AttributeName& rName );
160 DISTI_EXPORT
bool operator==(
const std::string& lName,
const AttributeName& rName );
161 DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const std::string& rName );
164 DISTI_IF_HAS_USER_DEFINED_LITERAL(
inline AttributeName
operator""_Attr(
const char* str, std::size_t ) {
return AttributeName( str ); } )
166 class DistiAttributeBase;
176 virtual bool IsValid()
const = 0;
181 class DistiAttributeObserverList;
222 DISTI_EXPORT
const AttributeName&
Name()
const;
225 DISTI_EXPORT AttributeName&
Name();
233 virtual DISTI_EXPORT
bool Copyable()
const;
241 virtual DISTI_EXPORT
bool OkToWrite()
const;
265 virtual DISTI_EXPORT
void ValueString(
const std::string& s );
269 virtual DISTI_EXPORT
long ValueInt();
273 virtual DISTI_EXPORT
void ValueInt(
long val );
281 virtual DISTI_EXPORT
void ValueFloat(
double val );
293 virtual std::ostream&
WriteValue( std::ostream& outstr ) = 0;
302 virtual std::istream&
ReadValue( std::istream& instr ) = 0;
313 template<
class valType>
328 template<
class valType>
384 ( _object.Get()->*( _method ) )( ev );
390 return !_object.IsNull();
402 template<
class Class>
418 : _attributeName( attributeName )
437 return !_object.IsNull();
441 AttributeName _attributeName;
449 template<
class Class>
452 const char* attributeName )
479 if( newValue != property )
482 object->NotifyAttributeChanged( name );
489 class DistiAttribDict;
509 , _attribPtr( attribPtr )
523 , _attribPtr( new T( initialValue ) )
531 bool Copyable() const DISTI_METHOD_OVERRIDE {
return true; }
574 std::ostream&
WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
577 outstr.precision( _precision );
588 std::istream&
ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
590 return ReadValueImpl( instr );
631 std::istream& ReadValueImpl( std::istream& instr )
646 inline std::istream& DistiAttribute<float>::ReadValueImpl( std::istream& instr )
650 *_attribPtr =
static_cast<float>( atof( instrBuf ) );
657 inline std::istream& DistiAttribute<double>::ReadValueImpl( std::istream& instr )
661 *_attribPtr = atof( instrBuf );
674 typedef std::list<Attr_t> List_t;
675 typedef std::multimap<long, Attr_t> Map_t;
677 typedef List_t::const_iterator const_iterator;
678 typedef List_t::iterator iterator;
686 #if defined( DISTI_HAS_RVAL_REFS )
690 *
this = std::move( other );
698 _list = std::move( other._list );
699 _map = std::move( other._map );
729 DISTI_DEPRECATED(
"Renamed to CopyCommonValues() to better represent the action taken by this function." )
751 const_iterator Begin()
const {
return _list.begin(); }
752 const_iterator End()
const {
return _list.end(); }
753 iterator Begin() {
return _list.begin(); }
754 iterator End() {
return _list.end(); }
757 int DISTI_EXPORT
Count()
const;
760 int DISTI_EXPORT
Count(
const AttributeName& name )
const;
763 void DISTI_EXPORT
Clear();
768 DISTI_EXPORT
void Delete(
const AttributeName& name );
776 DISTI_EXPORT
void ReadStrings( std::istream& instr );
783 DISTI_EXPORT
void Write( std::ostream& outstr,
bool changedDataOnly =
false );
788 DISTI_EXPORT
bool Read( std::istream& instr );
799 DISTI_EXPORT std::string
ValueString(
const AttributeName& name )
const;
803 DISTI_EXPORT
void ValueString(
const AttributeName& name,
const std::string& val );
806 DISTI_EXPORT
long ValueInt(
const AttributeName& name )
const;
809 DISTI_EXPORT
void ValueInt(
const AttributeName& name,
long val );
812 DISTI_EXPORT std::ostream&
WriteValue(
const AttributeName& name, std::ostream& outstr );
815 DISTI_EXPORT std::istream&
ReadValue(
const AttributeName& name, std::istream& instr );
819 DISTI_EXPORT DistiAttributeBase*
Get(
const AttributeName& name )
const;
824 DISTI_EXPORT
bool IsEqual(
const AttributeName& name,
const long val )
const;
844 static DISTI_EXPORT
bool ScanToken( std::istream& instr, std::string& result );
850 DISTI_EXPORT
void Remove(
const AttributeName& name );
864 inline DistiAttribDict::const_iterator end(
const DistiAttribDict& dict ) {
return dict.End(); }
866 inline DistiAttribDict::iterator end(
DistiAttribDict& dict ) {
return dict.End(); }
886 virtual DISTI_EXPORT
int EnumToInt(
const std::string&
string );
887 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
893 template<
class containerClass,
class setType,
class getType>
897 typedef void ( containerClass::*SetMethodType )( setType );
898 typedef getType ( containerClass::*GetMethodType )();
901 containerClass* _object;
903 SetMethodType _setMethod;
904 GetMethodType _getMethod;
906 DistiAttributeEnum( containerClass*
object, SetMethodType setMethod, GetMethodType getMethod,
const AttributeName& name )
909 , _setMethod( setMethod )
910 , _getMethod( getMethod )
912 DistiAssert( setMethod );
913 DistiAssert( getMethod );
922 return (
long)( _object->*_getMethod )();
927 ( _object->*_setMethod )( (setType)val );
946 bool foundIt =
false;
947 getType value = ( _object->*_getMethod )();
948 DistiAttributeEnumDefList::iterator item = _pairList->begin();
949 while( item != _pairList->end() && *item )
951 if( ( *item )->_enum == value )
953 outstr << ( *item )->_string;
967 int EnumToInt( std::string&
string )
969 bool foundIt =
false;
971 DistiAttributeEnumDefList::iterator item = _pairList->begin();
973 while( item != _pairList->end() && *item )
975 if( strcmp( ( *item )->_string,
string.c_str() ) == 0 )
978 returnVal = ( *item )->_enum;
991 bool foundIt =
false;
992 DistiAttributeEnumDefList::iterator item = _pairList->begin();
995 while( item != _pairList->end() && *item )
997 if( strcmp( ( *item )->_string, value ) == 0 )
999 ( _object->*_setMethod )( ( setType )( *item )->_enum );
1010 ( _object->*_setMethod )( (setType)atoi( value ) );
1018 #if defined( WIN32 )
1019 # pragma warning( pop )
The DistiUnhideGlobalsDummyClass class.
bool Copyable() const override
Definition: disti_metadata.h:531
bool IsEqual(const AttributeName &name, const long val) const
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:930
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:467
virtual void Call(DistiAttributeBase &attr)=0
virtual bool Copyable() const
virtual bool operator==(const DistiAttributeBase &r)
std::string ValueString(const AttributeName &name) const
DistiAttribDict & operator=(DistiAttribDict &&other)
Definition: disti_metadata.h:694
void CopyCommonValues(const DistiAttribDict &dict)
static long _currentFileVersionSecondary
Definition: disti_metadata.h:723
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
static int currentOutputSpacing
Definition: disti_metadata.h:827
bool LocalStorage() const
virtual long ValueInt()
Definition: disti_metadata.h:920
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
virtual void NotifyObservers()
std::istream & ReadValue(std::istream &instr) override
Definition: disti_metadata.h:588
bool operator!=(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:152
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
void Remove(const AttributeName &name)
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:450
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:329
void ValueFloat(double val) override
Definition: disti_metadata.h:551
static double _currentFileVersionPrimary
Definition: disti_metadata.h:721
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:314
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:944
double ValueFloat() override
Definition: disti_metadata.h:545
std::istream & ReadValue(const AttributeName &name, std::istream &instr)
Definition: disti_metadata.h:414
std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:574
DistiAttributeBase & operator=(const DistiAttributeBase &oldClass) override
Definition: disti_metadata.h:557
virtual double ValueFloat()
weak reference and related classes
AttributeName(const std::string &name)
A file for all GL Studio files to include.
virtual bool ValueChanged()
virtual bool IsValid() const
Definition: disti_metadata.h:388
bool operator==(const DistiAttributeBase &rArg) override
Definition: disti_metadata.h:606
void Call(DistiAttributeBase &attr)
Definition: disti_metadata.h:424
DistiAttribDict(DistiAttribDict &&other)
Definition: disti_metadata.h:688
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
Defines the stream out operator.
static std::string SpacingString()
DistiAttributeBase * Attr_t
Definition: disti_metadata.h:672
virtual std::string ValueString()
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:345
void Write(std::ostream &outstr, bool changedDataOnly=false)
virtual bool IsValid() const =0
AttributeName & operator=(const AttributeName &other)
Copy assignment.
Definition: disti_metadata.h:113
Definition: disti_metadata.h:894
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:507
virtual void CallCallback()
virtual bool OkToWrite() const
int _precision
Definition: disti_metadata.h:497
Definition: disti_metadata.h:367
#define GLS_ASSERT(exp)
Definition: disti_assert.h:135
bool operator==(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:144
T * _attribPtr
Definition: disti_metadata.h:495
Definition: disti_metadata.h:491
bool operator==(const DistiAttribDict &other)
virtual bool IsValid() const
Definition: disti_metadata.h:435
AttributeName(const AttributeName &other)
Copy constructor.
Definition: disti_metadata.h:106
~DistiAttribute() override
Definition: disti_metadata.h:620
#define GLS_VERIFY(exp)
Definition: disti_assert.h:155
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:986
virtual void ValueInt(long val)
Definition: disti_metadata.h:925
virtual T Value()
Definition: disti_metadata.h:594
ScopedPtr< DistiAttributeObserverList > _observerList
Definition: disti_metadata.h:198
Definition: disti_metadata.h:186
Definition: disti_metadata.h:169
static bool ScanToken(std::istream &instr, std::string &result)
void Call(DistiAttributeBase &ev)
Definition: disti_metadata.h:380
void ReadStrings(std::istream &instr)
Definition: disti_metadata.h:668
Definition: weak_referenceable_mixin.h:52
bool Read(std::istream &instr)
Definition: disti_metadata.h:882
void Delete(const AttributeName &name)
Definition: callback_caller_base.h:55
DistiAttribDict::const_iterator begin(const DistiAttribDict &dict)
Definition: disti_metadata.h:863
bool _localStorage
Definition: disti_metadata.h:204
void ValueInt(long val) override
Definition: disti_metadata.h:539
void SetAndNotifyIfChanged(AttributeChangedNotifier *object, T &property, const T &newValue, const AttributeName &name)
Definition: disti_metadata.h:477
Definition: weak_reference.h:91
long ValueInt(const AttributeName &name) const
static unsigned int _currentFileVersionMinor
Definition: disti_metadata.h:716
CallbackMethodCallerBase * _callback
Definition: disti_metadata.h:195
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:403
virtual void ResetValueChanged()
virtual CallbackID RegisterObserver(AttributeObserver *observer)
Definition: disti_metadata.h:458
AttributeName _name
Definition: disti_metadata.h:193
bool ReadAndCaptureMissing(std::istream &instr, std::stringstream *missingStream)
void Add(DistiAttributeBase *attr)
Definition: gls_cpp_lang_support.h:449
long StringIndex() const
Returns the index to the string associate with this instance.
Definition: disti_metadata.h:121
static void SpacingZero()
A smart pointer with unique ownership – poor man's std::unique_ptr.
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, const T &initialValue)
Definition: disti_metadata.h:521
virtual void Value(const T &val)
Definition: disti_metadata.h:599
Definition: disti_metadata.h:875
std::ostream & WriteValue(const AttributeName &name, std::ostream &outstr)
DistiAttributeBase * Get(const AttributeName &name) const
Macros and helper code to determine what subset of C++11/14/17 is available.
virtual void NotifyAttributeChanged(const AttributeName &name)=0
static unsigned int _currentFileVersionBuild
Definition: disti_metadata.h:718
Definition: disti_metadata.h:85
static unsigned int _currentFileVersionMajor
Definition: disti_metadata.h:714
const AttributeName & Name() const
Definition: bmpimage.h:46
long ValueInt() override
Definition: disti_metadata.h:534
virtual std::istream & ReadValue(std::istream &instr)=0
virtual void UnregisterObserver(CallbackID id)
weak reference and related classes
virtual std::ostream & WriteValue(std::ostream &outstr)=0