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;
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);
275 virtual std::ostream &
WriteValue(std::ostream &outstr) = 0;
278 virtual std::istream &
ReadValue(std::istream &instr) = 0;
289 template<
class valType>
302 template<
class valType>
358 ( _object.Get()->*( _method ) )( ev );
364 return !_object.IsNull();
376 template <
class Class>
392 : _attributeName( attributeName )
411 return !_object.IsNull();
423 template <
class Class>
426 const char* attributeName )
453 if( newValue != property )
456 object->NotifyAttributeChanged( name );
464 class DistiAttribDict;
483 _attribPtr(attribPtr),
487 if (
typeid( T ) ==
typeid(
float ) ||
488 typeid( T ) ==
typeid(
double )||
489 typeid( T ) ==
typeid(
long double ))
504 _attribPtr(new T(initialValue)),
508 if (
typeid( T ) ==
typeid(
float ) ||
509 typeid( T ) ==
typeid(
double )||
510 typeid( T ) ==
typeid(
long double ))
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 );
667 typedef std::list<Attr_t> List_t;
668 typedef std::multimap<long, Attr_t> Map_t;
670 typedef List_t::const_iterator const_iterator;
671 typedef List_t::iterator iterator;
689 static DISTI_EXPORT
long _currentFileVersionSecondary;
707 const_iterator Begin()
const {
return _list.begin(); }
708 const_iterator End()
const {
return _list.end(); }
709 iterator Begin() {
return _list.begin(); }
710 iterator End() {
return _list.end(); }
713 int DISTI_EXPORT
Count()
const;
716 int DISTI_EXPORT
Count(
const AttributeName& name)
const;
719 void DISTI_EXPORT
Clear();
724 virtual DISTI_EXPORT
void Delete(
const AttributeName& name);
732 virtual DISTI_EXPORT
void ReadStrings(std::istream &instr);
739 virtual DISTI_EXPORT
void Write(std::ostream &outstr,
bool changedDataOnly =
false);
744 virtual DISTI_EXPORT
bool Read(std::istream &instr);
749 virtual DISTI_EXPORT std::string
ValueString(
const AttributeName& name)
const;
753 virtual DISTI_EXPORT
void ValueString(
const AttributeName& name,
const std::string& val);
756 DISTI_EXPORT
long ValueInt(
const AttributeName& name)
const;
759 DISTI_EXPORT
void ValueInt(
const AttributeName& name,
long val);
767 template<
class valType>
768 bool SetValueSimple(
const AttributeName& name,
const valType& val)
770 Map_t::iterator attr(_map.find(name.StringIndex()));
772 if (attr != _map.end())
774 attr->second->SetValueSimple(val);
777 return attr != _map.end();
786 template<
class valType>
787 bool GetValueSimple(
const AttributeName& name, valType& val)
789 Map_t::iterator attr(_map.find(name.StringIndex()));
791 if (attr != _map.end())
793 attr->second->GetValueSimple(val);
796 return attr != _map.end();
801 virtual DISTI_EXPORT std::ostream &
WriteValue(
const AttributeName& name, std::ostream &outstr);
804 virtual DISTI_EXPORT std::istream &
ReadValue(
const AttributeName& name, std::istream &instr);
808 virtual DISTI_EXPORT DistiAttributeBase*
Get(
const AttributeName& name)
const;
813 virtual DISTI_EXPORT
bool IsEqual(
const AttributeName& name,
const long val)
const;
833 static DISTI_EXPORT
bool ScanToken(std::istream &instr, std::string &result);
873 virtual DISTI_EXPORT
int EnumToInt(
const std::string&
string);
874 virtual DISTI_EXPORT ~DistiAttributeEnumDefList();
880 template<
class containerClass,
class setType,
class getType>
887 typedef void (containerClass::*SetMethodType)(setType);
888 typedef getType (containerClass::*GetMethodType)();
890 containerClass* _object;
891 SetMethodType _setMethod;
892 GetMethodType _getMethod;
897 _setMethod(setMethod),
898 _getMethod(getMethod)
900 DistiAssert(setMethod);
901 DistiAssert(getMethod);
911 return (
long)(_object->*_getMethod)();
916 (_object->*_setMethod)((setType)val);
935 bool foundIt =
false;
936 getType value = (_object->*_getMethod)();
937 DistiAttributeEnumDefList::iterator item = _pairList->begin();
938 while (item != _pairList->end() && *item)
940 if ((*item)->_enum == value)
942 outstr << (*item)->_string;
956 int EnumToInt(std::string &
string)
958 bool foundIt =
false;
960 DistiAttributeEnumDefList::iterator item = _pairList->begin();
962 while (item != _pairList->end() && *item)
964 if (strcmp((*item)->_string,
string.c_str()) == 0)
967 returnVal = (*item)->_enum;
980 bool foundIt =
false;
981 DistiAttributeEnumDefList::iterator item = _pairList->begin();
984 while (item != _pairList->end() && *item)
986 if (strcmp((*item)->_string, value) == 0)
988 (_object->*_setMethod)((setType)(*item)->_enum);
999 (_object->*_setMethod)((setType)atoi(value));
1009 #pragma warning( pop )
The DistiUnhideGlobalsDummyClass class.
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: disti_metadata.h:919
virtual ~AttributeChangedNotifier()
Definition: disti_metadata.h:441
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:816
bool LocalStorage() const
virtual long ValueInt()
Definition: disti_metadata.h:909
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()
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
AttributeObserver * CreateAttributeResourceCallback(Class *const obj, const char *attributeName)
Definition: disti_metadata.h:424
DistiAttributeBase & operator>>(valType &val)
Definition: disti_metadata.h:303
static double _currentFileVersionPrimary
Definition: disti_metadata.h:688
DistiAttributeBase & operator<<(const valType &val)
Definition: disti_metadata.h:290
virtual std::istream & ReadValue(const AttributeName &name, std::istream &instr)
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:933
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: disti_metadata.h:569
Definition: disti_metadata.h:388
virtual double ValueFloat()
A templated list, disti::TList.
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:362
void Call(DistiAttributeBase &attr)
Definition: disti_metadata.h:398
static std::string SpacingString()
DistiAttributeBase * Attr_t
Definition: disti_metadata.h:665
virtual std::string ValueString()
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:319
virtual bool Copyable() const
Definition: disti_metadata.h:519
virtual double ValueFloat()
Definition: disti_metadata.h:539
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:881
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, T *attribPtr)
Definition: disti_metadata.h:481
virtual void CallCallback()
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: disti_metadata.h:601
virtual bool OkToWrite() const
int _precision
Definition: disti_metadata.h:472
virtual std::ostream & WriteValue(const AttributeName &name, std::ostream &outstr)
Definition: disti_metadata.h:341
DistiAttribDict & operator=(const DistiAttribDict &old_class)
virtual void Add(DistiAttributeBase *attr)
T * _attribPtr
Definition: disti_metadata.h:470
Definition: gls_mutex.h:53
Definition: disti_metadata.h:466
virtual bool IsValid() const
Definition: disti_metadata.h:409
#define GLS_VERIFY(exp)
Definition: disti_assert.h:148
virtual std::istream & ReadValue(std::istream &instr)
Definition: disti_metadata.h:975
virtual void ValueInt(long val)
Definition: disti_metadata.h:914
virtual void Remove(const AttributeName &name)
virtual T Value()
Definition: disti_metadata.h:589
Definition: disti_metadata.h:179
virtual std::string ValueString(const AttributeName &name) const
virtual long ValueInt()
Definition: disti_metadata.h:524
virtual void ValueInt(long val)
Definition: disti_metadata.h:531
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:354
Definition: disti_metadata.h:661
Definition: weak_referenceable_mixin.h:52
Definition: disti_metadata.h:869
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:451
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:377
virtual void ResetValueChanged()
virtual void Delete(const AttributeName &name)
virtual CallbackID RegisterObserver(AttributeObserver *observer)
Definition: disti_metadata.h:432
AttributeName _name
Definition: disti_metadata.h:185
static void SpacingZero()
DistiAttribute(CallbackMethodCallerBase *callback, const AttributeName &name, const T &initialValue)
Definition: disti_metadata.h:502
virtual void Value(const T &val)
Definition: disti_metadata.h:594
Definition: disti_metadata.h:861
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