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::uint64 | GetRawDataSize ( ) const |
IMPLEMENT_CHUNKINTERPRETER ( ) | |
virtual RED_RC | Save ( RED::IStream * iStream, RED::StreamingPolicy & iPolicy, int iState = -1 ) const |
virtual void | UnlinkFrom ( RED::Object * iObject ) |
Public static functions:
static RED::CID | GetClassID ( ) |
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
public RED::UserDataRaw::UserDataRaw | ( | ) |
Default constructor.
public RED::UserDataRaw::UserDataRaw | ( | void * | iData, |
RED::uint64 | iSize, | ||
const RED::String & | iLabel, | ||
bool | iOwner | ||
) |
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. |
public virtual RED::UserDataRaw::~UserDataRaw | ( | ) |
Default destructor.
public static RED::CID RED::UserDataRaw::GetClassID | ( | ) |
Reimplements: RED::IChunkSaver::GetClassID.
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:
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:
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:
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:
Reimplements: RED::UserData::As.
public void * RED::UserDataRaw::GetRawData | ( | ) const |
Returns:
public const RED::String & RED::UserDataRaw::GetRawDataLabel | ( | ) const |
Returns:
public RED::uint64 RED::UserDataRaw::GetRawDataSize | ( | ) const |
Returns:
public virtual RED_RC RED::UserDataRaw::Save | ( | RED::IStream * | iStream, |
RED::StreamingPolicy & | iPolicy, | ||
int | iState = -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_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
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.