C++ API Reference
MDGContextGuard Class Reference

Scope object used to modify current evaluation context in a code block. More...

#include <MDGContextGuard.h>

Public Member Functions

 ~MDGContextGuard ()
 Destructor, restore the previous evaluation context on this thread.
 
 MDGContextGuard (const MDGContext &tempContext)
 Initialize this guard with the given evaluation context. More...
 

Detailed Description

Scope object used to modify current evaluation context in a code block.

Some API methods can have a context passed in to them. In those cases the current context will be temporarily changed to the passed context for evaluation purposes.

A better method for longer sequences of evaluation in an alterative context is to create a guard in a block of code that makes a bunch of calls, and then use the context-free methods.

// Example with a temporary context
some_code_using_current_context();
{
MDGContextGuard contextGuard( MDGContext( 3.0 ) );
myPlug.getValue( myBool );
myPlug.getValue( myInt );
}

This is equivalent to:

some_code_using_current_context();
myPlug.getValue( MDGContext( 3.0 ), myBool );
myPlug.getValue( MDGContext( 3.0 ), myInt );
Note
Guard objects can be nested
Examples:
atomImportExport/atomCachedPlugs.cpp, and atomImportExport/atomImportExport.cpp.

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MDGContextGuard ( const MDGContext newContext)

Initialize this guard with the given evaluation context.

Store the currently assigned context for this thread for restoring on destruction.


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