Public Types | Static Public Member Functions

MCommandMessage Class Reference

Search for all occurrences

Detailed Description

Helper class to handle MEL output.

This class is used to register for a callback for when certain MEL command related messages are generated.

The add callback method returns an id which is used to remove the callback.

To remove a callback use MMessage::removeCallback.

All callbacks that are registered by a plug-in must be removed by that plug-in when it is unloaded. Failure to do so will result in a fatal error.

Note:
Setting up a callback using the addCommandCallback() method may degrade the performance of Maya since the installed callback will be invoked repeatedly as MEL operations are processed.

#include <MCommandMessage.h>

Inheritance diagram for MCommandMessage:
Inheritance graph
[legend]

List of all members.

Public Types

enum  MessageType {
  kHistory, kDisplay, kInfo, kWarning,
  kError, kResult, kStackTrace
}
 

Types of output messages.

More...
typedef void(* MMessageFunction )(const MString &message, MCommandMessage::MessageType messageType, void *clientData)
 Pointer to a message function.
typedef void(* MMessageFilterFunction )(const MString &message, MCommandMessage::MessageType messageType, bool &filterOutput, void *clientData)
 Pointer to a message filter function.

Static Public Member Functions

static MCallbackId addCommandCallback (MMessage::MStringFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL)
 This method registers a callback for command messages that are issued every time a MEL command is executed.
static MCallbackId addCommandOutputCallback (MCommandMessage::MMessageFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL)
 This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.
static MCallbackId addCommandOutputFilterCallback (MCommandMessage::MMessageFilterFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL)
 This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.
static const char * className ()
 Returns the name of this class.
static MCallbackId addProcCallback (MMessage::MStringIntBoolIntFunction func, void *clientData, MStatus *ReturnStatus)
 This method registers a callback that is executed every time a MEL procedure is run.

Member Typedef Documentation

typedef void(* MMessageFunction)(const MString &message, MCommandMessage::MessageType messageType, void *clientData)

Pointer to a message function.

Parameters:
[in]messageThe command that was executed.
[in]messageTypeThe type of message.
[in,out]clientDataUser defined data passed to the callback function.
typedef void(* MMessageFilterFunction)(const MString &message, MCommandMessage::MessageType messageType, bool &filterOutput, void *clientData)

Pointer to a message filter function.

Parameters:
[in]messageThe command that was executed.
[in]messageTypeThe type of message.
[out]filterBool that causes Maya to filter this message if set to true.
[in,out]clientDataUser defined data passed to the callback function.

Member Enumeration Documentation

Types of output messages.

Enumerator:
kHistory 

Command history.

kDisplay 

String to display unmodified.

kInfo 

General information.

kWarning 

Warning message.

kError 

Error message.

kResult 

Result from a command execution in the command window.

kStackTrace 

Stack trace.


Member Function Documentation

MCallbackId addCommandCallback ( MMessage::MStringFunction  func,
void *  clientData = NULL,
MStatus ReturnStatus = NULL 
) [static]

This method registers a callback for command messages that are issued every time a MEL command is executed.

It is only called when actual commands are executed and not when scripts are executed.

The callback function will be passed the any client data that was provided when the callback was registered.

NOTE: Setting up a callback using this method will degrade the performance of Maya since the installed callback will be invoked repeatedly as MEL operations are processed.

Parameters:
[in]funcThe callback function.
[in]clientDataUser defined data that will be passed to the callback function.
[out]ReturnStatusStatus code.
Returns:
Identifier used for removing the callback.
Status Codes:
MCallbackId addCommandOutputCallback ( MCommandMessage::MMessageFunction  func,
void *  clientData = NULL,
MStatus ReturnStatus = NULL 
) [static]

This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.

The callback function will be passed the any client data that was provided when the callback was registered.

Parameters:
[in]funcThe callback function.
[in]clientDataUser defined data that will be passed to the callback function.
[out]ReturnStatusStatus code.
Returns:
Identifier used for removing the callback.
Status Codes:
MCallbackId addCommandOutputFilterCallback ( MCommandMessage::MMessageFilterFunction  func,
void *  clientData = NULL,
MStatus ReturnStatus = NULL 
) [static]

This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.

This callback includes a boolean filter option which allows the callback to prevent the output of the message to the script editor and command line output. Setting the 'filterOutput' parameter to true, inside your callback will filter the output from the script editor and command line output.

The callback function will be passed the any client data that was provided when the callback was registered.

Parameters:
[in]funcThe callback function.
[in]clientDataUser defined data that will be passed to the callback function.
[out]ReturnStatusStatus code.
Returns:
Identifier used for removing the callback.
Status Codes:
const char * className ( ) [static]

Returns the name of this class.

Returns:
The name of this class.

Reimplemented from MMessage.

MCallbackId addProcCallback ( MMessage::MStringIntBoolIntFunction  func,
void *  clientData,
MStatus ReturnStatus 
) [static]

This method registers a callback that is executed every time a MEL procedure is run.

The callback will be executed once when the procedure is about to be executed, and again when it has exited. If a non-existent procedure is called the callback will be called once for entry but there will be no call on exit.

The callback function should have the following parameters:

func(const MString& procName, unsigned int procID, bool isProcEntry, unsigned int type, void* clientData)

Where: procName will be the name of the procedure being invoked procID is the ID for the procedure's invocation isProcEntry is true if the procedure is being entered, false otherwise type is an MCommandMessage::ProcType value, and denotes the type of call this is, a MEL Proc, or MEL Command clientData is a pointer to an unsigned integer which is the invocation ID of the procedure

The callback cannot be registered multiple times. To register a new callback function for this, please de-register the original callback first.

NOTE: Setting up a callback using this method can potentially degrade the performance of Maya since the installed callback will be invoked repeatedly as MEL procedures are executed.

Parameters:
[in]funcThe callback function.
[in]clientDataUser defined data that will be passed to the callback function.
[out]ReturnStatusStatus code.
Returns:
Identifier used for removing the callback.
Status Codes:

MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage
MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage