C++ API Reference
MArrayDataBuilder Class Reference

Array builder for arrays in data blocks. More...

#include <MArrayDataBuilder.h>

Public Member Functions

 MArrayDataBuilder (MDataBlock *, const MObject &attribute, unsigned int numElements, MStatus *ReturnStatus=NULL)
 The class constructor receives an attribute object and the number of elements to allocate space for. More...
 
MDataHandle addLast (MStatus *ReturnStatus=NULL)
 Adds a new element to the end of the array. More...
 
MDataHandle addElement (unsigned int index, MStatus *ReturnStatus=NULL)
 Adds a new element to the array at the given index. More...
 
MArrayDataHandle addLastArray (MStatus *ReturnStatus=NULL)
 Adds a new element to the end of the array. More...
 
MArrayDataHandle addElementArray (unsigned int index, MStatus *ReturnStatus=NULL)
 Adds a new element to the array at the given index. More...
 
MStatus removeElement (unsigned int index)
 Removes the specified element from the array. More...
 
unsigned int elementCount (MStatus *ReturnStatus=NULL) const
 Returns the number of elements in the array. More...
 
MStatus growArray (unsigned int amount)
 Grows the array storage by the given amount. More...
 
MStatus setGrowSize (unsigned int size)
 Sets the grow size of the array. More...
 
 MArrayDataBuilder (const MArrayDataBuilder &other)
 Copy constructor. More...
 
MArrayDataBuilderoperator= (const MArrayDataBuilder &other)
 Assignment operator. More...
 
 ~MArrayDataBuilder ()
 Class destructor.
 
 MArrayDataBuilder (const MObject &attribute, unsigned int numElements, MStatus *ReturnStatus=NULL)
 Deprecated in 2019.0 More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Friends

class MArrayDataHandle
 

Detailed Description

Array builder for arrays in data blocks.

An MArrayDataBuilder is used to construct data for attributes/plugs that have an array of data. An array builder is used with an MArrayDataHandle for managing data.

Examples:
apiMeshShape/apiMeshShape.cpp, dynExprField/dynExprField.cpp, multiCurveNode/multiCurveNode.cpp, ownerEmitter/ownerEmitter.cpp, simpleEmitter/simpleEmitter.cpp, sweptEmitter/sweptEmitter.cpp, torusField/torusField.cpp, and weightListNode/weightListNode.cpp.

Constructor & Destructor Documentation

MArrayDataBuilder ( MDataBlock block,
const MObject attribute,
unsigned int  numElements,
MStatus ReturnStatus = NULL 
)

The class constructor receives an attribute object and the number of elements to allocate space for.

The MObject must be a multi attribute (i.e. a plug that is a composite of multiple element plugs). This is different, for example, from a single attribute of type kVectorArrayData, which would be passed through a single plug as a single lump of data. Common examples of a multi-plug are the worldMatrix attribute that is on all DAG nodes, or the position attribute on the particleShape node.

This class will also take as input the datablock that the builder belongs to. You must specify this datablock if you want your builder to support per-plug caching.

Parameters
[in]blockthe data block that the builder belongs to.
[in]attributeattribute for which we wish to build data
[in]numElementsnumber of elements to allocate space for
[out]ReturnStatusresult status code
Status Codes:
  • MS::kSuccess operation successful
  • MS::kInvalidParameter object argument is invalid
  • MS::kFailure attribute pointer is NULL

Copy constructor.

Parameters
[in]otherThe source object to copy from.
OPENMAYA_MAJOR_NAMESPACE_OPEN MArrayDataBuilder ( const MObject attribute,
unsigned int  numElements,
MStatus ReturnStatus = NULL 
)

Deprecated in 2019.0

Deprecated:
Use the other constructor instead.
2019.0:
Deprecated in this version.
Parameters
[in]attributeattribute for which we wish to build data
[in]numElementsnumber of elements to allocate space for
[out]ReturnStatusresult status code

Member Function Documentation

MDataHandle addLast ( MStatus ReturnStatus = NULL)

Adds a new element to the end of the array.

The index of the element will be the current highest index + 1.

Parameters
[out]ReturnStatusresult status code
Returns
The handle for the new element
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid
MDataHandle addElement ( unsigned int  index,
MStatus ReturnStatus = NULL 
)

Adds a new element to the array at the given index.

Parameters
[in]indexthe index at which we wish to add the new element
[out]ReturnStatusresult status code
Returns
The handle for the new element
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid
Examples:
apiMeshShape/apiMeshShape.cpp, dynExprField/dynExprField.cpp, ownerEmitter/ownerEmitter.cpp, simpleEmitter/simpleEmitter.cpp, sweptEmitter/sweptEmitter.cpp, torusField/torusField.cpp, and weightListNode/weightListNode.cpp.
MArrayDataHandle addLastArray ( MStatus ReturnStatus = NULL)

Adds a new element to the end of the array.

The added element is also an array. The index of the element will the current highest index + 1.

Parameters
[out]ReturnStatusresult status code
Returns
The handle for the new array element
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid
MArrayDataHandle addElementArray ( unsigned int  index,
MStatus ReturnStatus = NULL 
)

Adds a new element to the array at the given index.

The added element is also an array.

Parameters
[in]indexthe index at which we wish to add the new element
[out]ReturnStatusresult status code
Returns
The handle for the new array element
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid
MStatus removeElement ( unsigned int  index)

Removes the specified element from the array.

Parameters
[in]indexthe element of the array to remove
Returns
Result status code
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid or remove the remove failed.
unsigned int elementCount ( MStatus ReturnStatus = NULL) const

Returns the number of elements in the array.

Parameters
[out]ReturnStatusresult status code
Returns
The number of elements
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid
MStatus growArray ( unsigned int  amount)

Grows the array storage by the given amount.

Parameters
[in]amountthe amount to grow the array by
Returns
Result status code
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid
MStatus setGrowSize ( unsigned int  size)

Sets the grow size of the array.

As elements are added to the array, the builder will allocate memory in chunks. This method tells the builder how many elements to allocate each time it grows the array.

Parameters
[in]sizethe number of elements to allocate when growing the array
Returns
Result status code
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure the object is invalid
MArrayDataBuilder & operator= ( const MArrayDataBuilder other)

Assignment operator.

Parameters
[in]otherThe source object to copy from.
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.

The documentation for this class was generated from the following files: