#ifndef _FSM_HPP_ #define _FSM_HPP_ #include "FSM.h" #include /// /// This is a generic update method, unknown classes are not supported. /// /// IBehaviouralState is the only accepted /// class. template void FSM::act() { // No implementation for unknown class. std::cout << "No implementation for unknown class" << std::endl; } // ///// ///// Calls the IBehaviouralState act method. ///// ///// IBehaviouralState is the only accepted /// class. template <> inline void FSM::act() { _currentState->act(); } /// /// This is a generic return of the type. /// /// Any class type works with this return. /// The current IBehaviouralState map. template std::map> FSM::get_states() { return _states; } ///// ///// State transitioning from current state to newState. ///// Calls Exit on the current state and Enter on the new state. ///// ///// IBehaviouralState is the only accepted /// class. ///// New state to transition into. template <> inline void FSM::set_state(std::shared_ptr newState) { // We can guarantee all statemachines are based on IBehaviouralState if (_currentState != nullptr) _currentState->exit(); _currentState = nullptr; _currentState = newState; _currentState->enter(); } /// /// State transitioning from current state to newState. /// Calls Exit on the current state and Enter on the new state. /// /// IBehaviouralState is the only accepted /// class. New state to transition /// into. template void FSM::set_state(std::shared_ptr newState) { // We can guarantee all statemachines are based on IBehaviouralState // No implementation for an unknown state change class. std::cout << "No implementation for unknown state change class" << std::endl; } #endif // _FSM_HPP_