BaseContainer Class Reference

#include <c4d_basecontainer.h>

详细描述

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 the SDK.

Containers can store any GeData type, including custom data types. Use GetCustomDataType() to access these values in a safe manner.

It is recommended to use the available containers to store your own values as well. That way they will be automatically saved.
However, to store values in the top level of for example an object container, use a sub-container with a unique id from http://www.plugincafe.com . Inside this sub-container use whatever ids.

警告
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.
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.

Private Attributes

void *  dummy1
Int   dummy2
Int32   dummy3
Int32   dummy4
Int32   dummy5

Constructor/Destructor

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

Assign/Clone/Copy

const BaseContainer operator= (const BaseContainer &n)
BaseContainer GetClone ( COPYFLAGS flags, AliasTrans *trans) const
Bool   CopyTo ( BaseContainer *dst, COPYFLAGS flags, AliasTrans *trans) const

Flush All

void  FlushAll (void)

Id

Int32   GetId () const
void  SetId ( Int32 c_id)

Dirty

UInt32   GetDirty () const

Remove Data/Index

Bool   RemoveData ( Int32 id)
Bool   RemoveIndex ( Int32 i)

Find Index / Get Index Id

Int32   FindIndex ( Int32 id, GeData **ppData=nullptr) const
Int32   GetIndexId ( Int32 index) const

Get Data Pointer(s)

const GeData GetDataPointer ( Int32 id) const
void  GetDataPointers (const Int32 *ids, Int32 cnt, const GeData **data) const

数据

GeData GetIndexData ( Int32 index) const
GeData InsData ( Int32 id, const GeData &n)
GeData InsDataAfter ( Int32 id, const GeData &n, GeData *last)
GeData SetData ( Int32 id, const GeData &n)
const GeData GetData ( Int32 id) const

Equal/Not Equal Operators

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
UInt32   GetUInt32 ( Int32 id, UInt32 preset=0) const
Int64   GetInt64 ( Int32 id, Int64 preset=0) const
UInt64   GetUInt64 ( Int32 id, UInt64 preset=0) const
Float   GetFloat ( Int32 id, Float preset=0.0) const
void *  GetVoid ( Int32 id, void *preset=nullptr) const
void *  GetMemoryAndRelease ( Int32 id, Int &count, void *preset=nullptr)
void *  GetMemory ( Int32 id, Int &count, void *preset=nullptr) const
向量   GetVector ( Int32 id, const 向量 &preset= 向量 ()) const
矩阵   GetMatrix ( Int32 id, const 矩阵 &preset= 矩阵 ()) const
String   GetString ( Int32 id, const maxon::String &preset= maxon::String ()) const
C4DUuid   GetUuid ( Int32 id, const C4DUuid &preset= C4DUuid ( DC )) const
Filename   GetFilename ( Int32 id, const Filename &preset= Filename ()) const
BaseTime   GetTime ( Int32 id, const BaseTime &preset= BaseTime ()) const
BaseContainer   GetContainer ( Int32 id) const
BaseContainer GetContainerInstance ( Int32 id)
const BaseContainer GetContainerInstance ( Int32 id) const
BaseList2D GetLink ( Int32 id, const BaseDocument *doc, Int32 instanceof=0) const
BaseObject GetObjectLink ( Int32 id, const BaseDocument *doc) const
BaseMaterial GetMaterialLink ( Int32 id, const BaseDocument *doc) const
BaseLink GetBaseLink ( Int32 id) const
const CustomDataType GetCustomDataType ( Int32 id, Int32 datatype) const

Get Type

Int32   GetType ( Int32 id) const

Set Data

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  SetMemory ( Int32 id, void *mem, Int count)
void  SetVector ( Int32 id, const 向量 &v)
void  SetMatrix ( Int32 id, const 矩阵 &m)
void  SetString ( Int32 id, const maxon::String &s)
void  SetUuid ( Int32 id, const C4DUuid &u)
void  SetFilename ( Int32 id, const Filename &f)
void  SetTime ( Int32 id, const BaseTime &b)
void  SetContainer ( Int32 id, const BaseContainer &s)
void  SetLink ( Int32 id, C4DAtomGoal *link)

Merge Container

void  MergeContainer (const BaseContainer &src)

Get/Set Parameter

Bool   GetParameter (const DescID &id, GeData &t_data) const
Bool   SetParameter (const DescID &id, const GeData &t_data)

Sort

void  Sort ()

构造函数 & 析构函数文档编制

◆  BaseContainer() [1/3]

BaseContainer ( )

Default constructor. Creates an empty container with ID 0 .

◆  BaseContainer() [2/3]

BaseContainer ( Int32   id )
explicit

Creates a container with a specific id .

参数
[in] id The container ID.

