BaseContainer Class Reference

#include <c4d_basecontainer.h>

Inheritance diagram for BaseContainer:

Constructors

 BaseContainer ()
 
 BaseContainer (Int32 id)
 
 BaseContainer (const BaseContainer &n)
 

Operators

const BaseContaineroperator= (const BaseContainer &n)
 
Bool operator== (const BaseContainer &d) const
 
Bool operator!= (const BaseContainer &d) const
 

Get Data

Bool GetBool (Int32 id, Bool preset=false) const
 
Int32 GetInt32 (Int32 id, Int32 preset=0) const
 
Int64 GetInt64 (Int32 id, Int64 preset=0) const
 
void * GetVoid (Int32 id, void *preset=nullptr) const
 
Float GetFloat (Int32 id, Float preset=0.0) const
 
Vector GetVector (Int32 id, const Vector &preset=Vector()) const
 
Matrix GetMatrix (Int32 id, const Matrix &preset=Matrix()) const
 
String GetString (Int32 id, const String &preset=String()) const
 
BaseTime GetTime (const Int32 id)
 
BaseList2DGetLink (const Int32 id)
 
Filename GetFilename (Int32 id, const Filename &preset=Filename()) const
 
const CustomDataTypeGetCustomDataType (Int32 id, Int32 datatype) const
 
BaseContainer GetContainer (Int32 id) const
 
BaseContainerGetContainerInstance (Int32 id) const
 
BaseObjectGetObjectLink (Int32 id) const
 
Bool GetParameter (const DescID &id, GeData &data)
 

Set Data

void MergeContainer (const BaseContainer &src)
 
void SetBool (Int32 id, Bool b)
 
void SetInt32 (Int32 id, Int32 l)
 
void SetUInt32 (Int32 id, UInt32 l)
 
void SetInt64 (Int32 id, Int64 l)
 
void SetUInt64 (Int32 id, UInt64 l)
 
void SetFloat (Int32 id, Float r)
 
void SetVoid (Int32 id, void *v)
 
void SetVector (Int32 id, const Vector &v)
 
void SetMatrix (Int32 id, const Matrix &m)
 
void SetString (Int32 id, const String &str)
 
void SetTime (const Int32 id, const BaseTime &s)
 
void SetLink (const Int32 id, BaseList2D *bl)
 
void SetFilename (const Int32 id, const Filename &s)
 
void SetContainer (const Int32 id, const BaseContainer &bc)
 
Bool SetParameter (const DescID &id, const GeData &t_data)
 

Additional Inherited Members

- Public Member Functions inherited from GeContainer
 ~GeContainer ()
 
void SDKInit (Int32 id)
 
void ClearDirty ()
 
void SetDirty ()
 
void RestoreDirty (UInt32 dirty)
 
Bool IsDirty ()
 
UInt32 GetDirty ()
 
BaseContainerGetClone (COPYFLAGS flags, AliasTrans *aliastrans) const
 
void CopyTo (BaseContainer *dest, COPYFLAGS flags, AliasTrans *aliastrans) const
 
void FlushAll ()
 
Int32 GetId () const
 
void SetId (Int32 c_id)
 
GeDataInsData (Int32 id, const GeData &n)
 
GeDataInsDataAfter (Int32 id, const GeData &n, GeData *last)
 
BaseContainerInsContainer (Int32 id, const BaseContainer &gc)
 
GeDataSetData (Int32 id, const GeData &n)
 
Bool RemoveData (Int32 id)
 
Bool RemoveIndex (Int32 i)
 
Int32 FindIndex (Int32 id) const
 
Int32 GetIndexId (Int32 index) const
 
GeDataGetIndexData (Int32 index) const
 
const GeDataGetData (Int32 id) const
 
- Protected Member Functions inherited from GeContainer
 GeContainer ()
 
 GeContainer (Int32 id)
 
 GeContainer (const BaseContainer &n)
 
void _SDKInit (Int32 id)
 
void _ClearDirty ()
 
void _SetDirty ()
 
Bool _IsDirty ()
 
UInt32 _GetDirty ()
 
BaseContainer_GetClone (COPYFLAGS flags, AliasTrans *aliastrans) const
 
void _CopyTo (BaseContainer *dest, COPYFLAGS flags, AliasTrans *aliastrans) const
 
const GeContaineroperator= (const GeContainer &n)
 
void _FlushAll ()
 
Int32 _GetId () const
 
void _SetId (Int32 c_id)
 
