2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_StateMachine
21 /// This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
22 /// from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
23 /// from one state to another state.
25 ///////////////////////////////////////////////////////////////////////////////
28 * @file frameworkunified_sm_externaltransition.h
29 * @brief \~english This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
30 * from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
31 * from one state to another state.
33 /** @addtogroup BaseSystem
36 /** @addtogroup native_service
40 /** @addtogroup framework_unified
41 * @ingroup native_service
44 /** @addtogroup framework
45 * @ingroup framework_unified
48 /** @addtogroup statemachine
52 #ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__ // NOLINT (build/header_guard)
53 #define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
57 ///////////////////////////////////////////////////////////////////////////////////////////////////
59 #include <native_service/frameworkunified_sm_transition.h>
61 class CFrameworkunifiedGuard;
62 class CFrameworkunifiedAction;
65 ///////////////////////////////////////////////////////////////////////////////////////////////////
66 /// This class implements the FrameworkunifiedReaction interface to support transition
67 /// from one state to another state.
68 ///////////////////////////////////////////////////////////////////////////////////////////////////
69 class CFrameworkunifiedExternalTransition : public CFrameworkunifiedTransition {
72 ///////////////////////////////////////////////////////////////////////////////////////////
73 /// \ingroup CFrameworkunifiedExternalTransition
74 /// \~english @par Brief
75 /// Constructor for class CFrameworkunifiedExternalTransition.
76 /// \~english @param [in] f_pTargetState
77 /// CFrameworkunifiedState* - pointer of target CFrameworkunifiedState object
78 /// \~english @retval none
79 /// \~english @par Prerequisite
81 /// \~english @par Change of internal state
83 /// \~english @par Conditions of processing failure
85 /// \~english @par Detail
86 /// inherit the CFrameworkunifiedTransition class and create instance of CFrameworkunifiedExternalTransition class \n
87 /// create the list for CFrameworkunifiedAction class,set pointer as member parameter\n
88 /// this class is intanced with FrameworkunifiedReaction interfase in order to support changing one state to other state.
89 /// \~english @par Classification
91 /// \~english @par Type
93 /// \~english @see CFrameworkunifiedExternalTransition, FrameworkunifiedReaction, FrameworkunifiedAddAction
94 ///////////////////////////////////////////////////////////////////////////////////////////
95 /// CFrameworkunifiedExternalTransition
96 /// Parameterized constructor
97 /// \param [in] f_pTargetState
98 /// CFrameworkunifiedState* - Target state object
101 CFrameworkunifiedExternalTransition(CFrameworkunifiedState *f_pTargetState); // NOLINT (readability/nolint)
103 ///////////////////////////////////////////////////////////////////////////////////////////
104 /// \ingroup CFrameworkunifiedExternalTransition
105 /// \~english @par Brief
106 /// Destructor for CFrameworkunifiedExternalTransition
107 /// \~english @retval none
108 /// \~english @par Preconditons
109 /// - Self instance of CFrameworkunifiedExternalTransition created.
110 /// \~english @par Change of internal status
112 /// \~english @par Conditions of processing failure
114 /// \~english @par Detail
115 /// Class CFrameworkunifiedHistoryState instance release. \n
116 /// Member variable active action list of CFrameworkunifiedAction release.\n
117 /// \~english @par Classification
119 /// \~english @par Type
121 /// \~english @see CFrameworkunifiedExternalTransition::CFrameworkunifiedExternalTransition
122 ///////////////////////////////////////////////////////////////////////////////////////////
123 ///////////////////////////////////////////////////////////////////////////////////////////
124 /// ~CFrameworkunifiedExternalTransition
128 virtual ~CFrameworkunifiedExternalTransition();
130 ///////////////////////////////////////////////////////////////////////////////////////////
131 /// \ingroup CFrameworkunifiedExternalTransition
132 ///////////////////////////////////////////////////////////////////////////////////////////
133 ///////////////////////////////////////////////////////////////////////////////////////////
134 /// FrameworkunifiedReaction
135 /// The reaction for an event is implemented in this function. For external transition, Exit
136 /// of the source state is called and entry of the target state is called recursively.
138 /// \~english @par Brief
139 /// CFrameworkunifiedExternalTransition instance event process.
140 /// \~english @param f_pSourceState
141 /// CFrameworkunifiedState* - source state object pointer
142 /// \~english @param f_pData
143 /// CEventDataPtr* - CEventData event pointer
144 /// \~english @retval CFrameworkunifiedState* active state pointer
145 /// \~english @retval NULL
146 /// \~english @par Preconditons
147 /// - Self instance of CFrameworkunifiedExternalTransition created.
148 /// \~english @par Change of internal status
149 /// - If input parameter f_pSourceState is NULL. [NULL]
150 /// - If member variable m_pTargetState is NULL. [NULL]
151 /// \~english @par Conditions of processing failure
153 /// \~english @par Detail
154 /// if the self-instance has guard object,event operation will not conduct.
155 /// return soucestate(CFrameworkunifiedState class)object()f_pSourceState(set from parameter) as
156 /// activestate(CFrameworkunifiedState class)object\n
157 /// as activestate(CFrameworkunifiedState class)object
158 /// if there is no guard object:
159 /// - Exit process(FrameworkunifiedOnHSMStop call)for sorcestate(CFrameworkunifiedStateclass)object will conduct once more.
160 /// - Entryt process(FrameworkunifiedOnHSMStart call)for target state(CFrameworkunifiedState class)objectwill conduct once more.
161 /// \~english @par Classification
163 /// \~english @par Type
165 /// \~english @see FrameworkunifiedSetGuard, FrameworkunifiedAddAction
166 ///////////////////////////////////////////////////////////////////////////////////////////
167 virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
169 ///////////////////////////////////////////////////////////////////////////////////////////
170 /// \ingroup CFrameworkunifiedExternalTransition
171 /// \~english @par Brief
172 /// Sets the Guard object in External Transition
173 /// \~english @param f_pGuard
174 /// CFrameworkunifiedGuard* - CFrameworkunifiedGuard object pointer
175 /// \~english @retval eFrameworkunifiedStatusOK success
176 /// \~english @retval eFrameworkunifiedStatusNullPointer set null pointer
177 /// \~english @par Preconditons
178 /// - Self instance of CFrameworkunifiedExternalTransition created.
179 /// \~english @par Change of internal status
180 /// - If input parameter CFrameworkunifiedGuard is NULL. [eFrameworkunifiedStatusNullPointer]
181 /// \~english @par Conditions of processing failure
183 /// \~english @par Detail
184 /// Sets the Guard object in CFrameworkunifiedExternalTransition instance\n
185 /// in order to guard the transform process. and during setting process,\n
186 /// transform is not conduct
187 /// \~english @par Classification
189 /// \~english @par Type
191 /// \~english @see FrameworkunifiedReaction, FrameworkunifiedAddAction
192 ///////////////////////////////////////////////////////////////////////////////////////////
193 ///////////////////////////////////////////////////////////////////////////////////////////
194 /// FrameworkunifiedSetGuard
195 /// Sets the Guard object in External Transition
197 /// \param [in] f_pGuard
198 /// CFrameworkunifiedGuard* - guard object
202 /// EFrameworkunifiedStatus -
204 virtual EFrameworkunifiedStatus FrameworkunifiedSetGuard(CFrameworkunifiedGuard *f_pGuard);
206 ///////////////////////////////////////////////////////////////////////////////////////////
207 /// \ingroup CFrameworkunifiedExternalTransition
208 /// \~english @par Brief
209 /// Adds CFrameworkunifiedAction object to the action list
210 /// \~english @param f_pAction
211 /// CFrameworkunifiedAction* - CFrameworkunifiedAction object pointer
212 /// \~english @retval eFrameworkunifiedStatusOK success
213 /// \~english @retval eFrameworkunifiedStatusNullPointer set null pointer
214 /// \~english @par Preconditons
215 /// - Self instance of CFrameworkunifiedExternalTransition created.
216 /// \~english @par Change of internal status
218 /// \~english @par Conditions of processing failure
219 /// - If input parameter CFrameworkunifiedAction is NULL. [eFrameworkunifiedStatusNullPointer]
220 /// - If member variable m_pActionList is NULL. [eFrameworkunifiedStatusNullPointer]
221 /// \~english @par Detail
222 /// add CFrameworkunifiedAction class object to the end of the list for CFrameworkunifiedAction class in parameter
223 /// \~english @par Classification
225 /// \~english @par Type
227 /// \~english @see FrameworkunifiedReaction, FrameworkunifiedSetGuard
228 ///////////////////////////////////////////////////////////////////////////////////////////
229 virtual EFrameworkunifiedStatus FrameworkunifiedAddAction(CFrameworkunifiedAction *f_pAction);
233 /// pointer to the guard condition object
234 CFrameworkunifiedGuard *m_pGuard;
236 ///////////////////////////////////////////////////////////////////////////////////////////
237 /// ExecuteTransition
238 /// Execute the transition actions, calls OnExit of Source State and OnEntry of target state
240 /// \param [in] f_pSourceState
241 /// CEventDataPtr - source state
243 /// \param [in] f_pData
244 /// CFrameworkunifiedState* - Event data
248 /// EFrameworkunifiedStatus -
250 ///////////////////////////////////////////////////////////////////////////////////////////
251 CFrameworkunifiedState *ExecuteTransition(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
254 typedef std::vector<CFrameworkunifiedAction *> TActionList;
256 // Action list iterator
257 typedef TActionList::iterator TActionListIterator;
259 // List of conditions
260 TActionList *m_pActionList;
262 #endif // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__ // NOLINT (build/header_guard)