Class ScopedRestore

Class Documentation

class ScopedRestore

Runs a restore function once: on Restore(), or else when destroyed.

Returned by the operations that change problem-owned solver settings temporarily, e.g. WGSContext::OverrideSourceScopes() and DiscreteOrdinatesProblem::PreserveWGSSolveSettings().

The destructor must not throw, since it also runs during stack unwinding, so it logs a failed restore instead. Call Restore() on the normal path when a failure must propagate.

Public Functions

inline explicit ScopedRestore(std::function<void()> restore)
inline ScopedRestore(ScopedRestore &&other) noexcept
ScopedRestore &operator=(ScopedRestore&&) = delete
ScopedRestore(const ScopedRestore&) = delete
ScopedRestore &operator=(const ScopedRestore&) = delete
~ScopedRestore()
inline void Restore()

Runs the restore function now, if it has not run; errors propagate.