BackendGuard#
Fully qualified name: isaacsim::foundation::utils::BackendGuard
-
class BackendGuard#
RAII guard that sets the active backend for the current thread within a scope.
On construction, saves the current thread-local backend context and activates the requested backend. On destruction, the previous context is automatically restored. Nested guards are supported: each guard restores exactly the state it found on entry.
See also
getCurrentBackend(), isBackendSet()
Note
This class is not copyable or movable. Declare it as a named local variable to ensure the scope matches the intended lifetime.
Warning
Declaring a temporary (unnamed) BackendGuard restores the backend immediately. Always declare a named variable:
BackendGuard guard("tensor");Public Functions
- explicit BackendGuard(
- const std::string &backend,
- bool raiseOnUnsupported = false,
- bool raiseOnFallback = false,
Activates the given backend for the current thread scope.
- Parameters:
backend – [in] The backend name to activate (e.g.
"usd","tensor").raiseOnUnsupported – [in] Whether to raise an exception when the active backend is not in the supported list passed to getCurrentBackend().
raiseOnFallback – [in] Whether to raise an exception when a fallback backend is selected because the active backend is unsupported.
-
~BackendGuard()#
Restores the backend context that was active before this guard was created.
-
BackendGuard(const BackendGuard&) = delete#
-
BackendGuard &operator=(const BackendGuard&) = delete#
-
BackendGuard(BackendGuard&&) = delete#
-
BackendGuard &operator=(BackendGuard&&) = delete#