Init basesystem source codes.
[staging/basesystem.git] / nsframework / framework_unified / client / include / native_service / frameworkunified_sm_externaltransition.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_StateMachine
19 /// \brief
20 ///
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.
24 ///
25 ///////////////////////////////////////////////////////////////////////////////
26 //@{
27 /**
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.
32  */
33 /** @addtogroup BaseSystem
34  *  @{
35  */
36 /** @addtogroup native_service
37  *  @ingroup BaseSystem
38  *  @{
39  */
40 /** @addtogroup framework_unified
41  *  @ingroup native_service
42  *  @{
43  */
44 /** @addtogroup framework
45  *  @ingroup framework_unified
46  *  @{
47  */
48 /** @addtogroup statemachine
49  *  @ingroup framework
50  *  @{
51  */
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__
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 // Include Files
57 ///////////////////////////////////////////////////////////////////////////////////////////////////
58
59 #include <native_service/frameworkunified_sm_transition.h>
60 #include <vector>
61 class CFrameworkunifiedGuard;
62 class CFrameworkunifiedAction;
63 class CEventData;
64
65 ///////////////////////////////////////////////////////////////////////////////////////////////////
66 /// This class implements the FrameworkunifiedReaction interface to support transition
67 /// from one state to another state.
68 ///////////////////////////////////////////////////////////////////////////////////////////////////
69 class CFrameworkunifiedExternalTransition : public CFrameworkunifiedTransition {
70  public :
71
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
80   ///            none
81   /// \~english @par Change of internal state
82   ///            none
83   /// \~english @par Conditions of processing failure
84   ///            none
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
90   ///           public
91   /// \~english @par Type
92   ///           none
93   /// \~english @see CFrameworkunifiedExternalTransition, FrameworkunifiedReaction, FrameworkunifiedAddAction
94   ///////////////////////////////////////////////////////////////////////////////////////////
95   /// CFrameworkunifiedExternalTransition
96   /// Parameterized constructor
97   /// \param [in] f_pTargetState
98   ///     CFrameworkunifiedState* - Target state object
99   ///
100   /// \return none
101   CFrameworkunifiedExternalTransition(CFrameworkunifiedState *f_pTargetState);  // NOLINT  (readability/nolint)
102
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
111   ///                none
112   /// \~english @par Conditions of processing failure
113   ///                none
114   /// \~english @par Detail
115   ///          Class CFrameworkunifiedHistoryState instance release. \n
116   ///          Member variable active action list of CFrameworkunifiedAction release.\n
117   /// \~english @par Classification
118   ///           public
119   /// \~english @par Type
120   ///            none
121   /// \~english @see CFrameworkunifiedExternalTransition::CFrameworkunifiedExternalTransition
122   ///////////////////////////////////////////////////////////////////////////////////////////
123   ///////////////////////////////////////////////////////////////////////////////////////////
124   /// ~CFrameworkunifiedExternalTransition
125   /// Class destructor
126   ///
127   /// \return none
128   virtual ~CFrameworkunifiedExternalTransition();
129
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.
137   ///
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
152   ///                none
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
162   ///           public
163   /// \~english @par Type
164   ///            none
165   /// \~english @see FrameworkunifiedSetGuard, FrameworkunifiedAddAction
166   ///////////////////////////////////////////////////////////////////////////////////////////
167   virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
168
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
182   ///                none
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
188   ///           public
189   /// \~english @par Type
190   ///            none
191   /// \~english @see FrameworkunifiedReaction, FrameworkunifiedAddAction
192   ///////////////////////////////////////////////////////////////////////////////////////////
193   ///////////////////////////////////////////////////////////////////////////////////////////
194   /// FrameworkunifiedSetGuard
195   /// Sets the Guard object in External Transition
196   ///
197   /// \param [in] f_pGuard
198   ///     CFrameworkunifiedGuard* - guard object
199   ///
200   ///
201   /// \return status
202   ///         EFrameworkunifiedStatus -
203   ///
204   virtual EFrameworkunifiedStatus FrameworkunifiedSetGuard(CFrameworkunifiedGuard *f_pGuard);
205
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
217   ///               none
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
224   ///           public
225   /// \~english @par Type
226   ///            none
227   /// \~english @see FrameworkunifiedReaction, FrameworkunifiedSetGuard
228   ///////////////////////////////////////////////////////////////////////////////////////////
229   virtual EFrameworkunifiedStatus FrameworkunifiedAddAction(CFrameworkunifiedAction *f_pAction);
230
231
232  protected :
233   /// pointer to the guard condition object
234   CFrameworkunifiedGuard *m_pGuard;
235
236   ///////////////////////////////////////////////////////////////////////////////////////////
237   /// ExecuteTransition
238   /// Execute the transition actions, calls OnExit of Source State and OnEntry of target state
239   ///
240   /// \param [in] f_pSourceState
241   ///     CEventDataPtr - source state
242   ///
243   /// \param [in] f_pData
244   ///     CFrameworkunifiedState* - Event data
245   ///
246   ///
247   /// \return status
248   ///         EFrameworkunifiedStatus -
249   ///
250   ///////////////////////////////////////////////////////////////////////////////////////////
251   CFrameworkunifiedState *ExecuteTransition(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
252
253   // Action list
254   typedef std::vector<CFrameworkunifiedAction *> TActionList;
255
256   // Action list iterator
257   typedef TActionList::iterator TActionListIterator;
258
259   // List of conditions
260   TActionList *m_pActionList;
261 };
262 #endif  // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__  // NOLINT  (build/header_guard)
263 /** @}*/
264 /** @}*/
265 /** @}*/
266 /** @}*/
267 /** @}*/
268 //@}