...
This commit is contained in:
@@ -317,6 +317,7 @@ protected:
|
||||
std::vector<std::function<void(const MccFiniteStateMachine*)>> _destroyFunc{};
|
||||
|
||||
std::string_view _currentStateID;
|
||||
std::string_view _previousStateID;
|
||||
std::vector<std::string_view> _stateID{};
|
||||
std::vector<std::string_view> _eventID{};
|
||||
|
||||
@@ -367,7 +368,7 @@ protected:
|
||||
|
||||
public:
|
||||
template <traits::fsm_state_c InitStateT>
|
||||
constexpr MccFiniteStateMachine(InitStateT) : _currentStateID(InitStateT::ID)
|
||||
constexpr MccFiniteStateMachine(InitStateT) : _currentStateID(InitStateT::ID), _previousStateID(InitStateT::ID)
|
||||
{
|
||||
using states_t = deduce_states_t<InitStateT>;
|
||||
auto states = std::make_shared<states_t>();
|
||||
@@ -417,6 +418,7 @@ public:
|
||||
p_event->onTransit();
|
||||
}
|
||||
|
||||
_previousStateID = curr_state_t::ID;
|
||||
*currentState = &std::get<to_state_t>(*states);
|
||||
_currentStateID = to_state_t::ID;
|
||||
|
||||
@@ -525,6 +527,11 @@ public:
|
||||
return _currentStateID;
|
||||
}
|
||||
|
||||
std::string_view previousStateID() const
|
||||
{
|
||||
return _previousStateID;
|
||||
}
|
||||
|
||||
|
||||
// returns IDs of all deduced unique states
|
||||
|
||||
|
||||
Reference in New Issue
Block a user