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;
101 #define GLS_DEBUG_ATTRIBUTE_NAMES 0
102 #if GLS_DEBUG_ATTRIBUTE_NAMES
109 DISTI_EXPORT
void Initialize(
const char* name );
118 explicit DISTI_EXPORT
AttributeName(
const std::string& name );
136 bool DISTI_EXPORT
operator==(
const AttributeName& other )
const;
141 bool DISTI_EXPORT
operator!=(
const AttributeName& other )
const;
144 DISTI_EXPORT
operator std::string()
const;
151 friend DISTI_EXPORT std::ostream&
operator<<( std::ostream& outstr,
const AttributeName& name );
154 friend DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const char* rName );
155 friend DISTI_EXPORT
bool operator==(
const char* lName,
const AttributeName& rName );
156 friend DISTI_EXPORT
bool operator==(
const std::string& lName,
const AttributeName& rName );
157 friend DISTI_EXPORT
bool operator==(
const AttributeName& lName,
const std::string& rName );
170 virtual bool IsValid()
const = 0;
175 class DistiAttributeObserverList;
226 virtual DISTI_EXPORT
bool Copyable()
const;
234 virtual DISTI_EXPORT
bool OkToWrite()
const;
258 virtual DISTI_EXPORT
void ValueString(
const std::string& s );
262 virtual DISTI_EXPORT
long ValueInt();
266 virtual DISTI_EXPORT
void ValueInt(
long val );
274 virtual DISTI_EXPORT
void ValueFloat(
double val );
286 virtual std::ostream&
WriteValue( std::ostream& outstr ) = 0;
295 virtual std::istream&
ReadValue( std::istream& instr ) = 0;
306 template<
class valType>
319 template<
class valType>
375 ( _object.Get()->*( _method ) )( ev );
381 return !_object.IsNull();
393 template<
class Class>
409 : _attributeName( attributeName )
428 return !_object.IsNull();
440 template<
class Class>
443 const char* attributeName )
470 if( newValue != property )
473 object->NotifyAttributeChanged( name );
480 class DistiAttribDict;
500 , _attribPtr( attribPtr )
504 if(
typeid( T ) ==
typeid(
float ) ||
typeid( T ) ==
typeid(
double ) ||
typeid( T ) ==
typeid(
long double ) )
519 , _attribPtr( new T( initialValue ) )
523 if(
typeid( T ) ==
typeid(
float ) ||
typeid( T ) ==
typeid(
double ) ||
typeid( T ) ==
typeid(
long double ) )
585 outstr.precision( _precision );
598 return ReadValueImpl( instr );
637 inline std::istream& ReadValueImpl( std::istream& instr )
651 inline std::istream& DistiAttribute<float>::ReadValueImpl( std::istream& instr )
655 *_attribPtr =
static_cast<float>( atof( instrBuf ) );
662 inline std::istream& DistiAttribute<double>::ReadValueImpl( std::istream& instr )
666 *_attribPtr = atof( instrBuf );
679 typedef std::list<Attr_t> List_t;
680 typedef std::multimap<long, Attr_t> Map_t;
682 typedef List_t::const_iterator const_iterator;
683 typedef List_t::iterator iterator;
727 const_iterator Begin()
const {
return _list.begin(); }
728 const_iterator End()
const {
return _list.end(); }
729 iterator Begin() {
return _list.begin(); }
730 iterator End() {
return _list.end(); }
733 int DISTI_EXPORT
Count()
const;
736 int DISTI_EXPORT
Count(
const AttributeName& name )
const;
739 void DISTI_EXPORT
Clear();
744 virtual DISTI_EXPORT
void Delete(
const AttributeName& name );
752 virtual DISTI_EXPORT
void ReadStrings( std::istream& instr );
759 virtual DISTI_EXPORT
void Write( std::ostream& outstr,
bool changedDataOnly =
false );
764 virtual DISTI_EXPORT
bool Read( std::istream& instr );
775 virtual DISTI_EXPORT std::string
ValueString(
const AttributeName& name )
const;
779 virtual DISTI_EXPORT
void ValueString(
const AttributeName& name,
const std::string& val );
782 DISTI_EXPORT
long ValueInt(
const AttributeName& name )
const;
785 DISTI_EXPORT
void ValueInt(
const AttributeName& name,
long val );
793 template<
class valType>
794 bool SetValueSimple(
const AttributeName& name,
const valType& val)
796 Map_t::iterator attr(_map.find(name.StringIndex()));
798 if (attr != _map.end())
800 attr->second->SetValueSimple(val);
803 return attr != _map.end();
812 template<
class valType>
813 bool GetValueSimple(
const AttributeName& name, valType& val)
815 Map_t::iterator attr(_map.find(name.StringIndex()));
817 if (attr != _map.end())
819 attr->second->GetValueSimple(val);
822 return attr != _map.end();
827 virtual DISTI_EXPORT std::ostream&
WriteValue(
const AttributeName& name, std::ostream& outstr );
830 virtual DISTI_EXPORT std::istream&
ReadValue(
const AttributeName& name, std::istream& instr );
834 virtual DISTI_EXPORT DistiAttributeBase*
Get(
const AttributeName& name )
const;
839 virtual DISTI_EXPORT
bool IsEqual(
const AttributeName& name,
const long val )
const;
859 static DISTI_EXPORT
bool ScanToken( std::istream& instr, std::string& result );
896 virtual DISTI_EXPORT
int EnumToInt(
const std::string&
string );
897 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
903 template<
class containerClass,
class setType,
class getType>
907 typedef void ( containerClass::*SetMethodType )( setType );
908 typedef getType ( containerClass::*GetMethodType )();
911 containerClass* _object;
913 SetMethodType _setMethod;
914 GetMethodType _getMethod;
919 , _setMethod( setMethod )
920 , _getMethod( getMethod )
922 DistiAssert( setMethod );
923 DistiAssert( getMethod );
932 return (
long)( _object->*_getMethod )();
937 ( _object->*_setMethod )( (setType)val );
956 bool foundIt =
false;
957 getType value = ( _object->*_getMethod )();
958 DistiAttributeEnumDefList::iterator item = _pairList->begin();
959 while( item != _pairList->end() && *item )
961 if( ( *item )->_enum == value )
963 outstr << ( *item )->_string;
977 int EnumToInt( std::string&
string )
979 bool foundIt =
false;
981 DistiAttributeEnumDefList::iterator item = _pairList->begin();
983 while( item != _pairList->end() && *item )
985 if( strcmp( ( *item )->_string,
string.c_str() ) == 0 )
988 returnVal = ( *item )->_enum;
1001 bool foundIt =
false;
1002 DistiAttributeEnumDefList::iterator item = _pairList->begin();
1005 while( item != _pairList->end() && *item )
1007 if( strcmp( ( *item )->_string, value ) == 0 )
1009 ( _object->*_setMethod )( ( setType )( *item )->_enum );
1020 ( _object->*_setMethod )( (setType)atoi( value ) );
1028 #if defined( WIN32 )
1029 # pragma warning( pop )
The DistiUnhideGlobalsDummyClass class.
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:940
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:458
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:709
static int currentOutputSpacing
Definition: disti_metadata.h:842
bool LocalStorage() const
virtual long ValueInt()
Definition: disti_metadata.h:930
virtual void ValueFloat(double val)
Definition: disti_metadata.h:559
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:565
virtual void NotifyObservers()
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:441
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:320
static double _currentFileVersionPrimary
Definition: disti_metadata.h:707
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:307
virtual std::istream & ReadValue(const AttributeName &name, std::istream &instr)
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:954
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:582
Definition: disti_metadata.h:405
virtual double ValueFloat()
A templated list, disti::TList.
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:596
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:628
A file for all GL Studio files to include.
virtual bool ValueChanged()
virtual bool IsValid() const
Definition: disti_metadata.h:379
void Call(DistiAttributeBase &attr)
Definition: disti_metadata.h:415
static std::string SpacingString()
DistiAttributeBase * Attr_t
Definition: disti_metadata.h:677
virtual std::string ValueString()
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:336
virtual bool Copyable() const
Definition: disti_metadata.h:532
virtual double ValueFloat()
Definition: disti_metadata.h:552
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:904
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:498
virtual void CallCallback()
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: disti_metadata.h:614
virtual bool OkToWrite() const
int _precision
Definition: disti_metadata.h:488
virtual std::ostream & WriteValue(const AttributeName &name, std::ostream &outstr)
Definition: disti_metadata.h:358
DistiAttribDict & operator=(const DistiAttribDict &old_class)
virtual void Add(DistiAttributeBase *attr)
T * _attribPtr
Definition: disti_metadata.h:486
Definition: gls_mutex.h:52
Definition: disti_metadata.h:482
virtual bool IsValid() const
Definition: disti_metadata.h:426
#define GLS_VERIFY(exp)
Definition: disti_assert.h:155
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:996
virtual void ValueInt(long val)
Definition: disti_metadata.h:935
virtual void Remove(const AttributeName &name)
virtual T Value()
Definition: disti_metadata.h:602
Definition: disti_metadata.h:180
virtual std::string ValueString(const AttributeName &name) const
virtual long ValueInt()
Definition: disti_metadata.h:537
virtual void ValueInt(long val)
Definition: disti_metadata.h:544
virtual bool Read(std::istream &instr)
Definition: disti_metadata.h:163
static bool ScanToken(std::istream &instr, std::string &result)
void Call(DistiAttributeBase &ev)
Definition: disti_metadata.h:371
Definition: disti_metadata.h:673
Definition: weak_referenceable_mixin.h:52
Definition: disti_metadata.h:892
Definition: callback_caller_base.h:55
bool _localStorage
Definition: disti_metadata.h:197
void SetAndNotifyIfChanged(AttributeChangedNotifier *object, T &property, const T &newValue, const AttributeName &name)
Definition: disti_metadata.h:468
Definition: weak_reference.h:91
long ValueInt(const AttributeName &name) const
static unsigned int _currentFileVersionMinor
Definition: disti_metadata.h:702
CallbackMethodCallerBase * _callback
Definition: disti_metadata.h:189
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:394
virtual void ResetValueChanged()
virtual void Delete(const AttributeName &name)
virtual CallbackID RegisterObserver(AttributeObserver *observer)
Definition: disti_metadata.h:449
AttributeName _name
Definition: disti_metadata.h:187
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:517
virtual void Value(const T &val)
Definition: disti_metadata.h:607
Definition: disti_metadata.h:885
virtual void ReadStrings(std::istream &instr)
virtual void NotifyAttributeChanged(const AttributeName &name)=0
static unsigned int _currentFileVersionBuild
Definition: disti_metadata.h:704
Definition: disti_metadata.h:79
static unsigned int _currentFileVersionMajor
Definition: disti_metadata.h:700
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