GL Studio C++ Runtime API
DistiAttributeBase Class Referenceabstract

#include <disti_metadata.h>

Inheritance diagram for DistiAttributeBase:
WeakReferenceableMixin WeakReferenceable DistiAttribute< std::string > DistiAttribute< Vertex > DistiAttribute< unsigned char > DistiAttributeEnum< containerClass, const int, int > DistiAttributeEnum< GlsEyePoint, GlsEyePoint::FovConstraintType, GlsEyePoint::FovConstraintType > DistiAttributeEnum< GlsLightSource, int, int > DistiAttributeEnum< containerClass, int, int > DistiAttributeEnum< GlsSphere, glsSphereMapping_e, glsSphereMapping_e > DistiAttributeEnumDirect< glsImageCodec > DistiAttributeVertexArray< Vector > DistiAttribute< T > DistiAttributeAlias DistiAttributeConnectionGlsAngularScaleDataArray DistiAttributeConnectionGlsLinearScaleDataArray DistiAttributeDictionaryAttribute DistiAttributeDictionaryAttributeSibling DistiAttributeDoubleArray DistiAttributeDynamicArray< T, showIndex > DistiAttributeEnum< containerClass, setType, getType > DistiAttributeEnumDirect< enumType > DistiAttributeFilePathClass DistiAttributeFixedString DistiAttributeFloatArray DistiAttributeHomogeneousItemArray< T > DistiAttributeMeshFaceArray DistiAttributeStdMap< Map_t > DistiAttributeStdVector< T, showIndex > DistiAttributeString DistiAttributeVertexArray< T > DistiAttributeVertexArray< Vertex > DistiAttributeViewDataArray DistiEmptyAttribute TexturePalette::DistiAttributeTexturePalette TexturePalette::DistiAttributeTexturePalette_V21

Public Types

typedef unsigned int CallbackID
 Type for unique identifiers.
 

Public Member Functions

 DistiAttributeBase (CallbackMethodCallerBase *callback, const AttributeName &name, bool localStorage)
 
virtual DistiAttributeBaseoperator= (const DistiAttributeBase &oldClass)
 
const AttributeNameName () const
 
AttributeNameName ()
 
bool LocalStorage () const
 
virtual bool Copyable () const
 
virtual bool OkToWrite () const
 
virtual bool ValueChanged ()
 
virtual void ResetValueChanged ()
 
virtual std::string ValueString ()
 
virtual void ValueString (const std::string &s)
 
virtual long ValueInt ()
 
virtual void ValueInt (long val)
 
virtual double ValueFloat ()
 
virtual void ValueFloat (double val)
 
virtual void CallCallback ()
 Calls callback CallType3 if it has been set.
 
virtual std::ostream & WriteValue (std::ostream &outstr)=0
 
virtual std::istream & ReadValue (std::istream &instr)=0
 
virtual bool operator== (const DistiAttributeBase &r)
 
template<class valType >
DistiAttributeBaseoperator<< (const valType &val)
 
template<class valType >
DistiAttributeBaseoperator>> (valType &val)
 
virtual CallbackID RegisterObserver (AttributeObserver *observer)
 
virtual void UnregisterObserver (CallbackID id)
 
virtual void NotifyObservers ()
 
- Public Member Functions inherited from WeakReferenceableMixin
void AddWeakReference (WeakReference *weakRef) override
 
void NotifyWeakReferenceDestroyed (WeakReference *ref) override
 
virtual void AddWeakReference (WeakReference *weakRef)=0
 
virtual void NotifyWeakReferenceDestroyed (WeakReference *weakReference)=0
 

Protected Attributes

AttributeName _name
 
CallbackMethodCallerBase_callback
 
ScopedPtr< DistiAttributeObserverList > _observerList
 
bool _localStorage
 
- Protected Attributes inherited from WeakReferenceableMixin
DynamicArray< WeakReference * > * _weakRefs
 

Friends

std::ostream & operator<< (std::ostream &outstr, const DistiAttributeBase &attribute)
 
std::istream & operator>> (std::istream &instr, DistiAttributeBase &attribute)
 

