|
A utility class to temporarily modify a stage's current EditTarget during an execution scope. More...
#include <editContext.h>
Public Member Functions | |
USD_API | UsdEditContext (const UsdStagePtr &stage) |
Construct without modifying stage's current EditTarget. | |
USD_API | UsdEditContext (const UsdStagePtr &stage, const UsdEditTarget &editTarget) |
Construct and save stage's current EditTarget to restore on destruction, then invoke stage->SetEditTarget(editTarget). | |
USD_API | 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). | |
USD_API | ~UsdEditContext () |
Restore the stage's original EditTarget if this context's stage is valid. | |
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.
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 50 of file editContext.h.
|
explicit |
Construct without modifying stage's current EditTarget.
Save stage's current EditTarget to restore on destruction.
If stage is invalid, a coding error will be issued by the constructor, and this class takes no action.
USD_API UsdEditContext | ( | const UsdStagePtr & | stage, |
const UsdEditTarget & | editTarget | ||
) |
Construct and save stage's current EditTarget to restore on destruction, then invoke stage->SetEditTarget(editTarget).
If stage is invalid, a coding error will be issued by the constructor, and this class takes no action.
If editTarget is invalid, a coding error will be issued by the stage, and its EditTarget will not be modified.
USD_API 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 stage is invalid, a coding error will be issued by the constructor, and this class takes no action.
If editTarget is invalid, a coding error will be issued by the stage, and its EditTarget will not be modified.
USD_API ~UsdEditContext | ( | ) |
Restore the stage's original EditTarget if this context's stage is valid.
Otherwise do nothing.