◆  BaseContainer() [3/3]

BaseContainer ( const BaseContainer n )

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

参数
[in] n The source container.

◆  ~BaseContainer()

~ BaseContainer ( void  )

Destructor.

成员函数文档编制

◆  operator=()

const BaseContainer & operator= ( const BaseContainer n )

Assignment operator. Copies all values from the source container.

参数
[in] n The source container.
返回
The assigned source container to the left-operand container.

◆  GetClone()

BaseContainer * GetClone ( COPYFLAGS   flags ,
AliasTrans trans  
) const

Retrieves a copy of the container including all values.

参数
[in] flags The flags for the clone: COPYFLAGS
[in] trans An alias translator for the operation. Can be nullptr . The caller owns the pointed alias translator.
返回
The cloned container. The caller owns the pointed container.

◆  CopyTo()

Bool CopyTo ( BaseContainer dst ,
COPYFLAGS   flags ,
AliasTrans trans  
) const

Copies the container values into the destination container dst .

参数
[out] dst The destination container. The caller owns the pointed container.
[in] flags The flags for the clone: COPYFLAGS
[in] trans An alias translator for the operation. Can be nullptr . The caller owns the pointed alias translator.
返回
true if successful, otherwise false .

◆  FlushAll()

void FlushAll ( void  )

Clears all values in the container. The container ID is not changed.

◆  GetId()

Int32 GetId ( ) const

Gets the ID of the container.

返回
The container ID.

◆  SetId()

void SetId ( Int32   c_id )

Sets the ID of the container.

参数
[in] c_id The container ID.

◆  GetDirty()

UInt32 GetDirty ( ) const

Gets the dirty count. It is incremented when the container changes so it can be used to check if the container has changed.

返回
The dirty counter.

◆  RemoveData()

Bool RemoveData ( Int32   id )

Removes the first data item with the specified id .

参数
[in] id The ID of the value to be removed.
返回
true if any value was removed, otherwise false .

◆  RemoveIndex()

Bool RemoveIndex ( Int32   i )

Removes the data item at the specified index i .

参数
[in] i The index of the value to be removed.
返回
true if any value was removed, otherwise false .

◆  FindIndex()

Int32 FindIndex ( Int32   id ,
GeData **  ppData = nullptr  
) const

Gets the index for the value with the specified id . ppData is optionally assigned the data of the specified id .

参数
[in] id The ID of the value.
[out] ppData Assigned the data of the specified id , if not nullptr .
返回
The index of the value, or NOTOK if such value does not exists.

◆  GetIndexId()

Int32 GetIndexId ( Int32   index ) const

Gets the ID of the element at the specified index .
Can be used to browse through the container:

Int32 i = 0; while ( true ) { id = GetIndexId (i++); if ( id == NOTOK ) break ; ... }
参数
[in] index The index of the value.
返回
The ID of the value, or NOTOK if it does not exist.

◆  GetDataPointer()

const GeData * GetDataPointer ( Int32   id ) const

Retrieves a pointer to directly access the data (Read-only).

参数
[in] id The ID of the data.
返回
A pointer to the data (Read-only). The container owns the pointed data.

◆  GetDataPointers()

void GetDataPointers ( const Int32 ids ,
Int32   cnt ,
const GeData **  data  
) const

Retrieves an array of pointers to directly access the data (Read-only).

参数
[out] ids Assigned a pointer to the array of data IDs. The container owns the pointed array.
[in] cnt The number of array elements.
[out] data Assigned a pointer to the data pointer array. The container owns the pointed array.

◆  GetIndexData()

GeData * GetIndexData ( Int32   index ) const

Retrieves the data for the element at index .

参数
[in] index The index of the element.
返回
The data, or nullptr if no data was found. The container owns the pointed data. Must not be changed!

◆  InsData()

GeData * InsData ( Int32   id ,
const GeData n  
)

Inserts an arbitrary data at the specified id .

注意
Does not check if the ID already exists in the container.
参数
[in] id The ID to insert at.
[in] n The data to insert.
返回
The inserted data. The container owns the pointed data.

◆  InsDataAfter()

GeData * InsDataAfter ( Int32   id ,
const GeData n ,
GeData last  
)

Inserts an arbitrary data at the specified id after last .

参数
[in] id The ID to insert at.
[in] n The data to insert.
[in] last The data to insert after. The container owns the pointed data.
返回
The inserted data. The container owns the pointed data.

◆  SetData()

GeData * SetData ( Int32   id ,
const GeData n  
)

Sets an arbitrary data at the specified id . If a value exists under the same ID, its content will be changed.

参数
[in] id The ID of the element to set.
[in] n The data to set.
返回
The data set, or a DA_NIL data if it was not found.

◆  GetData()