Additional Inherited Members

- Protected Member Functions inherited from WeakReferenceableMixin
 WeakReferenceableMixin ()
 
virtual ~WeakReferenceableMixin ()
 

Detailed Description

This is the base class for all Disti Attributes.

Constructor & Destructor Documentation

◆ DistiAttributeBase()

DistiAttributeBase ( CallbackMethodCallerBase callback,
const AttributeName name,
bool  localStorage 
)

Constructor

Parameters
callbackThe method to call when the value changes. A duplicate of the CallbackMethodCallerBase is created and stored internally.
nameThe name of the attribute
localStorageTrue if this DistiAttribute contains actual storage, rather than just a pointer to somebody elses storage

Member Function Documentation

◆ Copyable()

virtual bool Copyable ( ) const
virtual

It is not a word, but it means it is able to be copied.

Note
By default, will only copy if it contains local storage
Returns
True if it makes sense for the data to be copied.

Reimplemented in DistiAttribute< T >, DistiAttribute< std::string >, DistiAttribute< Vertex >, and DistiAttribute< unsigned char >.

◆ LocalStorage()

bool LocalStorage ( ) const
Returns
True if this object has local storage.

◆ Name() [1/2]

AttributeName & Name ( )
Returns
The name of this object.

◆ Name() [2/2]

const AttributeName & Name ( ) const
Returns
The name of this object.

◆ NotifyObservers()

virtual void NotifyObservers ( )
virtual

Triggers all observers to have their callbacks called. Typically called by the class that owns the DistiAttributeBase

Reimplemented in DistiAttributeAlias.

◆ OkToWrite()

◆ operator<<()

DistiAttributeBase & operator<< ( const valType &  val)
inline

Allow for generic access to some data types. This will NOT work for types which: s << val does not work. In general if the WriteValue is overridden, then it probably will not work.

Parameters
valThe new value to set.
Returns
The updated attribute (this).

◆ operator=()

◆ operator==()

virtual bool operator== ( const DistiAttributeBase r)
virtual

Compares name and value.

Note
This can be overriden to improve speed.
Parameters
rThe attribute to compare.
Returns
Whether or not the attributes have the same name and value.

Reimplemented in DistiAttributeAlias, DistiAttribute< T >, DistiAttribute< std::string >, DistiAttribute< Vertex >, DistiAttribute< unsigned char >, DistiAttributeVertexArray< T >, DistiAttributeVertexArray< Vector >, and DistiAttributeVertexArray< Vertex >.

◆ operator>>()

DistiAttributeBase & operator>> ( valType &  val)
inline

Allows for generic access to some data types. This will NOT work for types which: s >> val does not work. In general if the ReadValue is overridden, then it probably will not work.

Parameters
valThe value to be returned.
Returns
This attribute (unmodified, unless there are side effects).

◆ ReadValue()

virtual std::istream & ReadValue ( std::istream &  instr)
pure virtual

Pure virtual because this is specific to the data type to be contained. This should be overridden to read the data from the stream. The value read could be encoded for being read from a file as a single string, or have its own special encoding specific to its underlying type. In the case of attribute strings, this will be the GLS file encoded value. The user is responsible for encoding the value themselves, or using WriteValue which should perform encoding to maintain symmetry.

Parameters
instrThe stream to read from.
Returns
The input stream in its current state.

