Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
StateTransition.h
00001 /* 00002 * FiniteStateMachine. Table driven Finite State Machine library 00003 * based on theHarel state machine, supporting actions on transitions, state 00004 * entry and state exit. 00005 * 00006 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk> 00007 * 00008 * This file is part of FiniteStateMachine. 00009 * 00010 * FiniteStateMachine is free software: you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation, either version 3 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * FiniteStateMachine is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with DebugTrace. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 #ifndef SNATCH59_STATETRANSITION_H 00025 #define SNATCH59_STATETRANSITION_H 00026 00027 #include <mbed.h> 00028 #include "FSMDefs.h" 00029 00030 STATE_TEMPLATE_ class State; 00031 00032 #include "State.h" 00033 00034 STATE_TEMPLATE_ 00035 class StateTransition 00036 { 00037 00038 public: 00039 StateTransition(int event_id, ActionPtrType action, STATE_* state_ptr, StateBehaviour behaviour); 00040 00041 STATE_* match(const int event_id) const; 00042 void doAction(StateObjectType* &its_state_object) const; 00043 StateBehaviour getStateBehaviour() const; 00044 00045 private: 00046 int eventId; 00047 ActionPtrType action; 00048 STATE_* newState; 00049 StateBehaviour mode; 00050 }; 00051 00052 STATE_TEMPLATE_ 00053 inline STATE_* STATE_TRANSITION_::match(const int event_id) const 00054 { 00055 if (eventId == event_id) return newState; 00056 00057 return NULL; 00058 } 00059 00060 STATE_TEMPLATE_ 00061 inline StateBehaviour STATE_TRANSITION_::getStateBehaviour() const 00062 { 00063 return mode; 00064 } 00065 00066 STATE_TEMPLATE_ 00067 STATE_TRANSITION_::StateTransition(int event_id, ActionPtrType action_ptr, STATE_* state_ptr, StateBehaviour behaviour) : 00068 eventId(event_id), action(action_ptr), newState(state_ptr), mode(behaviour) 00069 { 00070 } 00071 00072 STATE_TEMPLATE_ 00073 void STATE_TRANSITION_::doAction(StateObjectType* &its_state_object) const 00074 { 00075 if (action != NULL) 00076 { 00077 (its_state_object->*action)( ); 00078 } 00079 } 00080 00081 #endif
Generated on Wed Jul 13 2022 21:34:29 by
1.7.2