const GeData & GetData ( Int32   id ) const

Retrieves the data for an element at the specified id .

参数
[in] id The ID of the element.
返回
The data, or a DA_NIL data if it was not found.

◆  operator==()

Bool operator== ( const BaseContainer d ) const

Equality operator. Checks if the containers have the same IDs, the same values and all values are equal.

注意
IDs have to be in the same order.
参数
[in] d The container to compare against.
返回
true if the containers have the same IDs, the same values and all values are equal, otherwise false .

◆  operator!=()

Bool operator!= ( const BaseContainer d ) const

Not equal operator. Checks if the containers have different IDs, different values or values are different.

参数
[in] d The container to compare against.
返回
true if the containers have different IDs, different values or values are different, otherwise false .

◆  GetBool()

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

Gets the Bool value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetInt32()

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

Gets the Int32 value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetUInt32()

UInt32 GetUInt32 ( Int32   id ,
UInt32   preset = 0  
) const

Gets the UInt32 value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetInt64()

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

Gets the Int64 value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetUInt64()

UInt64 GetUInt64 ( Int32   id ,
UInt64   preset = 0  
) const

Gets the UInt64 value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetFloat()

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

Gets the Float value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetVoid()

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

Gets the void* value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value, or preset if it does not exist.

◆  GetMemoryAndRelease()

void* GetMemoryAndRelease ( Int32   id ,
Int count ,
void *  preset = nullptr  
)

Gets the memory buffer at the specified id .

注意
In this version of GetMemory() the caller takes over the ownership of the memory block.
The memory block must be allocated with NewMem() and deallocated with DeleteMem() .
参数
[in] id The ID of the requested value.
[out] count Assigned the number of bytes in the memory buffer returned.
[in] preset Returned if the value is not available.
返回
The memory buffer, or preset if it does not exist. The caller takes over the ownership of the memory block.

◆  GetMemory()

void* GetMemory ( Int32   id ,
Int count ,
void *  preset = nullptr  
) const

Gets the memory buffer at the specified id .

参数
[in] id The ID of the requested value.
[out] count Assigned the number of bytes in the memory buffer returned.
[in] preset Returned if the value is not available.
返回
The memory buffer, or preset if it does not exist. The container owns the pointed memory block.

◆  GetVector()

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

Gets the 向量 value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetMatrix()

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

Gets the 矩阵 value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetString()

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

Gets the String value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetUuid()

C4DUuid GetUuid ( Int32   id ,
const C4DUuid preset = C4DUuid(DC)  
) const

Gets the C4DUuid value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetFilename()

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

Gets the Filename value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetTime()

BaseTime GetTime ( Int32   id ,
const BaseTime preset = BaseTime()  
) const

Gets the BaseTime value at the specified id .

参数
[in] id The ID of the requested value.
[in] preset Returned if the value is not available.
返回
The value.

◆  GetContainer()

BaseContainer GetContainer ( Int32   id ) const

Gets a copy of the sub-container at the specified id .

参数
[in] id The ID of the requested sub-container.
返回
The sub-container, or an empty container if it does not exist.

◆  GetContainerInstance() [1/2]

BaseContainer * GetContainerInstance ( Int32   id )

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

参数
[in] id The ID of the requested sub-container ID.
返回
A pointer to the sub-container, or nullptr if it does not exist. The container owns the pointed sub-container.

◆  GetContainerInstance() [2/2]

const BaseContainer * GetContainerInstance ( Int32   id ) const

Gets a read-only pointer to the sub-container with the specified id .

由于
R17.032
参数
[in] id The ID of the requested sub-container ID.
返回
A pointer to the sub-container, or nullptr if it does not exist. The container owns the pointed sub-container.

◆  GetLink()

BaseList2D * GetLink ( Int32   id ,
const BaseDocument doc ,
Int32   instanceof = 0  
) const

Gets a linked baselist node at the specified id . Equivalent to BaseLink::GetLink() .
instanceof is specified, nullptr is returned if the node is not of this type.

参数
[in] id The ID of the requested value.
[in] doc The document to evaluate the link in. The caller owns the pointed document.
[in] instanceof Set this to a node type to only return the link if it is of this type.
返回
The linked object, or nullptr if the link is broken. The document owns the pointed linked baselist.

◆  GetObjectLink()

BaseObject * GetObjectLink ( Int32   id ,
const BaseDocument doc  
) const

Gets a linked object at the specified id .

参数
[in] id The ID of the requested object link.
[in] doc The document to evaluate the object link in. The caller owns the pointed document.
返回
The linked object, or nullptr if the link is broken. The document owns the pointed linked object.

◆  GetMaterialLink()

BaseMaterial * GetMaterialLink ( Int32   id ,
const BaseDocument doc  
) const

