|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
RAII helper that fixes DateTime::now() to a constant instant (or a custom callable) for its lifetime and restores the previous override on destruction. More...
#include <datetime.hpp>
Public Member Functions | |
| ScopedNowOverride (DateTime fixedInstant) | |
Installs a clock that always returns fixedInstant. | |
| ScopedNowOverride (std::function< DateTime()> clock) | |
| Installs an arbitrary clock callable, saving whatever override was there before. | |
| ~ScopedNowOverride () | |
| Restores the saved override (or "no override", if none was installed before). | |
| ScopedNowOverride (const ScopedNowOverride &)=delete | |
| ScopedNowOverride & | operator= (const ScopedNowOverride &)=delete |
| ScopedNowOverride (ScopedNowOverride &&)=delete | |
| ScopedNowOverride & | operator= (ScopedNowOverride &&)=delete |
RAII helper that fixes DateTime::now() to a constant instant (or a custom callable) for its lifetime and restores the previous override on destruction.
Mirrors morph::journal::ScopedActionLog and morph::log::ScopedLoggerOverride — the same scoped-install-then-restore pattern used for the codebase's other process-wide override seams, so one test's fixed "now" never leaks into the next.
Definition at line 340 of file datetime.hpp.
|
inlineexplicit |
Installs a clock that always returns fixedInstant.
| fixedInstant | The constant instant DateTime::now() should report for this scope. |
Definition at line 344 of file datetime.hpp.
|
inlineexplicit |
Installs an arbitrary clock callable, saving whatever override was there before.
clock must not throw and must not call DateTime::now()/Timestamp::now() or install another override. | clock | Callable returning the instant DateTime::now() should report for this scope. |
Definition at line 351 of file datetime.hpp.
|
inline |
Restores the saved override (or "no override", if none was installed before).
Definition at line 359 of file datetime.hpp.