C++ API Reference
|
Base Class for User-defined Dependency Graph Data Types. More...
#include <MPxData.h>
Public Types | |
enum | Type { kData, kGeometryData, kLast } |
Type of the data. More... | |
Public Member Functions | |
MPxData () | |
Class Constructor. More... | |
virtual | ~MPxData () |
Class Destructor. More... | |
virtual MStatus | readASCII (const MArgList &argList, unsigned int &endOfTheLastParsedElement) |
Creates Data in Data Block as specified by input from ASCII file record. More... | |
virtual MStatus | readBinary (std::istream &in, unsigned int length) |
Creates Data in Data Block as specified by binary data from the given stream. More... | |
virtual MStatus | writeASCII (std::ostream &out) |
Encodes Data in accordance with the ASCII file format and outputs it to the given stream. More... | |
virtual MStatus | writeBinary (std::ostream &out) |
Encodes Data in accordance with the binary file format and outputs it to the given stream. More... | |
virtual void | copy (const MPxData &src)=0 |
This method initializes an instance of an MPxData derived class from another existing instance. More... | |
virtual MTypeId | typeId () const =0 |
Determines the type id of the Data object. More... | |
virtual MString | name () const =0 |
Determines the type name of the Data object. More... | |
Base Class for User-defined Dependency Graph Data Types.
In Maya, both intrinsic and user-defined Maya Objects are registered and recognized by their type identifier (MTypeId). Data which flows in the Dependency Graph (DG) is implemented as Maya objects, therefore, the type characteristics of DG Data are specified by the type id (MTypeId). The type id is used to at run-time to determine how to create and destroy Maya Objects, and how they are to be input/output from/to files.
User-defined Data has two parts. One part is an internal Maya Data object of neutral type which is common to all user-defined types. This common Data object implements the interface and behaviour characteristics required for user-defined Data to act as Data within Maya. The second part is unique to each user-defined type and implements the type-specific behaviour.
The Proxy Data (MPxData) class is the base class for user-defined Data types. All user-defined Data that is to be passed between Nodes in the DG must be derived from MPxData. MPxData transparently incorporates the common behaviour and defines the common interface required for DG Data. When initialized with a unique type id, Data objects of classes derived from MPxData are recognized by Maya the same as built-in DG Data types, but are be able to implement user-specified behaviour.
The MPxData class defines the interface for methods to read, write and assign Data objects of the the user-defined type. User-defined types must override these methods to provide type-specific behaviour.
MPxData also provides common methods for querying the type id and type name of the Data object.
All user-defined DG Data types require an associated static creator function that returns a void pointer to a new instance of the data class. This function is usually a static function within the user defined data type class.
The registration of the new data type is performed by the MFnPlugin::registerData() which is invoked in the initializePlugin() function during Plug-in loading. One of the most important thing that the registration does is it associates the type id with the data.
Once a user-defined Data type based on MPxData has been defined and registered, use the Typed Attribute Function Set (MFnTypedAttribute) to create an Attribute of the user-defined type. The Attribute may also be an multi-Attribute (array). Use the DG Node Function Set (MFnDependencyNode) to add the Attribute to a user- defined Node. This is usually done in the initialize() method of the Node creator.
Data of a user-defined type on a Node is accessed in the same way as intrinsic Data types. The Data is actually held in an Data Block (MDataBlock). Use a Data Handle (MDataHandle) or Array Data Handle (MArrayDataHandle) to access the Data within a Data Block. Use a Data Block to obtain a Data Handle or Array Data Handle for either an Attribute or the associated Plug on the Attribute. The Data Handle or Array data handle can then be queried for the underlying Data object. The underlying Data object is a generic Maya Object (MObject) with a type id of the user-defined type.
Use the Plug-in Data Function Set (MFnPluginData) to obtain an MPxData pointer which can be safely cast to a pointer of the user-defined type.
enum Type |
Type of the data.
Used when registering the custom data type with MFnPlugin::registerData.
Enumerator | |
---|---|
kData |
|
kGeometryData |
|
kLast |
|
OPENMAYA_MAJOR_NAMESPACE_OPEN MPxData | ( | ) |
Class Constructor.
Invoked by the constructor of the user-defined type to initialize the common Data object component of the instance of the user-defined type.
|
virtual |
Class Destructor.
No additional action.
Creates Data in Data Block as specified by input from ASCII file record.
[in] | argList | List of arguments read from ASCII record |
[in,out] | endOfTheLastParsedElement | On invocation points to last argument already parsed. On return points to last argument parsed by this method. |
|
virtual |
Creates Data in Data Block as specified by binary data from the given stream.
[in] | in | Input stream |
[in] | length | Length in bytes of binary data to be read. |
|
virtual |
Encodes Data in accordance with the ASCII file format and outputs it to the given stream.
[in] | out | Output stream |
|
virtual |
Encodes Data in accordance with the binary file format and outputs it to the given stream.
[in] | out | Output stream |
|
pure virtual |
This method initializes an instance of an MPxData derived class from another existing instance.
This method can be thought of as the second half of a copy constructor for the class. The default constructor has already been called for the instance, and this method is used to set the private data by copying the values from an existing instance. This is a pure virtual method, and must be overridden in derived classes.
[in] | src | The object from which to copy the private data |
Implemented in MPxGeometryData.
|
pure virtual |
Determines the type id of the Data object.
This is a pure virtual method, and must be overridden in derived classes.
Implemented in MPxGeometryData.
|
pure virtual |
Determines the type name of the Data object.
This is a pure virtual method, and must be overridden in derived classes.
Implemented in MPxGeometryData.