AtomArray Class Reference

#include <c4d_baselist.h>

Detailed Description

An array of C4DAtom objects.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Private Member Functions

 AtomArray ()
 
 ~AtomArray ()
 

Alloc/Free

static AtomArrayAlloc ()
 
static void Free (AtomArray *&obj)
 

Miscellaneous

Int32 GetCount () const
 
Int32 GetCount (Int32 type, Int32 instance) const
 
C4DAtomGetIndex (Int32 idx) const
 
Bool Append (C4DAtom *obj)
 
void Flush ()
 
Bool Remove (C4DAtom *obj)
 
C4DAtomGetPreferred () const
 
void SetPreferred (C4DAtom *t_preferred)
 
void FilterObject (Int32 type, Int32 instance, Bool generators=false)
 
void FilterObjectChildren ()
 
Bool Append (const AtomArray *src)
 
Int32 Find (C4DAtom *obj)
 
Bool Compare (const AtomArray *cmp) const
 

Copy

Bool CopyTo (AtomArray *dest) const
 
Bool CopyToFilter (AtomArray *dest, Int32 type, Int32 instance, Int32 generators=1) const
 

User ID and Data

Int32 GetUserID () const
 
void SetUserID (Int32 t_userid)
 
void * GetUserData () const
 
void SetUserData (void *t_userdata)
 

Constructor & Destructor Documentation

◆ AtomArray()

AtomArray ( )
private

◆ ~AtomArray()

~AtomArray ( )
private

Member Function Documentation

◆ Alloc()

static AtomArray* Alloc ( )
static

Allocates an atom array. Destroy the allocated atom array with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated atom array, or nullptr if the allocation failed.

◆ Free()

static void Free ( AtomArray *&  obj)
static

Destructs atom arrays allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]objThe atom array to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ GetCount() [1/2]

Int32 GetCount ( ) const

Gets the number of atoms in the array.

Returns
The atom count.

◆ GetCount() [2/2]

Int32 GetCount ( Int32  type,
Int32  instance 
) const

Checks how many elements in the array match type and/or instance.

Parameters
[in]typeChecked against C4DAtom::GetType(). Pass NOTOK to ignore this test.
[in]instanceChecked against C4DAtom::IsInstanceOf(). Pass NOTOK to ignore this test.
Returns
The number of matches.

◆ GetIndex()

C4DAtom* GetIndex ( Int32  idx) const

Gets the atom at the position idx in the array.

Parameters
[in]idxThe index. Must be between 0 and GetCount().
Returns
The idx-th atom in the array. The atom array owns the pointed object.

◆ Append() [1/2]

Bool Append ( C4DAtom obj)

Appends obj to the array.

Parameters
[in]objThe atom to append to the array. Only the pointer is stored; the actual ownership remains with the caller.
Returns
true if the atom was appended, otherwise false.

◆ Flush()

void Flush ( )

Clears the atom array.

◆ Remove()

Bool Remove ( C4DAtom obj)

Removes obj from the array.

Parameters
[in]objThe atom to remove from the array. Only the pointer is removed; the object is not freed.
Returns
true if successful, otherwise false.

◆ CopyTo()

Bool CopyTo ( AtomArray dest) const

Copies all atoms in *this to *dest.

Parameters
[out]destThe destination array. The caller owns the pointed object.
Returns
true if the atom array was copied, otherwise false.

◆ CopyToFilter()

Bool CopyToFilter ( AtomArray dest,
Int32  type,
Int32  instance,
Int32  generators = 1 
) const

Copies all atoms in *this to *dest filtered by type and/or instance.

Parameters
[out]destThe destination array. The caller owns the pointed object.
[in]typeChecked against C4DAtom::GetType(). Pass NOTOK to ignore this test.
[in]instanceChecked against C4DAtom::IsInstanceOf(). Pass NOTOK to ignore this test.
[in]generatorsUsed to filter generators.
Returns
true if the atom array was copied, otherwise false.

◆ GetUserID()

Int32 GetUserID ( ) const

Gets the user ID of the array.

Returns
This array's user ID.

◆ SetUserID()

void SetUserID ( Int32  t_userid)

Sets the user ID of the array to t_userid.

Parameters
[in]t_useridThe new user ID.

◆ GetUserData()

void* GetUserData ( ) const

Gets the user data pointer stored with the array.

Returns
The user data pointer. Not managed by the atom array.

◆ SetUserData()

void SetUserData ( void *  t_userdata)

Store a user data pointer with the array.

Parameters
[in]t_userdataThe new user data pointer. Not manager by the atom array.

◆ GetPreferred()

C4DAtom* GetPreferred ( ) const

The preferred object is the one to use for operations that require a single object.
For example, if the user drags many objects to a link field this is used.

Note
This is not always set. In that case for example use the first object.
Returns
The preferred object to use for single object actions. The array owns the pointed object..

◆ SetPreferred()

void SetPreferred ( C4DAtom t_preferred)

Sets the preferred object.

See also
GetPreferred()
Parameters
[in]t_preferredThe new preferred object. Must already be in the array.

◆ FilterObject()

void FilterObject ( Int32  type,
Int32  instance,
Bool  generators = false 
)

Removes objects that do not match the filter given by type and instance.

Parameters
[in]typeChecked against C4DAtom::GetType(). Pass NOTOK to ignore this test.
[in]instanceChecked against C4DAtom::IsInstanceOf(). Pass NOTOK to ignore this test.
[in]generatorsUsed to filter generators.

◆ FilterObjectChildren()

void FilterObjectChildren ( )

Removes all objects that has a parent (or ancestor) in the array.

◆ Append() [2/2]

Bool Append ( const AtomArray src)

Appends all objects in src to the array.

Parameters
[in]srcThe source array to append. The caller owns the pointed object.
Returns
true if successful, otherwise false.

◆ Find()

Int32 Find ( C4DAtom obj)

Finds the index of obj in the array.

Parameters
[in]objThe atom to search for.
Returns
The index, or NOTOK if not found.

◆ Compare()

Bool Compare ( const AtomArray cmp) const

Compares the array with cmp.

Parameters
[in]cmpThe atom array to compare with. The caller owns the pointed object.
Returns
true if both arrays are identical, otherwise false.