Implemented in DistiAttributeMeshFaceArray, DistiAttributeConnectionGlsAngularScaleDataArray, DistiAttributeConnectionGlsLinearScaleDataArray, DistiAttributeViewDataArray, DistiAttribute< T >, DistiAttribute< std::string >, DistiAttribute< Vertex >, DistiAttribute< unsigned char >, DistiAttributeEnum< containerClass, setType, getType >, DistiAttributeEnum< containerClass, const int, int >, DistiAttributeEnum< GlsEyePoint, GlsEyePoint::FovConstraintType, GlsEyePoint::FovConstraintType >, DistiAttributeEnum< GlsLightSource, int, int >, DistiAttributeEnum< containerClass, int, int >, DistiAttributeEnum< GlsSphere, glsSphereMapping_e, glsSphereMapping_e >, DistiAttributeFilePathClass, DistiAttributeCWDRelativePath, DistiAttributeUCharOrBool, DistiAttributeFloatArray, DistiAttributeDoubleArray, DistiAttributeString, DistiAttributeEncodedString, DistiAttributeEncodedStdString, DistiAttributeFixedString, DistiAttributeStdString, DistiAttributeLocation, DistiAttributeDictionaryAttribute, DistiAttributeDictionaryAttributeSibling, DistiAttributeStdMap< Map_t >, DistiAttributeVertexArray< T >, DistiAttributeVertexArray< Vector >, DistiAttributeVertexArray< Vertex >, DistiAttributeTexturePointArray, DistiAttributeAlias, DistiAttributeDynamicArray< T, showIndex >, DistiAttributeStdVector< T, showIndex >, DistiAttributeHomogeneousItemArray< T >, DistiAttributeProperty< containerT, T, SetArgT, GetReturnT >, DistiEmptyAttribute, DistiAttributeEnumDirect< enumType >, DistiAttributeEnumDirect< glsImageCodec >, GlsTextCharAttr, TexturePalette::DistiAttributeTexturePalette_V21, and TexturePalette::DistiAttributeTexturePalette.

◆ RegisterObserver()

virtual CallbackID RegisterObserver ( AttributeObserver observer)
virtual

Register a callback that is called when the value of the attribute changes. If multiple oservers are registered, they will be notified in the order they registered. DistiAttributeBase takes ownership of the observer and will delete it.

Parameters
observerthe observer to notify. It is automatically unregistered and destroyed when it becomes invalid.
Returns
an id that can be used to unregister the observer

Reimplemented in DistiAttributeAlias.

◆ ResetValueChanged()

virtual void ResetValueChanged ( )
virtual

Saves the current value for later comparison by ValueChanged().

Note
This does nothing in the base class.

Reimplemented in DistiAttributeAlias.

◆ UnregisterObserver()

virtual void UnregisterObserver ( CallbackID  id)
virtual

Unregister an observer

Parameters
idthe id returned when the observer was registered

Reimplemented in DistiAttributeAlias.

◆ ValueChanged()

virtual bool ValueChanged ( )
virtual
Note
This is not implmented in the base class and will always return true if not overridden.
Returns
True if the object's value has changed since calling ResetValueChanged().

Reimplemented in DistiAttributeAlias.

◆ ValueFloat() [1/2]

virtual double ValueFloat ( )
virtual

Allows for faster access to floating-point types than the more generic stream operators.

Note
This is only faster if it is overridden.
Returns
The double value of this attribute.

Reimplemented in DistiAttribute< T >, DistiAttribute< std::string >, DistiAttribute< Vertex >, DistiAttribute< unsigned char >, DistiAttributeAlias, and DistiAttributeProperty< containerT, T, SetArgT, GetReturnT >.

◆ ValueFloat() [2/2]

virtual void ValueFloat ( double  val)
virtual

Allows for faster access to floating-point types than the more generic stream operator.

Note
This is only faster if it is overridden.
Parameters
valThe new double value to set.

Reimplemented in DistiAttribute< T >, DistiAttribute< std::string >, DistiAttribute< Vertex >, DistiAttribute< unsigned char >, DistiAttributeAlias, and DistiAttributeProperty< containerT, T, SetArgT, GetReturnT >.

◆ ValueInt() [1/2]

◆ ValueInt() [2/2]

◆ ValueString() [1/2]

virtual std::string ValueString ( )
virtual

Here in the base class it uses WriteValue(). If this particular attribute's underlying type is a string, this returns the unencoded value, suitable for users. If a file encoded value is required, call WriteValue instead.

Returns
The std::string version of the attribute data.

Reimplemented in DistiAttributeEncodedString, DistiAttributeEncodedStdString, DistiAttributeAlias, and DistiAttributeProperty< containerT, T, SetArgT, GetReturnT >.

◆ ValueString() [2/2]

virtual void ValueString ( const std::string &  s)
virtual