Gets a linked material at the specified id .

参数
[in] id The ID of the requested link.
[in] doc The document to evaluate the link in. The caller owns the pointed document.
返回
The linked material, or nullptr if the link is broken. The document owns the pointed linked material.

◆  GetBaseLink()

BaseLink * GetBaseLink ( Int32   id ) const

Gets the BaseLink at the specified id .

参数
[in] id The ID of the requested link.
返回
The link, or nullptr if there is no link stored. The container owns the pointed link.

◆  GetCustomDataType()

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

Gets the CustomDataType value at the specified id .

参数
[in] id The ID of the requested custom datatype.
[in] datatype The datatype type ID.
返回
The custom datatype, or nullptr if it does not exist or the wrong datatype was specified. The container owns the pointed custom datatype.

◆  GetType()

Int32 GetType ( Int32   id ) const

Gets the type of the element at the specified id .

参数
[in] id The ID of the element.
返回
The type of the element: DA_TYPES

◆  SetBool()

void SetBool ( Int32   id ,
Bool   b  
)

设置 Bool value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] b The new or inserted value.

◆  SetInt32()

void SetInt32 ( Int32   id ,
Int32   l  
)

设置 Int32 value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] l The new or inserted value.

◆  SetUInt32()

void SetUInt32 ( Int32   id ,
UInt32   l  
)

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

参数
[in] id The ID of the value to set.
[in] l The new or inserted value.

◆  SetInt64()

void SetInt64 ( Int32   id ,
Int64   l  
)

设置 Int64 value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] l The new or inserted value.

◆  SetUInt64()

void SetUInt64 ( Int32   id ,
UInt64   l  
)

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

参数
[in] id The ID of the value to set.
[in] l The new or inserted value.

◆  SetFloat()

void SetFloat ( Int32   id ,
Float   r  
)

设置 Float value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] r The new or inserted value.

◆  SetVoid()

void SetVoid ( Int32   id ,
void *  v  
)

设置 void* value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] v The new or inserted value.

◆  SetMemory()

void SetMemory ( Int32   id ,
void *  mem ,
Int   count  
)

Sets the memory block at the specified id to mem , or inserts it if it did not exist.

参数
[in] id The ID of the value to set.
[in] mem The memory buffer. The container takes the ownership over the memory buffer.
[in] count The number of bytes in mem .

◆  SetVector()

void SetVector ( Int32   id ,
const 向量 v  
)

设置 向量 value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] v The new or inserted value.

◆  SetMatrix()

void SetMatrix ( Int32   id ,
const 矩阵 m  
)

设置 矩阵 value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] m The new or inserted value.

◆  SetString()

void SetString ( Int32   id ,
const maxon::String s  
)

设置 String value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] s The new or inserted value.

◆  SetUuid()

void SetUuid ( Int32   id ,
const C4DUuid u  
)

设置 C4DUuid value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] u The new or inserted value.

◆  SetFilename()

void SetFilename ( Int32   id ,
const Filename f  
)

设置 Filename value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] f The new or inserted value.

◆  SetTime()

void SetTime ( Int32   id ,
const BaseTime b  
)

设置 BaseTime value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] b The new or inserted value.

◆  SetContainer()

void SetContainer ( Int32   id ,
const BaseContainer s  
)

Sets the sub-container value at the specified id , or inserts it if it does not exist.

参数
[in] id The ID of the value to set.
[in] s The new or inserted value.

◆  SetLink()

void SetLink ( Int32   id ,
C4DAtomGoal link  
)

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

参数
[in] id The ID of the value to set.
[in] link The new or inserted value.

◆  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.

参数
[in] src The source container to merge.

◆  GetParameter()

Bool GetParameter ( const DescID id ,
GeData t_data  
) const

Retrieves the GeData for the specified parameter description id .

参数
[in] id The ID of the requested data.
[out] t_data Assigned the retrieved data.
返回
true if successful, otherwise false .

◆  SetParameter()

Bool SetParameter ( const DescID id ,
const GeData t_data  
)

设置 GeData for the specified parameter description id .

参数
[in] id The ID of the parameter to set.
[in] t_data The data to set or insert.

◆  Sort()

void Sort ( )

Sorts the container entries by ID.

注意
This function sorts the strings and remove any other value. (keeping the ID)

Member Data Documentation

◆  dummy1

void* dummy1 private

◆  dummy2

Int dummy2
private

◆  dummy3

Int32 dummy3
private

◆  dummy4

Int32 dummy4
private

◆  dummy5

Int32 dummy5
private
NOTOK
#define NOTOK
定义: ge_sys_math.h:265
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
BaseContainer::GetIndexId
Int32 GetIndexId(Int32 index) const
定义: c4d_basecontainer.h:197