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 )
111 AttributeName&
operator=(
const AttributeName& other ) DISTI_FUNC_NOEXCEPT
113 _stringIndex = other._stringIndex;
121 DISTI_EXPORT
operator std::string()
const;
127 IF_GLS_DEBUG_ATTRIBUTE_NAMES( std::string _name )
132 void Initialize(
const char* name );
136 DISTI_EXPORT std::ostream&
operator<<( std::ostream& outstr,
const AttributeName& name );
151 return !( attr1 == attr2 );
155 DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const char* rName );
156 DISTI_EXPORT
bool operator==(
const char* lName,
const AttributeName& rName );
157 DISTI_EXPORT
bool operator==(
const std::string& lName,
const AttributeName& rName );
158 DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const std::string& rName );
161 DISTI_IF_HAS_USER_DEFINED_LITERAL(
inline AttributeName
operator""_Attr(
const char* str, std::size_t ) {
return AttributeName( str ); } )
163 class DistiAttributeBase;
173 virtual bool IsValid()
const = 0;
178 class DistiAttributeObserverList;
230 virtual DISTI_EXPORT
bool Copyable()
const;
238 virtual DISTI_EXPORT
bool OkToWrite()
const;
262 virtual DISTI_EXPORT
void ValueString(
const std::string& s );
266 virtual DISTI_EXPORT
long ValueInt();
270 virtual DISTI_EXPORT
void ValueInt(
long val );
278 virtual DISTI_EXPORT
void ValueFloat(
double val );
290 virtual std::ostream&
WriteValue( std::ostream& outstr ) = 0;
299 virtual std::istream&
ReadValue( std::istream& instr ) = 0;
310 template<
class valType>
325 template<
class valType>
381 ( _object.Get()->*( _method ) )( ev );
387 return !_object.IsNull();
399 template<
class Class>
415 : _attributeName( attributeName )
434 return !_object.IsNull();
446 template<
class Class>
449 const char* attributeName )
476 if( newValue != property )
479 object->NotifyAttributeChanged( name );
486 class DistiAttribDict;
506 , _attribPtr( attribPtr )
520 , _attribPtr( new T( initialValue ) )
528 bool Copyable() const DISTI_METHOD_OVERRIDE {
return true; }
571 std::ostream&
WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
574 outstr.precision( _precision );
585 std::istream&
ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
587 return ReadValueImpl( instr );
628 std::istream& ReadValueImpl( std::istream& instr )
643 inline std::istream& DistiAttribute<float>::ReadValueImpl( std::istream& instr )
647 *_attribPtr =
static_cast<float>( atof( instrBuf ) );
654 inline std::istream& DistiAttribute<double>::ReadValueImpl( std::istream& instr )
658 *_attribPtr = atof( instrBuf );
671 typedef std::list<Attr_t> List_t;
672 typedef std::multimap<long, Attr_t> Map_t;
674 typedef List_t::const_iterator const_iterator;
675 typedef List_t::iterator iterator;
683 #if defined( DISTI_HAS_RVAL_REFS )
687 *
this = std::move( other );
695 _list = std::move( other._list );
696 _map = std::move( other._map );
726 DISTI_DEPRECATED(
"Renamed to CopyCommonValues() to better represent the action taken by this function." )
748 const_iterator Begin()
const {
return _list.begin(); }
749 const_iterator End()
const {
return _list.end(); }
750 iterator Begin() {
return _list.begin(); }
751 iterator End() {
return _list.end(); }
754 int DISTI_EXPORT
Count()
const;
757 int DISTI_EXPORT
Count(
const AttributeName& name )
const;
760 void DISTI_EXPORT
Clear();
765 DISTI_EXPORT
void Delete(
const AttributeName& name );
773 DISTI_EXPORT
void ReadStrings( std::istream& instr );
780 DISTI_EXPORT
void Write( std::ostream& outstr,
bool changedDataOnly =
false );
785 DISTI_EXPORT
bool Read( std::istream& instr );
796 DISTI_EXPORT std::string
ValueString(
const AttributeName& name )
const;
800 DISTI_EXPORT
void ValueString(
const AttributeName& name,
const std::string& val );
803 DISTI_EXPORT
long ValueInt(
const AttributeName& name )
const;
806 DISTI_EXPORT
void ValueInt(
const AttributeName& name,
long val );
809 DISTI_EXPORT std::ostream&
WriteValue(
const AttributeName& name, std::ostream& outstr );
812 DISTI_EXPORT std::istream&
ReadValue(
const AttributeName& name, std::istream& instr );
816 DISTI_EXPORT DistiAttributeBase*
Get(
const AttributeName& name )
const;
821 DISTI_EXPORT
bool IsEqual(
const AttributeName& name,
const long val )
const;
841 static DISTI_EXPORT
bool ScanToken( std::istream& instr, std::string& result );
861 inline DistiAttribDict::const_iterator end(
const DistiAttribDict& dict ) {
return dict.End(); }
863 inline DistiAttribDict::iterator end(
DistiAttribDict& dict ) {
return dict.End(); }
883 virtual DISTI_EXPORT
int EnumToInt(
const std::string&
string );
884 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
890 template<
class containerClass,
class setType,
class getType>
894 typedef void ( containerClass::*SetMethodType )( setType );
895 typedef getType ( containerClass::*GetMethodType )();
898 containerClass* _object;
900 SetMethodType _setMethod;
901 GetMethodType _getMethod;
906 , _setMethod( setMethod )
907 , _getMethod( getMethod )
909 DistiAssert( setMethod );
910 DistiAssert( getMethod );
919 return (
long)( _object->*_getMethod )();
924 ( _object->*_setMethod )( (setType)val );
943 bool foundIt =
false;
944 getType value = ( _object->*_getMethod )();
945 DistiAttributeEnumDefList::iterator item = _pairList->begin();
946 while( item != _pairList->end() && *item )
948 if( ( *item )->_enum == value )
950 outstr << ( *item )->_string;
964 int EnumToInt( std::string&
string )
966 bool foundIt =
false;
968 DistiAttributeEnumDefList::iterator item = _pairList->begin();
970 while( item != _pairList->end() && *item )
972 if( strcmp( ( *item )->_string,
string.c_str() ) == 0 )
975 returnVal = ( *item )->_enum;
988 bool foundIt =
false;
989 DistiAttributeEnumDefList::iterator item = _pairList->begin();
992 while( item != _pairList->end() && *item )
994 if( strcmp( ( *item )->_string, value ) == 0 )
996 ( _object->*_setMethod )( ( setType )( *item )->_enum );
1007 ( _object->*_setMethod )( (setType)atoi( value ) );
1015 #if defined( WIN32 )
1016 # pragma warning( pop )
The DistiUnhideGlobalsDummyClass class.
bool Copyable() const override
Definition: disti_metadata.h:528
bool IsEqual(const AttributeName &name, const long val) const
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:927
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:464
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:691
void CopyCommonValues(const DistiAttribDict &dict)
static long _currentFileVersionSecondary
Definition: disti_metadata.h:720
#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:824
bool LocalStorage() const
virtual long ValueInt()
Definition: disti_metadata.h:917
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:585
bool operator!=(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:149
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
void Remove(const AttributeName &name)
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:447
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:326
void ValueFloat(double val) override
Definition: disti_metadata.h:548
static double _currentFileVersionPrimary
Definition: disti_metadata.h:718
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:311
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:941
double ValueFloat() override
Definition: disti_metadata.h:542
std::istream & ReadValue(const AttributeName &name, std::istream &instr)
Definition: disti_metadata.h:411
std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:571
DistiAttributeBase & operator=(const DistiAttributeBase &oldClass) override
Definition: disti_metadata.h:554
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:385
bool operator==(const DistiAttributeBase &rArg) override
Definition: disti_metadata.h:603
void Call(DistiAttributeBase &attr)
Definition: disti_metadata.h:421
DistiAttribDict(DistiAttribDict &&other)
Definition: disti_metadata.h:685
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:669
virtual std::string ValueString()
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:342
void Write(std::ostream &outstr, bool changedDataOnly=false)
virtual bool IsValid() const =0
AttributeName & operator=(const AttributeName &other)
Copy assignment.
Definition: disti_metadata.h:111
Definition: disti_metadata.h:891
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:504
virtual void CallCallback()
virtual bool OkToWrite() const
int _precision
Definition: disti_metadata.h:494
Definition: disti_metadata.h:364
#define GLS_ASSERT(exp)
Definition: disti_assert.h:135
bool operator==(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:141
T * _attribPtr
Definition: disti_metadata.h:492
Definition: disti_metadata.h:488
bool operator==(const DistiAttribDict &other)
virtual bool IsValid() const
Definition: disti_metadata.h:432
AttributeName(const AttributeName &other)
Copy constructor.
Definition: disti_metadata.h:106
~DistiAttribute() override
Definition: disti_metadata.h:617
#define GLS_VERIFY(exp)
Definition: disti_assert.h:155
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:983
virtual void ValueInt(long val)
Definition: disti_metadata.h:922
virtual T Value()
Definition: disti_metadata.h:591
ScopedPtr< DistiAttributeObserverList > _observerList
Definition: disti_metadata.h:195
Definition: disti_metadata.h:183
Definition: disti_metadata.h:166
static bool ScanToken(std::istream &instr, std::string &result)
void Call(DistiAttributeBase &ev)
Definition: disti_metadata.h:377
void ReadStrings(std::istream &instr)
Definition: disti_metadata.h:665
Definition: weak_referenceable_mixin.h:52
bool Read(std::istream &instr)
Definition: disti_metadata.h:879
void Delete(const AttributeName &name)
Definition: callback_caller_base.h:55
DistiAttribDict::const_iterator begin(const DistiAttribDict &dict)
Definition: disti_metadata.h:860
bool _localStorage
Definition: disti_metadata.h:201
void ValueInt(long val) override
Definition: disti_metadata.h:536
void SetAndNotifyIfChanged(AttributeChangedNotifier *object, T &property, const T &newValue, const AttributeName &name)
Definition: disti_metadata.h:474
Definition: weak_reference.h:91
long ValueInt(const AttributeName &name) const
static unsigned int _currentFileVersionMinor
Definition: disti_metadata.h:713
CallbackMethodCallerBase * _callback
Definition: disti_metadata.h:192
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:400
virtual void ResetValueChanged()
virtual CallbackID RegisterObserver(AttributeObserver *observer)
Definition: disti_metadata.h:455
AttributeName _name
Definition: disti_metadata.h:190
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:118
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:518
virtual void Value(const T &val)
Definition: disti_metadata.h:596
Definition: disti_metadata.h:872
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:715
Definition: disti_metadata.h:85
static unsigned int _currentFileVersionMajor
Definition: disti_metadata.h:711
const AttributeName & Name() const
Definition: bmpimage.h:46
long ValueInt() override
Definition: disti_metadata.h:531
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