class RED::UserData

Generic class for custom user data. More...

#include <REDUserData.h>

Inherits: Object.

Inherited by: UserDataRaw.

Public functions:

UserData ( )
virtual ~UserData ( )
virtual void *As ( const RED::CID & iCID )
virtual const void *As ( const RED::CID & iCID ) const
template< class T_As > const T_As *As ( ) const
template< class T_As > T_As *As ( )
virtual voidUnlinkFrom ( RED::Object * iObject ) = 0

Public static functions:

static RED::CIDGetClassID ( )

Detailed description:

Generic class for custom user data.

The RED::UserData is a data container that can be freely associated to any scene graph object. Shapes, materials fonts and images expose the RED::IUserData interface, so that user data can be stored on them, according to the application needs.

As long as a class inheriting RED::UserData implements valid chunk writing and reading methods, instances of this class will be automatically loaded from and saved to .red files.

Functions documentation

Default constructor.

public virtual RED::UserData::~UserData()

Default destructor.

Reimplements: RED::Object::GetClassID.

Reimplemented by: RED::UserDataRaw::GetClassID.

public virtual void * RED::UserData::As(const RED::CID &iCID)

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::Object::As.

Reimplemented by: RED::UserDataRaw::As.

public virtual const void * RED::UserData::As(const RED::CID &iCID) const

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::Object::As.

Reimplemented by: RED::UserDataRaw::As.

template< class T_As > public const T_As * RED::UserData::As() const

Template version of the as const method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to a const instance of class T on success, NULL otherwise.

Reimplements: RED::Object::As.

Reimplemented by: RED::UserDataRaw::As.

template< class T_As > public T_As * RED::UserData::As()

Template version of the as method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to an instance of class T on success, NULL otherwise.

Reimplements: RED::Object::As.

Reimplemented by: RED::UserDataRaw::As.

public virtual void RED::UserData::UnlinkFrom(RED::Object *iObject) = 0

Method called when the user data are unlinked from a RED::Object instance.

A RED::UserData object can be linked exclusively to a RED::IUserData instance by making the latter the owner of the former (see RED::IUserData::SetUserData). In such a case, destroying the RED::IUserData instance will destroy the linked RED::UserData too. If not the owner, destroying the RED::IUserData will automatically call the UnlinkFrom method to inform the RED::UserData object of the lost of connectivity with the RED::IUserData instance.

Note that a call to UnlinkFrom can also occur when the RED::IUserData instance gets linked with another RED::UserData object, replacing the current connection.

Parameters:

iObject:Pointer to the object from which the user data are being unlinked.

Implemented by: RED::UserDataRaw::UnlinkFrom.