Sets the value from a std::string argument. Here in the base class it uses ReadValue(). If this particular attribute's underlying type is a string, this should not be set to an encoded value. If needing to set from an encoded value, call ReadValue instead.

Parameters
sThe string value to set.

Reimplemented in DistiAttributeEncodedString, DistiAttributeEncodedStdString, DistiAttributeAlias, and DistiAttributeProperty< containerT, T, SetArgT, GetReturnT >.

◆ WriteValue()

virtual std::ostream & WriteValue ( std::ostream &  outstr)
pure virtual

Pure virtual because this is specific to the data type to be contained. This should be overridden to write the data to the stream. The value written could be encoded for writing to a file as a single string, or have its own special encoding specific to its underlying type. In the case of attribute strings, this will be the GLS file encoded value. The user is responsible for decoding the value themselves, or using ReadValue which should perform decoding to maintain symmetry.

Parameters
outstrThe stream to write to.
Returns
The output stream in its current state.

Implemented in DistiAttributeMeshFaceArray, DistiAttributeConnectionGlsAngularScaleDataArray, DistiAttributeConnectionGlsLinearScaleDataArray, DistiAttributeViewDataArray, DistiAttribute< T >, DistiAttribute< std::string >, DistiAttribute< Vertex >, DistiAttribute< unsigned char >, DistiAttributeEnum< containerClass, setType, getType >, DistiAttributeEnum< containerClass, const int, int >, DistiAttributeEnum< GlsEyePoint, GlsEyePoint::FovConstraintType, GlsEyePoint::FovConstraintType >, DistiAttributeEnum< GlsLightSource, int, int >, DistiAttributeEnum< containerClass, int, int >, DistiAttributeEnum< GlsSphere, glsSphereMapping_e, glsSphereMapping_e >, DistiAttributeFilePathClass, DistiAttributeCWDRelativePath, DistiAttributeUCharOrBool, DistiAttributeFloatArray, DistiAttributeDoubleArray, DistiAttributeString, DistiAttributeEncodedString, DistiAttributeEncodedStdString, DistiAttributeFixedString, DistiAttributeStdString, DistiAttributeLocation, DistiAttributeDictionaryAttribute, DistiAttributeDictionaryAttributeSibling, DistiAttributeStdMap< Map_t >, DistiAttributeVertexArray< T >, DistiAttributeVertexArray< Vector >, DistiAttributeVertexArray< Vertex >, DistiAttributeTexturePointArray, DistiAttributeAlias, DistiAttributeDynamicArray< T, showIndex >, DistiAttributeStdVector< T, showIndex >, DistiAttributeHomogeneousItemArray< T >, DistiAttributeProperty< containerT, T, SetArgT, GetReturnT >, DistiEmptyAttribute, DistiAttributeEnumDirect< enumType >, DistiAttributeEnumDirect< glsImageCodec >, GlsTextCharAttr, TexturePalette::DistiAttributeTexturePalette_V21, and TexturePalette::DistiAttributeTexturePalette.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  outstr,
const DistiAttributeBase attribute 
)
friend

Stream out operator.

Note
Internally it uses WriteValue().
Parameters
outstrStream to write path to.
attributeThe value to write to the stream.
Returns
The stream in its current state.

◆ operator>>

std::istream & operator>> ( std::istream &  instr,
DistiAttributeBase attribute 
)
friend

Stream in operator.

Note
Internally it uses ReadValue().
Parameters
instrThe stream to read from.
attributeThe returned value read from the stream.
Returns
The stream in its current state.

Member Data Documentation

◆ _callback

CallbackMethodCallerBase* _callback
protected

The callback which is called when the value of this object changes

◆ _localStorage

bool _localStorage
protected

_localStorage is true if this attributes data should be copied. It would typically be set false if the data is stored externally, and there is no need to copy the data through metadata. It is also used to determine if storage should be deleted.

◆ _name

AttributeName _name
protected

The name of this attribute

◆ _observerList

ScopedPtr<DistiAttributeObserverList> _observerList
protected

The list of observers to be notified when this property changes.


The documentation for this class was generated from the following file: