MPxData Class Reference
[OpenMaya - API module for common classesProxy classes]

#include <MPxData.h>

Inheritance diagram for MPxData:

Inheritance graph
[legend]

List of all members.


Detailed Description

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.

Examples:

apiMeshData.cpp, apiMeshData.h, blindComplexDataCmd.cpp, and blindDoubleDataCmd.cpp.


Public Types

enum  Type { kData, kGeometryData, kLast }

Public Member Functions

 MPxData ()
virtual ~MPxData ()
virtual MStatus readASCII (const MArgList &argList, unsigned int &endOfTheLastParsedElement)
virtual MStatus readBinary (std::istream &in, unsigned int length)
virtual MStatus writeASCII (std::ostream &out)
virtual MStatus writeBinary (std::ostream &out)
virtual void copy (const MPxData &src)=0
virtual MTypeId typeId () const =0
virtual MString name () const =0

Friends

class MDataHandle

Member Enumeration Documentation

Type of the data. Used when registering the custom data type with MFnPlugin::registerData.

Enumerator:
kData   
kGeometryData   
kLast   


Constructor & Destructor Documentation

MPxData::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.

MPxData::~MPxData (  )  [virtual]

Class Destructor

No additional action.


Member Function Documentation

MStatus MPxData::readASCII ( const MArgList argList,
unsigned int &  endOfTheLastParsedElement 
) [virtual]

Creates Data in Data Block as specified by input from ASCII file record.

Parameters:
[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.
Returns:
  • MS::kSuccess Success
  • MS::kFailure Failure - Could not parse arguments, could not create Data or base class method not overridden.
Examples:

MStatus MPxData::readBinary ( std::istream &  in,
unsigned int  length 
) [virtual]

/fn MStatus MPxData::readBinary( std::istream& in, unsigned int length ) Creates Data in Data Block as specified by binary data from the given stream.

Parameters:
[in] in Input stream
[in] length Length in bytes of binary data to be read.
Returns:
  • MS::kSuccess Success
  • MS::kFailure Failure - Could not parse arguments, could not create Data or base class method not overridden.
Examples:

MStatus MPxData::writeASCII ( std::ostream &  out  )  [virtual]

/fn MStatus MPxData::writeASCII( std::ostream& out) Encodes Data in accordance with the ASCII file format and outputs it to the given stream.

Parameters:
[in] out Output stream
Returns:
Examples:

MStatus MPxData::writeBinary ( std::ostream &  out  )  [virtual]

/fn MStatus MPxData::writeBinary( std::ostream& out) Encodes Data in accordance with the binary file format and outputs it to the given stream.

Parameters:
[in] out Output stream
Returns:
Examples:

void MPxData::copy ( const MPxData src  )  [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.

Parameters:
[in] src The object from which to copy the private data

Implemented in MPxGeometryData.

Examples:

MTypeId MPxData::typeId (  )  const [pure virtual]

Determines the type id of the Data object. This is a pure virtual method, and must be overridden in derived classes.

Returns:
Type id of the Data object

Implemented in MPxGeometryData.

Examples:

MString MPxData::name (  )  const [pure virtual]

Determines the type name of the Data object. This is a pure virtual method, and must be overridden in derived classes.

Returns:
Type name of the Data object

Implemented in MPxGeometryData.

Examples:


Autodesk® Maya® 2010 © 1997-2009 Autodesk, Inc. All rights reserved. Generated with doxygen 1.5.6