- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Static Public Member Functions

# MConditionMessage Class Reference

# OpenMaya - API module for common classes

Search for all occurrences

## Detailed Description

Condition change messages.

This class is used to register callbacks for changes to specific conditions.

The addConditionCallback method will add callback a callback for condition changed messages.

The first parameter passed to the addConditionCallback method is the name of the condition that will trigger the callback. The list of available condition names can be retrieved by calling the getConditionNames method or by using the -listConditions flag on the scriptJob command.

Callbacks that are registered for conditions will be passed a bool value as a parameter. This value indicates the new state of the condition.

The addConditionCallback 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.

The getConditionState method is used to return the current state of the specified condition.

`#include <MConditionMessage.h>`

Inheritance diagram for MConditionMessage:
[legend]

List of all members.

## Static Public Member Functions
static MCallbackId | addConditionCallback (const MString &conditionName, MMessage::MStateFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL)
| This method registers a callback for condition changed messages.
static MStatus | getConditionNames (MStringArray &names)
| This method returns the list of available condition names.
static bool | getConditionState (const MString &name, MStatus *ReturnStatus=NULL)
| This method returns the current state of a condition.
static const char * | className ()
| Returns the name of this class.

## Member Function Documentation

MCallbackId addConditionCallback | ( | const MString & | conditionName,
|  | MMessage::MStateFunction | func,
|  | void * | clientData = `NULL`,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | `[static]`

Search for all occurrences

This method registers a callback for condition changed messages.

The callback function will be passed the new state of the condition and any client data that the user wishes to pass in.

Example callback ( prints out a message when a condition changes ) :

        void userCB( bool state, void* )
        {
            if (state) {
                cout << "Condition: true" << endl;
            } else {
                cout << "Condition: false" << endl;
            }
        }

Parameters:

  [in] | conditionName | the condition to register the callback for
  [in] | func | the callback function

- state the new state of the condition triggering the callback
- clientData User defined data passed to the callback function

Parameters:

  [in] | clientData | User defined data that will be passed to the callback function
  [out] | ReturnStatus | status code

Returns:
  Identifier used for removing the callback.

Status Codes:
  - MS::kSuccess Operation succeeded
  - MS::kUnknownParameter The named condition could not be found
  - MS::kInsufficientMemory No memory available
  - MS::kFailure Error adding callback

Examples:
  conditionTest.cpp.

MStatus getConditionNames | ( | MStringArray & | names | ) | `[static]`

Search for all occurrences

This method returns the list of available condition names.

Parameters:

  [out] | names | set to the array of available condition names.

Returns:
  - MS::kSuccess Operation succeeded
  - MS::kInsufficientMemory No memory available
  - MS::kFailure Error retrieving condition names

Examples:
  conditionTest.cpp.

bool getConditionState | ( | const MString & | name,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | `[static]`

Search for all occurrences

This method returns the current state of a condition.

Parameters:

  [in] | name | the name of the condition.
  [out] | ReturnStatus | status code

Returns:
  The current state of the condition.

Status Codes:
  - MS::kSuccess Operation succeeded
  - MS::kUnknownParameter The named condition could not be found
  - MS::kInsufficientMemory No memory available
  - MS::kFailure Error retrieving condition state

Examples:
  conditionTest.cpp.

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

Reimplemented from MMessage.

MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage
MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage MConditionMessage