| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <string> | ||
| 4 | |||
| 5 | namespace na64dp { | ||
| 6 | namespace aux { | ||
| 7 | |||
| 8 | ///\brief Mixing maintaining "fail flag" -- a mechanism to report | ||
| 9 | /// foreseen issues to the caller context | ||
| 10 | /// | ||
| 11 | /// Upon error, classes (handlers) inheriting this mixin can check whether | ||
| 12 | /// the instance is backed up and set failflag instead of raising exceptions. | ||
| 13 | class FallbackableMixin { | ||
| 14 | private: | ||
| 15 | bool * _failFlag; | ||
| 16 | public: | ||
| 17 | 2 | FallbackableMixin() : _failFlag(nullptr) {} | |
| 18 | |||
| 19 | FallbackableMixin(const FallbackableMixin &) = delete; | ||
| 20 | FallbackableMixin & operator=(const FallbackableMixin &) = delete; | ||
| 21 | |||
| 22 | ✗ | virtual bool is_backed() const { return _failFlag; } | |
| 23 | virtual void set_failflag_ptr(bool &); | ||
| 24 | virtual bool failflag() const; | ||
| 25 | virtual void failflag(bool); | ||
| 26 | |||
| 27 | ///\brief Sets failflag if fail flag is assigned, otherwise throws a | ||
| 28 | /// runtime exception (`na64dp::errors::GenericRuntimeError`) | ||
| 29 | /// | ||
| 30 | /// Use this method to provide verbose error message and raise an exception | ||
| 31 | /// if external context does not provie fail flag. | ||
| 32 | virtual std::string set_failflag(const char *fmt, ...); | ||
| 33 | }; // class FallbackableMixin | ||
| 34 | |||
| 35 | } // namespace ::na64dp::aux | ||
| 36 | } // namespace na64dp | ||
| 37 | |||
| 38 |