class RED::UserDataRaw

Implementation class for raw custom user data. More...

#include <REDUserDataRaw.h>

Inherits: IChunkSaver and UserData.

Public functions:

UserDataRaw ( )
UserDataRaw ( void * iData, RED::uint64 iSize, const RED::String & iLabel, bool iOwner )
virtual ~UserDataRaw ( )
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 ( )
void *GetRawData ( ) const
const RED::String &GetRawDataLabel ( ) const
RED::uint64GetRawDataSize ( ) const
IMPLEMENT_CHUNKINTERPRETER ( )
virtual RED_RCSave ( RED::IStream * iStream, RED::StreamingPolicy & iPolicy, int iState = -1 ) const
virtual voidUnlinkFrom ( RED::Object * iObject )

Public static functions:

static RED::CIDGetClassID ( )

Protected variables:

void *_data
RED::String_label
bool_owner
RED::uint64_size

Detailed description:

Implementation class for raw custom user data.

This class implements the RED::UserData concept for raw data (i.e non typed data). This can be useful to add custom information to some RED::Object instances implementing the RED::IUserData interface.

The user must supply a pointer to an array of data, the size of the array and a label identifying the data. The label will be needed by an application that wants to interpret loaded custom data.

Note those raw custom data will be automatically saved to and reloaded from RED files.

Functions documentation

Default constructor.

public RED::UserDataRaw::UserDataRaw(void *iData,
RED::uint64iSize,
const RED::String &iLabel,
booliOwner
)

Constructor.

The constructed RED::UserDataRaw instance does not become the owner of the passed data until the caller explicitely request it setting the owner flag to true.

If the instance becomes the owner of the data, those will be automatically destroyed when the instance gets destroyed. Otherwise, it's the user responsibility to properly destroy the data when they are no more needed.

Note that in the case of becoming the owner of the data, the data memory should have been allocated using the built-in REDsdk memory allocator.

Parameters:

iData:pointer to the raw data.
iSize:size of the raw data in bytes.
iLabel:string identifying the raw data.
iOwner:flag indicating if the instance becomes the owner of the passed data.

Default destructor.

public virtual void * RED::UserDataRaw::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::UserData::As.

public virtual const void * RED::UserDataRaw::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::UserData::As.

template< class T_As > public const T_As * RED::UserDataRaw::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::UserData::As.

template< class T_As > public T_As * RED::UserDataRaw::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::UserData::As.

public void * RED::UserDataRaw::GetRawData() const

Returns:

a pointer to the raw data.

Returns:

the label associated to the raw data.

Returns:

the size of the raw data in bytes.
public virtual RED_RC RED::UserDataRaw::Save(RED::IStream *iStream,
RED::StreamingPolicy &iPolicy,
intiState = -1
)const

Saves the object content as one or more chunks in the given stream.

Parameters:

iStream:Pointer to the stream where the data must be saved.
iPolicy:Reference to the streaming policy to be used.
iState:Optional state number parameter at which the data to be saved must be retrieved. Default is set to 0 (for current state).

Returns:

RED_OK on success,
RED_FILE_WRITE_ERROR on a file write error (if iStream is a file stream),
RED_ALLOC_FAILURE on a memory allocation error,
RED_FAIL otherwise.

Implements: RED::IChunkSaver::Save.

public virtual void RED::UserDataRaw::UnlinkFrom(RED::Object *iObject)

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.

Implements: RED::UserData::UnlinkFrom.

Variables documentation

protected void * RED::UserDataRaw::_data

Pointer to the raw data.

String identifying the data.

Flag indicating if our instance is the owner of the data or not.

Size of the memory pointed to by _data.