HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdEditContext Class Reference

#include <editContext.h>

Public Member Functions

USD_API UsdEditContext (const UsdStagePtr &stage)
 
USD_API UsdEditContext (const UsdStagePtr &stage, const UsdEditTarget &editTarget)
 
USD_API UsdEditContext (const std::pair< UsdStagePtr, UsdEditTarget > &stageTarget)
 
USD_API ~UsdEditContext ()
 

Detailed Description

A utility class to temporarily modify a stage's current EditTarget during an execution scope.

This is an "RAII"-like object meant to be used as an automatic local variable. Upon construction, it sets a given stage's EditTarget, and upon destruction it restores the stage's EditTarget to what it was previously.

Example usage, temporarily overriding a stage's EditTarget to direct an edit to the stage's session layer. When the ctx object expires, it restores the stage's EditTarget to whatever it was previously.

void SetVisState(const UsdPrim &prim, bool vis) {
prim.GetStage()->GetSessionLayer());
prim.GetAttribute("visible").Set(vis);
}

Threading Note

When one thread is mutating a UsdStage, it is unsafe for any other thread to either query or mutate it. Using this class with a stage in such a way that it modifies the stage's EditTarget constitutes a mutation.

Definition at line 67 of file editContext.h.

Constructor & Destructor Documentation

USD_API UsdEditContext::UsdEditContext ( const UsdStagePtr &  stage)
explicit

Construct without modifying stage's current EditTarget. Save stage's current EditTarget to restore on destruction.

USD_API UsdEditContext::UsdEditContext ( const UsdStagePtr &  stage,
const UsdEditTarget editTarget 
)

Construct and save stage's current EditTarget to restore on destruction, then invoke stage->SetEditTarget(editTarget).

If editTarget is invalid, a coding error will be issued by the stage, and its EditTarget will not be modified.

USD_API UsdEditContext::UsdEditContext ( const std::pair< UsdStagePtr, UsdEditTarget > &  stageTarget)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This ctor is handy to construct an edit context from the return value of another function (Cannot return a UsdEditContext since it needs to be noncopyable).

If editTarget is invalid, a coding error will be issued by the stage, and its EditTarget will not be modified.

USD_API UsdEditContext::~UsdEditContext ( )

Restore the stage's original EditTarget if this context's stage is valid. Otherwise do nothing.


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