UserDataRaw

Functions

SET_CID

IMPLEMENT_AS

SET_CHUNK_SIGNATURE

IMPLEMENT_CHUNKINTERPRETER

UserDataRaw

UserDataRaw

~UserDataRaw

void *

GetRawData

RED::uint64

GetRawDataSize

const String &

GetRawDataLabel

void

UnlinkFrom

RED_RC

Save

Detailed Description

class UserDataRaw : public RED::UserData, public RED::IChunkSaver

Implementation class for raw custom user data.

@related Saving and Reloading a Custom Container , class RED::UserData

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.

Public Functions

SET_CID(CID_class_REDUserDataRaw)
IMPLEMENT_AS()
SET_CHUNK_SIGNATURE (0x0000000B)
IMPLEMENT_CHUNKINTERPRETER()
UserDataRaw()

Default constructor.

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.

virtual ~UserDataRaw()

Default destructor.

void *GetRawData() const
Returns

a pointer to the raw data.

RED::uint64 GetRawDataSize() const
Returns

the size of the raw data in bytes.

const RED::String &GetRawDataLabel() const
Returns

the label associated to the raw data.

virtual void 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.

virtual RED_RC 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_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.