#ifndef STA_TACOS_WATCHDOG_HPP #define STA_TACOS_WATCHDOG_HPP #include #ifdef STA_TACOS_WATCHDOG_ENABLED #ifndef STA_TACOS_WATCHDOG_PRIORITY # error "TACOS watchdog priority was not specified!" #endif // STA_TACOS_WATCHDOG_PRIORITY #ifndef STA_TACOS_WATCHDOG_FREQUENCY # error "TACOS watchdog frequency was not specified!" #endif // STA_TACOS_WATCHDOG_FREQUENCY #include /** * @defgroup tacos_watchdog Watchdog Task * @ingroup tacos * @brief Watchdog class for TACOS. */ namespace sta { namespace tacos { /** * @brief Watchdog class for TACOS using singleton pattern. * * @ingroup tacos_watchdog */ class Watchdog: public TacosThread { public: /** * @brief Getter for the singleton instance. Constructs the instance if no exists. * * @ingroup tacos_watchdog */ static Watchdog* instance() { static CGuard g; if (!_instance) { // Create the watchdog singleton instance. Watchdog::_instance = new Watchdog(); } return _instance; } void func() override; /** * @brief Get the number of thread restarts during the program's runtime. * * @return uint16_t The number of thread restarts. */ uint16_t getNumRestarts(); private: static Watchdog* _instance; class CGuard { public: ~CGuard() { if( NULL != Watchdog::_instance ) { delete Watchdog::_instance; Watchdog::_instance = NULL; } } }; Watchdog(); Watchdog(const Watchdog&); ~Watchdog() {} private: uint16_t restarts_; }; } // namespace tacos } // namespace sta #endif // STA_TACOS_WATCHDOG_ENABLED #endif // STA_TACOS_WATCHDOG_HPP