42 #ifndef DISTI_METADATA_H
43 #define DISTI_METADATA_H
46 #pragma warning( push )
47 #pragma warning (disable:4786)
48 #pragma warning (disable:4251) // This may hide non-exported code.
75 class CallbackMethodCallerBase;
77 const int MAX_ATTRIBUTE_NAME_LENGTH = 128;
87 class StaticNameStorage
91 static DISTI_EXPORT StaticNameStorage* Instance();
97 std::map<std::string,int> _nameMap;
100 std::vector<std::string> _nameVector;
107 DISTI_EXPORT
void Initialize(
const char *name);
117 explicit DISTI_EXPORT
AttributeName(
const std::string &name);
135 bool DISTI_EXPORT
operator == (
const AttributeName & other)
const;
140 bool DISTI_EXPORT
operator != (
const AttributeName & other)
const;
143 DISTI_EXPORT
operator std::string()
const;
150 friend DISTI_EXPORT std::ostream &
operator<<(std::ostream & outstr,
const AttributeName & name);
153 friend DISTI_EXPORT
bool operator==(
const AttributeName & lName,
const char* rName);
154 friend DISTI_EXPORT
bool operator==(
const char* lName,
const AttributeName & rName);
155 friend DISTI_EXPORT
bool operator==(
const std::string& lName,
const AttributeName & rName);
156 friend DISTI_EXPORT
bool operator==(
const AttributeName & lName,
const std::string& rName);
169 virtual bool IsValid()
const = 0;
174 class DistiAttributeObserverList;
224 virtual DISTI_EXPORT
bool Copyable()
const;
232 virtual DISTI_EXPORT
bool OkToWrite()
const;
256 virtual DISTI_EXPORT
void ValueString(
const std::string& s);
260 virtual DISTI_EXPORT
long ValueInt();
264 virtual DISTI_EXPORT
void ValueInt(
long val);
272 virtual DISTI_EXPORT
void ValueFloat(
double val);
284 virtual std::ostream &
WriteValue(std::ostream &outstr) = 0;
293 virtual std::istream &
ReadValue(std::istream &instr) = 0;
304 template<
class valType>
317 template<
class valType>
373 ( _object.Get()->*( _method ) )( ev );
379 return !_object.IsNull();
391 template <
class Class>
407 : _attributeName( attributeName )
426 return !_object.IsNull();
438 template <
class Class>
441 const char* attributeName )
468 if( newValue != property )
471 object->NotifyAttributeChanged( name );
479 class DistiAttribDict;
498 _attribPtr(attribPtr),
502 if (
typeid( T ) ==
typeid(
float ) ||
503 typeid( T ) ==
typeid(
double )||
504 typeid( T ) ==
typeid(
long double ))
519 _attribPtr(new T(initialValue)),
523 if (
typeid( T ) ==
typeid(
float ) ||
524 typeid( T ) ==
typeid(
double )||
525 typeid( T ) ==
typeid(
long double ))
587 outstr.precision(_precision);
600 return ReadValueImpl( instr );
639 inline std::istream& ReadValueImpl( std::istream& instr )
653 inline std::istream& DistiAttribute< float >::ReadValueImpl( std::istream& instr )
657 *_attribPtr =
static_cast< float >( atof( instrBuf ) );
664 inline std::istream& DistiAttribute< double >::ReadValueImpl( std::istream& instr )
668 *_attribPtr = atof( instrBuf );
682 typedef std::list<Attr_t> List_t;
683 typedef std::multimap<long, Attr_t> Map_t;
685 typedef List_t::const_iterator const_iterator;
686 typedef List_t::iterator iterator;
704 static DISTI_EXPORT
long _currentFileVersionSecondary;
722 const_iterator Begin()
const {
return _list.begin(); }
723 const_iterator End()
const {
return _list.end(); }
724 iterator Begin() {
return _list.begin(); }
725 iterator End() {
return _list.end(); }
728 int DISTI_EXPORT
Count()
const;
731 int DISTI_EXPORT
Count(
const AttributeName& name)
const;
734 void DISTI_EXPORT
Clear();
739 virtual DISTI_EXPORT
void Delete(
const AttributeName& name);
747 virtual DISTI_EXPORT
void ReadStrings(std::istream &instr);
754 virtual DISTI_EXPORT
void Write(std::ostream &outstr,
bool changedDataOnly =
false);
759 virtual DISTI_EXPORT
bool Read(std::istream &instr);
770 virtual DISTI_EXPORT std::string
ValueString(
const AttributeName& name)
const;
774 virtual DISTI_EXPORT
void ValueString(
const AttributeName& name,
const std::string& val);
777 DISTI_EXPORT
long ValueInt(
const AttributeName& name)
const;
780 DISTI_EXPORT
void ValueInt(
const AttributeName& name,
long val);
788 template<
class valType>
789 bool SetValueSimple(
const AttributeName& name,
const valType& val)
791 Map_t::iterator attr(_map.find(name.StringIndex()));
793 if (attr != _map.end())
795 attr->second->SetValueSimple(val);
798 return attr != _map.end();
807 template<
class valType>
808 bool GetValueSimple(
const AttributeName& name, valType& val)
810 Map_t::iterator attr(_map.find(name.StringIndex()));
812 if (attr != _map.end())
814 attr->second->GetValueSimple(val);
817 return attr != _map.end();
822 virtual DISTI_EXPORT std::ostream &
WriteValue(
const AttributeName& name, std::ostream &outstr);
825 virtual DISTI_EXPORT std::istream &
ReadValue(
const AttributeName& name, std::istream &instr);
829 virtual DISTI_EXPORT DistiAttributeBase*
Get(
const AttributeName& name)
const;
834 virtual DISTI_EXPORT
bool IsEqual(
const AttributeName& name,
const long val)
const;
854 static DISTI_EXPORT
bool ScanToken(std::istream &instr, std::string &result);
894 virtual DISTI_EXPORT
int EnumToInt(
const std::string&
string);
895 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
901 template<
class containerClass,
class setType,
class getType>
908 typedef void (containerClass::*SetMethodType)(setType);
909 typedef getType (containerClass::*GetMethodType)();
911 containerClass* _object;
912 SetMethodType _setMethod;
913 GetMethodType _getMethod;
918 _setMethod(setMethod),
919 _getMethod(getMethod)
921 DistiAssert(setMethod);
922 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));
1030 #pragma warning( pop )
The DistiUnhideGlobalsDummyClass class.
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:940
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:456
virtual void Call(DistiAttributeBase &attr)=0
virtual bool Copyable() const
bool operator==(const AttributeName &other) const
virtual bool operator==(const DistiAttributeBase &r)
static int currentOutputSpacing
Definition: disti_metadata.h:837
bool LocalStorage() const
virtual long ValueInt()
Definition: disti_metadata.h:930
virtual void ValueFloat(double val)
Definition: disti_metadata.h:561
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:567
virtual void NotifyObservers()
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:439
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:318
static double _currentFileVersionPrimary
Definition: disti_metadata.h:703
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:305
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:584
Definition: disti_metadata.h:403
virtual double ValueFloat()
A templated list, disti::TList.
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:598
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:630
A file for all GL Studio files to include.
virtual bool ValueChanged()
virtual bool IsValid() const
Definition: disti_metadata.h:377
void Call(DistiAttributeBase &attr)
Definition: disti_metadata.h:413
static std::string SpacingString()
DistiAttributeBase * Attr_t
Definition: disti_metadata.h:680
virtual std::string ValueString()
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:334
virtual bool Copyable() const
Definition: disti_metadata.h:534
virtual double ValueFloat()
Definition: disti_metadata.h:554
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:902
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:496
virtual void CallCallback()
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: disti_metadata.h:616
virtual bool OkToWrite() const
int _precision
Definition: disti_metadata.h:487
virtual std::ostream & WriteValue(const AttributeName &name, std::ostream &outstr)
Definition: disti_metadata.h:356
DistiAttribDict & operator=(const DistiAttribDict &old_class)
virtual void Add(DistiAttributeBase *attr)
T * _attribPtr
Definition: disti_metadata.h:485
Definition: gls_mutex.h:53
Definition: disti_metadata.h:481
virtual bool IsValid() const
Definition: disti_metadata.h:424
#define GLS_VERIFY(exp)
Definition: disti_assert.h:148
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:604
Definition: disti_metadata.h:179
virtual std::string ValueString(const AttributeName &name) const
virtual long ValueInt()
Definition: disti_metadata.h:539
virtual void ValueInt(long val)
Definition: disti_metadata.h:546
virtual bool Read(std::istream &instr)
Definition: disti_metadata.h:162
static bool ScanToken(std::istream &instr, std::string &result)
void Call(DistiAttributeBase &ev)
Definition: disti_metadata.h:369
Definition: disti_metadata.h:676
Definition: weak_referenceable_mixin.h:52
Definition: disti_metadata.h:890
Definition: callback_caller_base.h:56
bool _localStorage
Definition: disti_metadata.h:195
void SetAndNotifyIfChanged(AttributeChangedNotifier *object, T &property, const T &newValue, const AttributeName &name)
Definition: disti_metadata.h:466
Definition: weak_reference.h:91
long ValueInt(const AttributeName &name) const
CallbackMethodCallerBase * _callback
Definition: disti_metadata.h:187
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:392
virtual void ResetValueChanged()
virtual void Delete(const AttributeName &name)
virtual CallbackID RegisterObserver(AttributeObserver *observer)
Definition: disti_metadata.h:447
AttributeName _name
Definition: disti_metadata.h:185
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:609
Definition: disti_metadata.h:882
virtual void ReadStrings(std::istream &instr)
virtual void NotifyAttributeChanged(const AttributeName &name)=0
Definition: disti_metadata.h:83
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