GeData_InsData (Int32 id, const GeData &n)
 
GeData_InsDataAfter (Int32 id, const GeData &n, GeData *last)
 
BaseContainer_InsContainer (Int32 id, const BaseContainer &gc)
 
GeData_SetData (Int32 id, const GeData &n)
 
Bool _RemoveData (Int32 id)
 
Bool _RemoveIndex (Int32 i)
 
Int32 _FindIndex (Int32 id) const
 
Int32 _GetIndexId (Int32 index) const
 
GeData_GetIndexData (Int32 index) const
 
const GeData_GetData (Int32 id) const
 
- Protected Attributes inherited from GeContainer
GeDataListFirst
 
GeDataListLast
 
Int32 Id
 
UInt16 dirty_sum
 
UInt16 dirty_last
 
void * future_enhancements
 

Detailed Description

A container is a collection of individual values. Each value has its own ID and type. Container can also carry any number of child containers.
90% of Cinema 4D's internal values are stored in containers and all messages are working with container, so this class is an essential part of Melange.
Containers can store any GeData type, including custom data types. Use GetCustomDataType() to access these values in a safe manner.

Warning
Keep in mind that there is no guarantee for a value to be in the container. Use default values whenever possible when accessing container's ID data.
Please use the typed access methods (for example GetBool()) whenever possible, instead of the low-level GetData().
Once a container value has been set using one type you must neither try to access it using another type, nor overwrite it with a value of another type! Using the wrong access will not crash, but it is illegal.

Example: Set and get data.

if (op->SetParameter(12345, GeData(Vector(1.0,2.0,3.0))))
{
if (op->GetParameter(12345, data))
{
Vector vec = data.GetVector();
printf(" - VTEST: %f %f %f\n", vec.x, vec.y, vec.z);
data = 5.0;
if (op->SetParameter(DescID(DescLevel(12345, DTYPE_VECTOR,0), DescLevel(VECTOR_Y)), data))
{
if (op->GetParameter(12345, data))
{
vec = data.GetVector();
printf(" - VTEST: %f %f %f\n", vec.x, vec.y, vec.z);
}
if (op->GetParameter(DescID(DescLevel(12345, DTYPE_VECTOR,0), DescLevel(VECTOR_Z)), data))
printf(" - VTEST: %f", data.GetReal());
}
}
}

Constructor & Destructor Documentation

◆ BaseContainer() [1/3]

Default constructor. Creates an empty container with ID 0.

◆ BaseContainer() [2/3]

Creates a container with a specific id.

Parameters
[in]idThe container ID.

◆ BaseContainer() [3/3]

BaseContainer ( const BaseContainer n)

Copy constructor. Creates a container with all the IDs and values from the source one.

Parameters
[in]nThe source container.

Member Function Documentation

◆ operator=()

const BaseContainer& operator= ( const BaseContainer n)

Assignment operator. Copies all values from the source container.

Parameters
[in]nThe source container.
Returns
The assigned source container to the left-operand container.

◆ operator==()

Bool operator== ( const BaseContainer d) const

Equal operator.

Parameters
[in]dThe container to compare against.
Returns
true if the compared containers have the same IDs, have the same values and all values are equal, otherwise false.

◆ operator!=()

Bool operator!= ( const BaseContainer d) const

Not equal operator.

Parameters
[in]dThe container to compare against.
Returns
true if the compared containers have different IDs, have different values or values are different, otherwise false.

◆ GetBool()

Bool GetBool ( Int32  id,
Bool  preset = false 
) const

Gets the Bool value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetInt32()

Int32 GetInt32 ( Int32  id,
Int32  preset = 0 
) const

Gets the Int32 value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetInt64()

Int64 GetInt64 ( Int32  id,
Int64  preset = 0 
) const

Gets the Int64 value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetVoid()

void* GetVoid ( Int32  id,
void *  preset = nullptr 
) const

Gets the void* value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value, or preset if it does not exist.

◆ GetFloat()

Float GetFloat ( Int32  id,
Float  preset = 0.0 
) const

Gets the Float value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetVector()

Vector GetVector ( Int32  id,
const Vector preset = Vector() 
) const

Gets the Vector value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetMatrix()

Matrix GetMatrix ( Int32  id,
const Matrix preset = Matrix() 
) const

Gets the Matrix value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetString()

String GetString ( Int32  id,
const String preset = String() 
) const

Gets the String value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetTime()

BaseTime GetTime ( const Int32  id)

Gets the BaseTime value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
Returns
The value.

