About
A BaseContainer is a collection of individual values. Each value has its own ID and type. A BaseContainer 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 containers, so this class is an essential part of the SDK. Containers can store any GeData type, including custom data types. It is recommended to use the available containers to store values in custom NodeData based plugins.
- 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.
-
Use the typed access methods (for example BaseContainer::GetBool()) whenever possible, instead of the low-level BaseContainer::GetData(). See Access.
-
Once a container value has been set using one type one 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.
- Note
- To browse through all elements of a BaseContainer use the class BrowseContainer.
Access
Every BaseList2D based object of the Cinema 4D API has a BaseContainer that stores its data. This BaseContainer can be accessed with:
See BaseList2D Manual.
- Note
- Object parameters should be edited with C4DAtom::GetParameter() / C4DAtom::SetParameter(). Not all parameters of an object may be stored in the BaseContainer.
if (rdata == nullptr)
if (bitmap == nullptr)
BaseContainer elements are also often used as an argument in a function call.
Copy
The complete content of a BaseContainer object can be copied to another object:
It is also possible to copy a BaseContainer using the copy constructor.
- Note
- To merge containers see BaseContainer::MergeContainer() in chapter Functionality.
Data
ID
A BaseContainer can have an ID. This ID can be used to identify the container.
{
{
{
_interactStart = true;
break;
}
{
if (_undoStarted)
{
_undoStarted = false;
}
_interactStart = false;
break;
}
}
return SUPER::Message(msg, result);
}
Access
A BaseContainer stores its data using GeData objects. It is possible to access these GeData objects or the stored values directly using typed access functions. It is recommended to prefer the typed access functions.
A copy of a GeData element can be obtained with:
- Note
- The DescLevel::id property is used as the actual ID.
The GeData elements are also accessible via:
For fast access read-only pointers to the GeData elements are accessible:
Int32 ids[] = { 100, 200 };
if (data[0])
if (data[1])
A GeData element is also accessible via its index in the BaseContainer:
if (first != nullptr)
if (second != nullptr)
New GeData elements can be added to the BaseContainer:
To access the values of primitive data types, these access functions are available:
See also Primitive Data Types Manual (Classic).
A BaseContainer can store a void pointer.
- Note
- This should not be used to store a reference to a C4DAtom based element; instead a BaseLink should be used.
SomeObject*
const obj =
static_cast<SomeObject*
>(bc.
GetVoid(100));
A BaseContainer can store raw memory:
if (size == 0)
{
}
else
{
void* pArray = myArray.Disconnect().Begin().GetPtr();
if (pArray == nullptr)
}
if (memFromContainer != nullptr && size > 0)
{
if (myMem == nullptr)
myblock.
Set(myMem, size);
myOtherArray.
Connect(myblock, size);
}
for (auto& value : myOtherArray)
A BaseContainer offers also access functions for mathematical data types:
See also Vector Manual (Classic) and Matrix Manual (Classic).
A BaseContainer offers further access functions for typical Cinema 4D data types:
See also String Manual (Classic) and Filename Manual.
See also BaseTime Manual.
A BaseContainer also offers special functions to store and handle BaseLink objects:
See also BaseLink Manual.
if (mat)
if (obj)
if (link)
A BaseContainer object can also store further sub-containers:
A BaseContainer can also store custom data types. To set the value of the custom data type a GeData object is needed.
if (date == nullptr)
if (dateTimeData)
{
}
These functions can be used to limit the values of a Vector or Float value inside a BaseContaier:
- Note
- These functions simply apply ClampValue(), see also Mathematical Functions Manual (Classic).
Index
The elements stored within a BaseContainer are accessible through their index and their ID:
See also BaseContainer::GetIndexData() above. To loop through values see also BrowseContainer.
while (true)
{
break;
else
}
Remove
Elements can be removed from a BaseContainer:
Functionality
Several operations can be performed on a BaseContainer object.
Compare
Two BaseContainer are identical if they have the same ID, the same number of entries and if the entries are also identical and in the same order.
Detect Changes
The dirty state of a BaseContainer changes incrementally when a value stored in the BaseContainer is changed.
BrowseContainer
The BrowseContainer class can be used to browse through the values stored in a BaseContainer. See also Index.
while (browse.GetNext(&id, &dat))
{
if (dat != nullptr)
{
}
}
Disc I/O
A BaseContainer can be stored in a HyperFile.
if (hf == nullptr)
{
}
else
{
}
See also HyperFile Manual on BaseContainer.
Further Reading
const GeData & GetData(Int32 id) const
Definition: c4d_basecontainer.h:262
BaseContainer GetData()
Definition: c4d_baselist.h:2296
void SetDateTime(const DateTime &d, Bool bSetDate=true, Bool bSetTime=true)
@ OK
Image loaded/created.
Bool CopyTo(BaseContainer *dst, COPYFLAGS flags, AliasTrans *trans) const
Definition: c4d_basecontainer.h:110
BaseObject * GetObjectLink(Int32 id, const BaseDocument *doc) const
void SetMemory(Int32 id, void *mem, Int count)
Definition: c4d_basecontainer.h:548
Definition: c4d_baselist.h:2174
BaseDocument * GetActiveDocument(void)
MAXON_ATTRIBUTE_FORCE_INLINE void Connect(const Block< T > &block, Int capacity=0)
Definition: basearray.h:1477
GeData * SetData(Int32 id, const GeData &n)
Definition: c4d_basecontainer.h:255
#define DeleteObj(obj)
Definition: newobj.h:159
maxon::Int Int
Definition: ge_sys_math.h:64
void SetCustomDataType(Int32 datatype, const CustomDataType &v)
Definition: c4d_gedata.h:664
BaseMaterial * GetMaterialLink(Int32 id, const BaseDocument *doc) const
RENDERRESULT
Definition: ge_prepass.h:413
static String UIntToString(UInt32 v)
Definition: c4d_string.h:511
GeData * InsDataAfter(Int32 id, const GeData &n, GeData *last)
Definition: c4d_basecontainer.h:247
void SetVoid(Int32 id, void *v)
Definition: c4d_basecontainer.h:540
Definition: c4d_baseobject.h:224
GeData * GetIndexData(Int32 index) const
Definition: c4d_basecontainer.h:229
Definition: lib_description.h:328
Int32 GetType(void) const
Definition: c4d_gedata.h:407
@ ANY
Show an error dialog for any error.
void SetString(Int32 id, const maxon::String &s)
Definition: c4d_basecontainer.h:569
Int32 minute
Minute.
Definition: customgui_datetime.h:67
maxon::UInt32 UInt32
Definition: ge_sys_math.h:61
RENDERRESULT RenderDocument(BaseDocument *doc, const BaseContainer &rdata, ProgressHook *prog, void *private_data, BaseBitmap *bmp, RENDERFLAGS renderflags, BaseThread *th, WriteProgressHook *wprog=nullptr, void *data=nullptr)
BaseMaterial * GetActiveMaterial(void)
RENDERFLAGS
Definition: ge_prepass.h:4496
void GetDateTimeNow(DateTime &t)
BaseList2D * GetLink(Int32 id, const BaseDocument *doc, Int32 instanceof=0) const
Definition: c4d_basecontainer.h:443
@ DA_NIL
No value.
Definition: c4d_gedata.h:38
@ NONE
No check if file exists under case-sensitive drives.
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
BaseTag * GetActiveTag(void)
Definition: customgui_datetime.h:156
Definition: basearray.h:411
void Set(T *ptr, Int size, Int stride=(STRIDED &&GENERIC) ? -1 :SIZEOF(StrideType))
Definition: block.h:520
Bool RemoveData(Int32 id)
Definition: c4d_basecontainer.h:160
void * GetMemoryAndRelease(Int32 id, Int &count, void *preset=nullptr)
Definition: c4d_basecontainer.h:354
static IMAGERESULT Init(BaseBitmap *&res, const Filename &name, Int32 frame=-1, Bool *ismovie=nullptr, BitmapLoaderPlugin **loaderplugin=nullptr, const maxon::Delegate< void(Float progress)> &progressCallback=nullptr)
@ DA_STRING
String.
Definition: c4d_gedata.h:47
Int32 GetId() const
Definition: c4d_basecontainer.h:131
Bool Open(Int32 ident, const Filename &filename, FILEOPEN mode, FILEDIALOG error_dialog)
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
const CustomDataType * GetCustomDataType(Int32 id, Int32 datatype) const
Definition: c4d_string.h:38
static String IntToString(Int32 v)
Definition: c4d_string.h:495
@ OK
Function was successful.
Bool GetParameter(const DescID &id, GeData &t_data) const
Definition: c4d_basecontainer.h:628
Represents a date and time.
Definition: customgui_datetime.h:38
BaseContainer GetContainer(Int32 id) const
Definition: c4d_basecontainer.h:418
#define SIZEOF(x)
Calculates the size of a datatype or element.
Definition: apibasemath.h:205
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:190
@ BFM_INTERACTEND
Sent when user interaction ends.
Definition: gui.h:935
Bool ReadContainer(BaseContainer *v, Bool flush)
#define NOTOK
Definition: ge_sys_math.h:267
BaseContainer * GetClone(COPYFLAGS flags, AliasTrans *trans) const
Definition: c4d_basecontainer.h:101
Definition: c4d_gedata.h:82
maxon::Int32 Int32
Definition: ge_sys_math.h:60
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
Int32 day
Day in month.
Definition: customgui_datetime.h:64
Bool ShowBitmap(const Filename &fn)
void GetDataPointers(const Int32 *ids, Int32 cnt, const GeData **data) const
Definition: c4d_basecontainer.h:217
void * GetVoid(Int32 id, void *preset=nullptr) const
Definition: c4d_basecontainer.h:343
Bool SetParameter(const DescID &id, const GeData &t_data)
Definition: c4d_basecontainer.h:635
void MergeContainer(const BaseContainer &src)
void SetLink(Int32 id, C4DAtomGoal *link)
Definition: c4d_basecontainer.h:604
Base class for custom data types.
Definition: c4d_customdatatype.h:50
const String & GetString(void) const
Definition: c4d_gedata.h:463
Bool WriteContainer(const BaseContainer &v)
DateTime GetDateTime() const
@ READ
Open the file for reading.
RenderData * GetActiveRenderData(void)
Definition: ge_autoptr.h:36
String GetString(Int32 id, const maxon::String &preset=maxon::String()) const
Definition: c4d_basecontainer.h:387
@ RDATA_YRES
Definition: drendersettings.h:154
#define DATETIME_DATA
DateTime custom data ID.
Definition: customgui_datetime.h:23
void SetContainer(Int32 id, const BaseContainer &s)
Definition: c4d_basecontainer.h:597
Int32 year
Year.
Definition: customgui_datetime.h:62
Definition: c4d_basedocument.h:142
BaseObject * GetActiveObject(void)
Definition: c4d_gedata.h:673
@ RDATA_XRES
Definition: drendersettings.h:153
String GetName() const
Definition: c4d_baselist.h:2348
IMAGERESULT
Definition: ge_prepass.h:3730
@ BFM_INTERACTSTART
Definition: gui.h:916
Int32 hour
Hour.
Definition: customgui_datetime.h:66
Int32 month
Month.
Definition: customgui_datetime.h:63
Definition: c4d_basematerial.h:27
Int32 GetIndexId(Int32 index) const
Definition: c4d_basecontainer.h:197
Int32 GetInt32(Int32 id, Int32 preset=0) const
Definition: c4d_basecontainer.h:303
Int32 second
Second.
Definition: customgui_datetime.h:68
UInt32 GetDirty() const
Definition: c4d_basecontainer.h:148
Definition: c4d_basedocument.h:496
Definition: c4d_basecontainer.h:46
Definition: apibase.h:306
@ NODOCUMENTCLONE
Set to avoid an automatic clone of the scene sent to RenderDocument().