TACOS/Tacos/include/sta/tacos/statemachine.hpp

74 lines
1.1 KiB
C++

/*
* statemachine.hpp
*
* Created on: Sep 14, 2023
* Author: Dario
*/
#ifndef INCLUDE_TACOS_STATEMACHINE_HPP_
#define INCLUDE_TACOS_STATEMACHINE_HPP_
#include <sta/config.hpp>
#include <sta/tacos/thread.hpp>
namespace sta
{
namespace tacos
{
class Statemachine : public TacosThread
{
public:
static Statemachine* instance()
{
static CGuard g;
if (!_instance)
{
// Create a the manager singleton instance.
Statemachine::_instance = new Statemachine();
// Start the manager task as a tacos task.
Statemachine::_instance->start();
}
return _instance;
}
void init() override;
void func() override;
uint16_t getCurrentState();
private:
static Statemachine * _instance;
class CGuard
{
public:
~CGuard()
{
if( NULL != Statemachine::_instance )
{
delete Statemachine::_instance;
Statemachine::_instance = NULL;
}
}
};
Statemachine();
Statemachine(const Statemachine&);
~Statemachine() {}
uint16_t currentState_;
};
} // namespace tacos
} // namespace sta
#endif /* INCLUDE_TACOS_STATEMACHINE_HPP_ */