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.
71 class CallbackMethodCallerBase;
73 const int MAX_ATTRIBUTE_NAME_LENGTH = 128;
83 class StaticNameStorage
87 static DISTI_EXPORT StaticNameStorage* Instance();
93 std::map<std::string, int> _nameMap;
96 std::vector<std::string> _nameVector;
103 DISTI_EXPORT
void Initialize(
const char* name );
112 explicit DISTI_EXPORT
AttributeName(
const std::string& name );
130 bool DISTI_EXPORT
operator==(
const AttributeName& other )
const;
135 bool DISTI_EXPORT
operator!=(
const AttributeName& other )
const;
138 DISTI_EXPORT
operator std::string()
const;
145 friend DISTI_EXPORT std::ostream&
operator<<( std::ostream& outstr,
const AttributeName& name );
148 friend DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const char* rName );
149 friend DISTI_EXPORT
bool operator==(
const char* lName,
const AttributeName& rName );
150 friend DISTI_EXPORT
bool operator==(
const std::string& lName,
const AttributeName& rName );
151 friend DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const std::string& rName );
164 virtual bool IsValid()
const = 0;
169 class DistiAttributeObserverList;
220 virtual DISTI_EXPORT
bool Copyable()
const;
228 virtual DISTI_EXPORT
bool OkToWrite()
const;
252 virtual DISTI_EXPORT
void ValueString(
const std::string& s );
256 virtual DISTI_EXPORT
long ValueInt();
260 virtual DISTI_EXPORT
void ValueInt(
long val );
268 virtual DISTI_EXPORT
void ValueFloat(
double val );
280 virtual std::ostream&
WriteValue( std::ostream& outstr ) = 0;
289 virtual std::istream&
ReadValue( std::istream& instr ) = 0;
300 template<
class valType>
313 template<
class valType>
369 ( _object.Get()->*( _method ) )( ev );
375 return !_object.IsNull();
387 template<
class Class>
403 : _attributeName( attributeName )
422 return !_object.IsNull();
434 template<
class Class>
437 const char* attributeName )
464 if( newValue != property )
467 object->NotifyAttributeChanged( name );
474 class DistiAttribDict;
494 , _attribPtr( attribPtr )
498 if(
typeid( T ) ==
typeid(
float ) ||
typeid( T ) ==
typeid(
double ) ||
typeid( T ) ==
typeid(
long double ) )
513 , _attribPtr( new T( initialValue ) )
517 if(
typeid( T ) ==
typeid(
float ) ||
typeid( T ) ==
typeid(
double ) ||
typeid( T ) ==
typeid(
long double ) )
579 outstr.precision( _precision );
592 return ReadValueImpl( instr );
631 inline std::istream& ReadValueImpl( std::istream& instr )
645 inline std::istream& DistiAttribute<float>::ReadValueImpl( std::istream& instr )
649 *_attribPtr =
static_cast<float>( atof( instrBuf ) );
656 inline std::istream& DistiAttribute<double>::ReadValueImpl( std::istream& instr )
660 *_attribPtr = atof( instrBuf );
673 typedef std::list<Attr_t> List_t;
674 typedef std::multimap<long, Attr_t> Map_t;
676 typedef List_t::const_iterator const_iterator;
677 typedef List_t::iterator iterator;
721 const_iterator Begin()
const {
return _list.begin(); }
722 const_iterator End()
const {
return _list.end(); }
723 iterator Begin() {
return _list.begin(); }
724 iterator End() {
return _list.end(); }
727 int DISTI_EXPORT
Count()
const;
730 int DISTI_EXPORT
Count(
const AttributeName& name )
const;
733 void DISTI_EXPORT
Clear();
738 virtual DISTI_EXPORT
void Delete(
const AttributeName& name );
746 virtual DISTI_EXPORT
void ReadStrings( std::istream& instr );
753 virtual DISTI_EXPORT
void Write( std::ostream& outstr,
bool changedDataOnly =
false );
758 virtual DISTI_EXPORT
bool Read( std::istream& instr );
769 virtual DISTI_EXPORT std::string
ValueString(
const AttributeName& name )
const;
773 virtual DISTI_EXPORT
void ValueString(
const AttributeName& name,
const std::string& val );
776 DISTI_EXPORT
long ValueInt(
const AttributeName& name )
const;
779 DISTI_EXPORT
void ValueInt(
const AttributeName& name,
long val );
787 template<
class valType>
788 bool SetValueSimple(
const AttributeName& name,
const valType& val)
790 Map_t::iterator attr(_map.find(name.StringIndex()));
792 if (attr != _map.end())
794 attr->second->SetValueSimple(val);
797 return attr != _map.end();
806 template<
class valType>
807 bool GetValueSimple(
const AttributeName& name, valType& val)
809 Map_t::iterator attr(_map.find(name.StringIndex()));
811 if (attr != _map.end())
813 attr->second->GetValueSimple(val);
816 return attr != _map.end();
821 virtual DISTI_EXPORT std::ostream&
WriteValue(
const AttributeName& name, std::ostream& outstr );
824 virtual DISTI_EXPORT std::istream&
ReadValue(
const AttributeName& name, std::istream& instr );
828 virtual DISTI_EXPORT DistiAttributeBase*
Get(
const AttributeName& name )
const;
833 virtual DISTI_EXPORT
bool IsEqual(
const AttributeName& name,
const long val )
const;
853 static DISTI_EXPORT
bool ScanToken( std::istream& instr, std::string& result );
890 virtual DISTI_EXPORT
int EnumToInt(
const std::string&
string );
891 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
897 template<
class containerClass,
class setType,
class getType>
901 typedef void (containerClass::*SetMethodType)(setType);
902 typedef getType(containerClass::*GetMethodType)();
905 containerClass* _object;
907 SetMethodType _setMethod;
908 GetMethodType _getMethod;
914 , _setMethod( setMethod )
915 , _getMethod( getMethod )
917 DistiAssert( setMethod );
918 DistiAssert( getMethod );
927 return (
long)( _object->*_getMethod )();
932 ( _object->*_setMethod )( (setType)val );
951 bool foundIt =
false;
952 getType value = ( _object->*_getMethod )();
953 DistiAttributeEnumDefList::iterator item = _pairList->begin();
954 while( item != _pairList->end() && *item )
956 if( ( *item )->_enum == value )
958 outstr << ( *item )->_string;
972 int EnumToInt( std::string&
string )
974 bool foundIt =
false;
976 DistiAttributeEnumDefList::iterator item = _pairList->begin();
978 while( item != _pairList->end() && *item )
980 if( strcmp( ( *item )->_string,
string.c_str() ) == 0 )
983 returnVal = ( *item )->_enum;
996 bool foundIt =
false;
997 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1000 while( item != _pairList->end() && *item )
1002 if( strcmp( ( *item )->_string, value ) == 0 )
1004 ( _object->*_setMethod )( ( setType )( *item )->_enum );
1015 ( _object->*_setMethod )( (setType)atoi( value ) );
1023 # if defined( WIN32 )
1024 # pragma warning( pop )
The DistiUnhideGlobalsDummyClass class.
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:935
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:452
virtual void Call(DistiAttributeBase &attr)=0
virtual bool Copyable() const
bool operator==(const AttributeName &other) const
virtual bool operator==(const DistiAttributeBase &r)
static long _currentFileVersionSecondary
Definition: disti_metadata.h:703
static int currentOutputSpacing
Definition: disti_metadata.h:836
bool LocalStorage() const
virtual long ValueInt()
Definition: disti_metadata.h:925
virtual void ValueFloat(double val)
Definition: disti_metadata.h:553
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:559
virtual void NotifyObservers()
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:435
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:314
static double _currentFileVersionPrimary
Definition: disti_metadata.h:701
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:301
virtual std::istream & ReadValue(const AttributeName &name, std::istream &instr)
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:949
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:576
Definition: disti_metadata.h:399
virtual double ValueFloat()
A templated list, disti::TList.
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:590
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:622
A file for all GL Studio files to include.
virtual bool ValueChanged()
virtual bool IsValid() const
Definition: disti_metadata.h:373
void Call(DistiAttributeBase &attr)
Definition: disti_metadata.h:409
static std::string SpacingString()
DistiAttributeBase * Attr_t
Definition: disti_metadata.h:671
virtual std::string ValueString()
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:330
virtual bool Copyable() const
Definition: disti_metadata.h:526
virtual double ValueFloat()
Definition: disti_metadata.h:546
friend std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
virtual bool IsValid() const =0
virtual void Write(std::ostream &outstr, bool changedDataOnly=false)
Definition: disti_metadata.h:898
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:492
virtual void CallCallback()
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: disti_metadata.h:608
virtual bool OkToWrite() const
int _precision
Definition: disti_metadata.h:482
virtual std::ostream & WriteValue(const AttributeName &name, std::ostream &outstr)
Definition: disti_metadata.h:352
DistiAttribDict & operator=(const DistiAttribDict &old_class)
virtual void Add(DistiAttributeBase *attr)
T * _attribPtr
Definition: disti_metadata.h:480
Definition: gls_mutex.h:52
Definition: disti_metadata.h:476
virtual bool IsValid() const
Definition: disti_metadata.h:420
#define GLS_VERIFY(exp)
Definition: disti_assert.h:155
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:991
virtual void ValueInt(long val)
Definition: disti_metadata.h:930
virtual void Remove(const AttributeName &name)
virtual T Value()
Definition: disti_metadata.h:596
Definition: disti_metadata.h:174
virtual std::string ValueString(const AttributeName &name) const
virtual long ValueInt()
Definition: disti_metadata.h:531
virtual void ValueInt(long val)
Definition: disti_metadata.h:538
virtual bool Read(std::istream &instr)
Definition: disti_metadata.h:157
static bool ScanToken(std::istream &instr, std::string &result)
void Call(DistiAttributeBase &ev)
Definition: disti_metadata.h:365
Definition: disti_metadata.h:667
Definition: weak_referenceable_mixin.h:52
Definition: disti_metadata.h:886
Definition: callback_caller_base.h:55
bool _localStorage
Definition: disti_metadata.h:191
void SetAndNotifyIfChanged(AttributeChangedNotifier *object, T &property, const T &newValue, const AttributeName &name)
Definition: disti_metadata.h:462
Definition: weak_reference.h:91
long ValueInt(const AttributeName &name) const
static unsigned int _currentFileVersionMinor
Definition: disti_metadata.h:696
CallbackMethodCallerBase * _callback
Definition: disti_metadata.h:183
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:388
virtual void ResetValueChanged()
virtual void Delete(const AttributeName &name)
virtual CallbackID RegisterObserver(AttributeObserver *observer)
Definition: disti_metadata.h:443
AttributeName _name
Definition: disti_metadata.h:181
bool ReadAndCaptureMissing(std::istream &instr, std::stringstream *missingStream)
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:511
virtual void Value(const T &val)
Definition: disti_metadata.h:601
Definition: disti_metadata.h:879
virtual void ReadStrings(std::istream &instr)
virtual void NotifyAttributeChanged(const AttributeName &name)=0
static unsigned int _currentFileVersionBuild
Definition: disti_metadata.h:698
Definition: disti_metadata.h:79
static unsigned int _currentFileVersionMajor
Definition: disti_metadata.h:694
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
bool operator!=(const AttributeName &other) const
virtual ~DistiAttribDict()
virtual std::ostream & WriteValue(std::ostream &outstr)=0
virtual DistiAttributeBase * Get(const AttributeName &name) const