◆ GetLink()

BaseList2D* GetLink ( const Int32  id)

Gets the BaseList2D value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
Returns
The value.

◆ GetFilename()

Filename GetFilename ( Int32  id,
const Filename preset = Filename() 
) const

Gets the Filename value with the specified id in the container.

Parameters
[in]idThe ID of the requested value.
[in]presetReturned if the value is not available.
Returns
The value.

◆ GetCustomDataType()

const CustomDataType* GetCustomDataType ( Int32  id,
Int32  datatype 
) const

Gets the custom data type value with the specified id in the container.

Parameters
[in]idThe ID of the requested custom data type value.
[in]datatypeThe custom data type's ID.
Returns
The custom data type value, or nullptr. The container owns the pointed custom data type value.

◆ GetContainer()

BaseContainer GetContainer ( Int32  id) const

Gets a copy of the sub-container with the specified id, or an empty container if it does not exist.

Parameters
[in]idThe ID of the requested sub-container.
Returns
The sub-container.

◆ GetContainerInstance()

BaseContainer* GetContainerInstance ( Int32  id) const

Gets a pointer to the sub-container with the specified id. Changes to the pointed container are reflected in the stored sub-container.

Parameters
[in]idThe ID of the requested sub-container ID.
Returns
A pointer to the sub-container, or nullptr if it doesn't exist.

◆ GetObjectLink()

BaseObject* GetObjectLink ( Int32  id) const

Gets a linked object for the link stored at the specified id.

Parameters
[in]idThe ID of the requested link.
Returns
The linked object, or nullptr if the link is broken.

◆ GetParameter()

Bool GetParameter ( const DescID id,
GeData data 
)

Gets the GeData with the specified parameter id in the container.

Parameters
[in]idThe ID of the requested value.
[in]dataAssigned the retrieved data.
Returns
true if the data was retrieved, otherwise false.

◆ MergeContainer()

void MergeContainer ( const BaseContainer src)

Stores the values from src in the container, overwriting any elements with the same IDs and keeping the rest.

Parameters
[in]srcThe source container to merge.

◆ SetBool()

void SetBool ( Int32  id,
Bool  b 
)

Sets the Bool value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]bThe new or inserted value.

◆ SetInt32()

void SetInt32 ( Int32  id,
Int32  l 
)

Sets the Int32 value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]lThe new or inserted value.

◆ SetUInt32()

void SetUInt32 ( Int32  id,
UInt32  l 
)

Sets the UInt32 value at the specified id, or inserts it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]lThe new or inserted value.

◆ SetInt64()

void SetInt64 ( Int32  id,
Int64  l 
)

Set the Int64 value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]lThe new or inserted value.

◆ SetUInt64()

void SetUInt64 ( Int32  id,
UInt64  l 
)

Sets the UInt64 value at the specified id, or inserts it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]lThe new or inserted value.

◆ SetFloat()

void SetFloat ( Int32  id,
Float  r 
)

Sets the Float value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]rThe new or inserted value.

◆ SetVoid()

void SetVoid ( Int32  id,
void *  v 
)

Sets the void * value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]vThe new or inserted value.

◆ SetVector()

void SetVector ( Int32  id,
const Vector v 
)

Sets the Vector value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]vThe new or inserted value.

◆ SetMatrix()

void SetMatrix ( Int32  id,
const Matrix m 
)

Sets the Matrix value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]mThe new or inserted value.

◆ SetString()

void SetString ( Int32  id,
const String str 
)

Sets the String value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]strThe new or inserted value.

◆ SetTime()

void SetTime ( const Int32  id,
const BaseTime s 
)

Sets the BaseTime value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]sThe new or inserted value.

◆ SetLink()

void SetLink ( const Int32  id,
BaseList2D bl 
)

Sets the BaseList2D link value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]blThe new or inserted value.

◆ SetFilename()

void SetFilename ( const Int32  id,
const Filename s 
)

Sets the Filename value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]sThe new or inserted value.

◆ SetContainer()

void SetContainer ( const Int32  id,
const BaseContainer bc 
)

Sets the BaseContainer value with the specified id, or insert it if it does not exist.

Parameters
[in]idThe ID of the value to set.
[in]bcThe new or inserted value.

◆ SetParameter()

Bool SetParameter ( const DescID id,
const GeData t_data 
)

Sets the GeData for the specified parameter id in the container.

Parameters
[in]idThe ID of the parameter to set.
[in]t_dataThe data value to set or insert.