2 * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
6 * Licensed under the Apache License, Version 2.0 (the License){}
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 #ifndef CICOSTATEMACHINE_H
19 #define CICOSTATEMACHINE_H
25 #include "CicoStateCore.h"
31 #ifndef CICOFINALSTATE_H
35 #ifndef CICOHISTORYSTATE_H
36 class CicoHistoryState;
41 * state-machine object class definition
47 * @brief The CicoStateMachine class
48 * state-machine object class definition
50 class CicoStateMachine : public CicoStateCore
54 CicoStateMachine(int value = 0);
55 CicoStateMachine(const std::string& name, int value = 0);
57 // registration state/historyState/fainalState objects
58 void addState(CicoState* state);
59 void addState(CicoFinalState* state);
60 void addState(CicoHistoryState* state);
62 // registration start position
63 void addInitState(CicoState* state);
64 void addInitState(CicoHistoryState* state);
66 // start state-machine
69 // Delivery of the event
70 bool eventEntry(const CicoEvent& ev);
71 // Test event delivery
72 bool eventTest(const CicoEvent& ev);
77 // Acquisition of state-objects is registered
78 const CicoStateCore* getState(const int value) const;
79 const CicoStateCore* getState(const std::string& name) const;
81 // get current active state-objects
82 bool getCurrentState(std::vector<const CicoState*>& states,
83 CicoStateCore::E_GetPolicy policy=CicoStateCore::ELvlBttm);
84 const CicoState* getCurrentState();
88 bool m_eventExec; // During event processing flag
92 * @brief CicoStateMachine::addState
93 * @param state register child state-object pointer
95 inline void CicoStateMachine::addState(CicoState* state)
97 CicoStateCore::addState((CicoStateCore*)state);
101 * @brief CicoStateMachine::addState
102 * @param state register child state-object pointer
104 inline void CicoStateMachine::addState(CicoFinalState* state)
106 CicoStateCore::addState((CicoStateCore*)state);
110 * @brief CicoStateMachine::addState
111 * @param state register child state-object pointer
113 inline void CicoStateMachine::addState(CicoHistoryState* state)
115 CicoStateCore::addState((CicoStateCore*)state);
119 * @brief CicoStateMachine::addInitState
121 * @param state state-object pointer is tart position
123 inline void CicoStateMachine::addInitState(CicoState* state)
125 CicoStateCore::addInitState((CicoStateCore*)state);
129 * @brief CicoStateMachine::addInitState
130 * @param state state-object pointer is tart positions
132 inline void CicoStateMachine::addInitState(CicoHistoryState* state)
134 CicoStateCore::addInitState((CicoStateCore*)state);
138 * @brief CicoStateMachine::getCurrentState
139 * @param states active state-object pointers store area
140 * @param policy get policy
141 * @return true:get success / false get fail
143 inline bool CicoStateMachine::getCurrentState(std::vector<const CicoState*>& states,
144 CicoStateCore::E_GetPolicy policy)
146 return CicoStateCore::getCurrentState(states, policy);
150 * @brief CicoStateMachine::getCurrentState
151 * @ get active state-object
152 * @return active state-object pointer
154 inline const CicoState* CicoStateMachine::getCurrentState()
156 return CicoStateCore::getCurrentState();
160 * @brief CicoStateMachine::getState
161 * @param value state-object identification number
162 * @return not 0:state-object pointer/0 get fail
164 inline const CicoStateCore* CicoStateMachine::getState(const int value) const
166 return CicoStateCore::getState(value);
170 * @brief CicoStateMachine::getState
171 * @param name state-object identification name
172 * @return not 0:state-object pointer/0 get fail
174 inline const CicoStateCore* CicoStateMachine::getState(const std::string& name) const
176 return CicoStateCore::getState(name);
179 #endif // CICOSTATEMACHINE_H