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.
68 #define GLS_DEBUG_ATTRIBUTE_NAMES 0
69 #if GLS_DEBUG_ATTRIBUTE_NAMES
70 # define IF_GLS_DEBUG_ATTRIBUTE_NAMES( x ) x
72 # define IF_GLS_DEBUG_ATTRIBUTE_NAMES( x )
77 class CallbackMethodCallerBase;
78 const int MAX_ATTRIBUTE_NAME_LENGTH = 128;
93 DISTI_EXPORT
explicit AttributeName(
const std::string& name );
106 : _stringIndex( other._stringIndex )
110 AttributeName&
operator=(
const AttributeName& other ) DISTI_FUNC_NOEXCEPT
112 _stringIndex = other._stringIndex;
120 DISTI_EXPORT
operator std::string()
const;
126 IF_GLS_DEBUG_ATTRIBUTE_NAMES( std::string _name );
131 void Initialize(
const char* name );
135 DISTI_EXPORT std::ostream&
operator<<( std::ostream& outstr,
const AttributeName& name );
150 return !( attr1 == attr2 );
154 DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const char* rName );
155 DISTI_EXPORT
bool operator==(
const char* lName,
const AttributeName& rName );
156 DISTI_EXPORT
bool operator==(
const std::string& lName,
const AttributeName& rName );
157 DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const std::string& rName );
160 DISTI_IF_HAS_USER_DEFINED_LITERAL(
inline AttributeName
operator""_Attr(
const char* str, std::size_t ) {
return AttributeName( str ); } )
162 class DistiAttributeBase;
172 virtual bool IsValid()
const = 0;
177 class DistiAttributeObserverList;
228 virtual DISTI_EXPORT
bool Copyable()
const;
236 virtual DISTI_EXPORT
bool OkToWrite()
const;
260 virtual DISTI_EXPORT
void ValueString(
const std::string& s );
264 virtual DISTI_EXPORT
long ValueInt();
268 virtual DISTI_EXPORT
void ValueInt(
long val );
276 virtual DISTI_EXPORT
void ValueFloat(
double val );
288 virtual std::ostream&
WriteValue( std::ostream& outstr ) = 0;
297 virtual std::istream&
ReadValue( std::istream& instr ) = 0;
308 template<
class valType>
323 template<
class valType>
379 ( _object.Get()->*( _method ) )( ev );
385 return !_object.IsNull();
397 template<
class Class>
413 : _attributeName( attributeName )
432 return !_object.IsNull();
444 template<
class Class>
447 const char* attributeName )
474 if( newValue != property )
477 object->NotifyAttributeChanged( name );
484 class DistiAttribDict;
504 , _attribPtr( attribPtr )
518 , _attribPtr( new T( initialValue ) )
572 outstr.precision( _precision );
585 return ReadValueImpl( instr );
624 inline std::istream& ReadValueImpl( std::istream& instr )
638 inline std::istream& DistiAttribute<float>::ReadValueImpl( std::istream& instr )
642 *_attribPtr =
static_cast<float>( atof( instrBuf ) );
649 inline std::istream& DistiAttribute<double>::ReadValueImpl( std::istream& instr )
653 *_attribPtr = atof( instrBuf );
666 typedef std::list<Attr_t> List_t;
667 typedef std::multimap<long, Attr_t> Map_t;
669 typedef List_t::const_iterator const_iterator;
670 typedef List_t::iterator iterator;
714 const_iterator Begin()
const {
return _list.begin(); }
715 const_iterator End()
const {
return _list.end(); }
716 iterator Begin() {
return _list.begin(); }
717 iterator End() {
return _list.end(); }
720 int DISTI_EXPORT
Count()
const;
723 int DISTI_EXPORT
Count(
const AttributeName& name )
const;
726 void DISTI_EXPORT
Clear();
731 virtual DISTI_EXPORT
void Delete(
const AttributeName& name );
739 virtual DISTI_EXPORT
void ReadStrings( std::istream& instr );
746 virtual DISTI_EXPORT
void Write( std::ostream& outstr,
bool changedDataOnly =
false );
751 virtual DISTI_EXPORT
bool Read( std::istream& instr );
762 virtual DISTI_EXPORT std::string
ValueString(
const AttributeName& name )
const;
766 virtual DISTI_EXPORT
void ValueString(
const AttributeName& name,
const std::string& val );
769 DISTI_EXPORT
long ValueInt(
const AttributeName& name )
const;
772 DISTI_EXPORT
void ValueInt(
const AttributeName& name,
long val );
775 virtual DISTI_EXPORT std::ostream&
WriteValue(
const AttributeName& name, std::ostream& outstr );
778 virtual DISTI_EXPORT std::istream&
ReadValue(
const AttributeName& name, std::istream& instr );
782 virtual DISTI_EXPORT DistiAttributeBase*
Get(
const AttributeName& name )
const;
787 virtual DISTI_EXPORT
bool IsEqual(
const AttributeName& name,
const long val )
const;
807 static DISTI_EXPORT
bool ScanToken( std::istream& instr, std::string& result );
844 virtual DISTI_EXPORT
int EnumToInt(
const std::string&
string );
845 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
851 template<
class containerClass,
class setType,
class getType>
855 typedef void ( containerClass::*SetMethodType )( setType );
856 typedef getType ( containerClass::*GetMethodType )();
859 containerClass* _object;
861 SetMethodType _setMethod;
862 GetMethodType _getMethod;
867 , _setMethod( setMethod )
868 , _getMethod( getMethod )
870 DistiAssert( setMethod );
871 DistiAssert( getMethod );
880 return (
long)( _object->*_getMethod )();
885 ( _object->*_setMethod )( (setType)val );
904 bool foundIt =
false;
905 getType value = ( _object->*_getMethod )();
906 DistiAttributeEnumDefList::iterator item = _pairList->begin();
907 while( item != _pairList->end() && *item )
909 if( ( *item )->_enum == value )
911 outstr << ( *item )->_string;
925 int EnumToInt( std::string&
string )
927 bool foundIt =
false;
929 DistiAttributeEnumDefList::iterator item = _pairList->begin();
931 while( item != _pairList->end() && *item )
933 if( strcmp( ( *item )->_string,
string.c_str() ) == 0 )
936 returnVal = ( *item )->_enum;
949 bool foundIt =
false;
950 DistiAttributeEnumDefList::iterator item = _pairList->begin();
953 while( item != _pairList->end() && *item )
955 if( strcmp( ( *item )->_string, value ) == 0 )
957 ( _object->*_setMethod )( ( setType )( *item )->_enum );
968 ( _object->*_setMethod )( (setType)atoi( value ) );
976 # if defined( WIN32 )
977 # pragma warning( pop )
The DistiUnhideGlobalsDummyClass class.
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:888
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:462
virtual void Call(DistiAttributeBase &attr)=0
virtual bool Copyable() const
virtual bool operator==(const DistiAttributeBase &r)
static long _currentFileVersionSecondary
Definition: disti_metadata.h:696
static int currentOutputSpacing
Definition: disti_metadata.h:790
bool LocalStorage() const
virtual long ValueInt()
Definition: disti_metadata.h:878
virtual void ValueFloat(double val)
Definition: disti_metadata.h:546
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:552
virtual void NotifyObservers()
bool operator!=(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:148
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:445
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:324
static double _currentFileVersionPrimary
Definition: disti_metadata.h:694
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:309
virtual std::istream & ReadValue(const AttributeName &name, std::istream &instr)
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:902
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:569
Definition: disti_metadata.h:409
virtual double ValueFloat()
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:583
weak reference and related classes
virtual bool IsEqual(const AttributeName &name, const long val) const
AttributeName(const std::string &name)
virtual ~DistiAttribute()
Definition: disti_metadata.h:615
A file for all GL Studio files to include.
virtual bool ValueChanged()
virtual bool IsValid() const
Definition: disti_metadata.h:383
void Call(DistiAttributeBase &attr)
Definition: disti_metadata.h:419
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:664
virtual std::string ValueString()
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:340
virtual bool Copyable() const
Definition: disti_metadata.h:526
virtual double ValueFloat()
Definition: disti_metadata.h:540
virtual bool IsValid() const =0
AttributeName & operator=(const AttributeName &other)
Copy assignment.
Definition: disti_metadata.h:110
virtual void Write(std::ostream &outstr, bool changedDataOnly=false)
Definition: disti_metadata.h:852
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:502
virtual void CallCallback()
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: disti_metadata.h:601
virtual bool OkToWrite() const
int _precision
Definition: disti_metadata.h:492
virtual std::ostream & WriteValue(const AttributeName &name, std::ostream &outstr)
Definition: disti_metadata.h:362
bool operator==(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:140
DistiAttribDict & operator=(const DistiAttribDict &old_class)
virtual void Add(DistiAttributeBase *attr)
T * _attribPtr
Definition: disti_metadata.h:490
Definition: disti_metadata.h:486
virtual bool IsValid() const
Definition: disti_metadata.h:430
AttributeName(const AttributeName &other)
Copy constructor.
Definition: disti_metadata.h:105
#define GLS_VERIFY(exp)
Definition: disti_assert.h:155
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:944
virtual void ValueInt(long val)
Definition: disti_metadata.h:883
virtual void Remove(const AttributeName &name)
virtual T Value()
Definition: disti_metadata.h:589
Definition: disti_metadata.h:182
virtual std::string ValueString(const AttributeName &name) const
virtual long ValueInt()
Definition: disti_metadata.h:529
virtual void ValueInt(long val)
Definition: disti_metadata.h:534
virtual bool Read(std::istream &instr)
Definition: disti_metadata.h:165
static bool ScanToken(std::istream &instr, std::string &result)
void Call(DistiAttributeBase &ev)
Definition: disti_metadata.h:375
Definition: disti_metadata.h:660
Definition: weak_referenceable_mixin.h:52
Definition: disti_metadata.h:840
Definition: callback_caller_base.h:55
bool _localStorage
Definition: disti_metadata.h:199
void SetAndNotifyIfChanged(AttributeChangedNotifier *object, T &property, const T &newValue, const AttributeName &name)
Definition: disti_metadata.h:472
Definition: weak_reference.h:91
long ValueInt(const AttributeName &name) const
static unsigned int _currentFileVersionMinor
Definition: disti_metadata.h:689
CallbackMethodCallerBase * _callback
Definition: disti_metadata.h:191
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:398
virtual void ResetValueChanged()
virtual void Delete(const AttributeName &name)
virtual CallbackID RegisterObserver(AttributeObserver *observer)
Definition: disti_metadata.h:453
AttributeName _name
Definition: disti_metadata.h:189
bool ReadAndCaptureMissing(std::istream &instr, std::stringstream *missingStream)
Definition: gls_cpp_lang_support.h:399
long StringIndex() const
Returns the index to the string associate with this instance.
Definition: disti_metadata.h:117
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:516
virtual void Value(const T &val)
Definition: disti_metadata.h:594
Definition: disti_metadata.h:833
virtual void ReadStrings(std::istream &instr)
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:691
Definition: disti_metadata.h:84
static unsigned int _currentFileVersionMajor
Definition: disti_metadata.h:687
const AttributeName & Name() const
Definition: bmpimage.h:46
virtual std::istream & ReadValue(std::istream &instr)=0
bool operator==(const DistiAttribDict &old_class)
virtual void UnregisterObserver(CallbackID id)
weak reference and related classes
virtual ~DistiAttribDict()
virtual std::ostream & WriteValue(std::ostream &outstr)=0
virtual DistiAttributeBase * Get(const AttributeName &name) const