summaryrefslogtreecommitdiffstats
path: root/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_externaltransition.h
blob: a466806414c6bae605aff90435c3abfd2e7e2381 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

///////////////////////////////////////////////////////////////////////////////
/// \ingroup  tag_StateMachine
/// \brief
///
/// This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
/// from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
/// from one state to another state.
///
///////////////////////////////////////////////////////////////////////////////
//@{
/**
 * @file frameworkunified_sm_externaltransition.h
 * @brief \~english This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
 *        from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
 *        from one state to another state.
 */
/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup native_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup framework_unified
 *  @ingroup native_service
 *  @{
 */
/** @addtogroup framework
 *  @ingroup framework_unified
 *  @{
 */
/** @addtogroup statemachine
 *  @ingroup framework
 *  @{
 */
#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__  // NOLINT  (build/header_guard)
#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__

///////////////////////////////////////////////////////////////////////////////////////////////////
// Include Files
///////////////////////////////////////////////////////////////////////////////////////////////////

#include <native_service/frameworkunified_sm_transition.h>
#include <vector>
class CFrameworkunifiedGuard;
class CFrameworkunifiedAction;
class CEventData;

///////////////////////////////////////////////////////////////////////////////////////////////////
/// This class implements the FrameworkunifiedReaction interface to support transition
/// from one state to another state.
///////////////////////////////////////////////////////////////////////////////////////////////////
class CFrameworkunifiedExternalTransition : public CFrameworkunifiedTransition {
 public :

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedExternalTransition
  /// \~english @par Brief
  ///          Constructor for class CFrameworkunifiedExternalTransition.
  /// \~english @param [in] f_pTargetState
  ///        CFrameworkunifiedState*   - pointer of target CFrameworkunifiedState object
  /// \~english @retval none
  /// \~english @par Prerequisite
  ///            none
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            none
  /// \~english @par Detail
  ///           inherit the CFrameworkunifiedTransition class and create instance of CFrameworkunifiedExternalTransition class \n
  ///           create the list for CFrameworkunifiedAction class,set pointer as member parameter\n
  ///           this class is intanced with FrameworkunifiedReaction interfase in order to support changing one state to other state.
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see CFrameworkunifiedExternalTransition, FrameworkunifiedReaction, FrameworkunifiedAddAction
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// CFrameworkunifiedExternalTransition
  /// Parameterized constructor
  /// \param [in] f_pTargetState
  ///     CFrameworkunifiedState* - Target state object
  ///
  /// \return none
  CFrameworkunifiedExternalTransition(CFrameworkunifiedState *f_pTargetState);  // NOLINT  (readability/nolint)

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedExternalTransition
  /// \~english @par Brief
  ///        Destructor for CFrameworkunifiedExternalTransition
  /// \~english @retval none
  /// \~english @par Preconditons
  ///          - Self instance of CFrameworkunifiedExternalTransition created.
  /// \~english @par Change of internal status
  ///                none
  /// \~english @par Conditions of processing failure
  ///                none
  /// \~english @par Detail
  ///          Class CFrameworkunifiedHistoryState instance release. \n
  ///          Member variable active action list of CFrameworkunifiedAction release.\n
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///            none
  /// \~english @see CFrameworkunifiedExternalTransition::CFrameworkunifiedExternalTransition
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// ~CFrameworkunifiedExternalTransition
  /// Class destructor
  ///
  /// \return none
  virtual ~CFrameworkunifiedExternalTransition();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedExternalTransition
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedReaction
  /// The reaction for an event is implemented in this function. For external transition, Exit
  /// of the source state is called and entry of the target state is called recursively.
  ///
  /// \~english @par Brief
  ///         CFrameworkunifiedExternalTransition instance event process.
  /// \~english @param f_pSourceState
  ///       CFrameworkunifiedState* - source state object pointer
  /// \~english @param f_pData
  ///       CEventDataPtr* - CEventData event pointer
  /// \~english @retval CFrameworkunifiedState* active state pointer
  /// \~english @retval NULL
  /// \~english @par Preconditons
  ///          - Self instance of CFrameworkunifiedExternalTransition created.
  /// \~english @par Change of internal status
  ///                - If input parameter f_pSourceState is NULL. [NULL]
  ///                - If member variable m_pTargetState is NULL. [NULL]
  /// \~english @par Conditions of processing failure
  ///                none
  /// \~english @par Detail
  ///      if the self-instance has guard object,event operation will not conduct.
  ///      return soucestate(CFrameworkunifiedState class)object()f_pSourceState(set from parameter) as
  ///      activestate(CFrameworkunifiedState class)object\n
  ///      as activestate(CFrameworkunifiedState class)object
  ///      if there is no guard object:
  ///       - Exit process(FrameworkunifiedOnHSMStop call)for sorcestate(CFrameworkunifiedStateclass)object will conduct once more.
  ///       - Entryt process(FrameworkunifiedOnHSMStart call)for target state(CFrameworkunifiedState class)objectwill conduct once more.
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///            none
  /// \~english @see FrameworkunifiedSetGuard, FrameworkunifiedAddAction
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedExternalTransition
  /// \~english @par Brief
  ///         Sets the Guard object in External Transition
  /// \~english @param f_pGuard
  ///       CFrameworkunifiedGuard* - CFrameworkunifiedGuard object pointer
  /// \~english @retval eFrameworkunifiedStatusOK           success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  set null pointer
  /// \~english @par Preconditons
  ///          - Self instance of CFrameworkunifiedExternalTransition created.
  /// \~english @par Change of internal status
  ///                - If input parameter CFrameworkunifiedGuard is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Conditions of processing failure
  ///                none
  /// \~english @par Detail
  ///           Sets the Guard object in CFrameworkunifiedExternalTransition instance\n
  ///           in order to guard the transform process. and during setting process,\n
  ///           transform is not conduct
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///            none
  /// \~english @see FrameworkunifiedReaction, FrameworkunifiedAddAction
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedSetGuard
  /// Sets the Guard object in External Transition
  ///
  /// \param [in] f_pGuard
  ///     CFrameworkunifiedGuard* - guard object
  ///
  ///
  /// \return status
  ///         EFrameworkunifiedStatus -
  ///
  virtual EFrameworkunifiedStatus FrameworkunifiedSetGuard(CFrameworkunifiedGuard *f_pGuard);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedExternalTransition
  /// \~english @par Brief
  ///         Adds CFrameworkunifiedAction object to the action list
  /// \~english @param f_pAction
  ///       CFrameworkunifiedAction* - CFrameworkunifiedAction object pointer
  /// \~english @retval eFrameworkunifiedStatusOK           success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  set null pointer
  /// \~english @par Preconditons
  ///          - Self instance of CFrameworkunifiedExternalTransition created.
  /// \~english @par Change of internal status
  ///               none
  /// \~english @par Conditions of processing failure
  ///                - If input parameter CFrameworkunifiedAction is NULL. [eFrameworkunifiedStatusNullPointer]
  ///                - If member variable m_pActionList is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///              add CFrameworkunifiedAction class object to the end of the list for CFrameworkunifiedAction class in parameter
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///            none
  /// \~english @see FrameworkunifiedReaction, FrameworkunifiedSetGuard
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual EFrameworkunifiedStatus FrameworkunifiedAddAction(CFrameworkunifiedAction *f_pAction);


 protected :
  /// pointer to the guard condition object
  CFrameworkunifiedGuard *m_pGuard;

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// ExecuteTransition
  /// Execute the transition actions, calls OnExit of Source State and OnEntry of target state
  ///
  /// \param [in] f_pSourceState
  ///     CEventDataPtr - source state
  ///
  /// \param [in] f_pData
  ///     CFrameworkunifiedState* - Event data
  ///
  ///
  /// \return status
  ///         EFrameworkunifiedStatus -
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  CFrameworkunifiedState *ExecuteTransition(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);

  // Action list
  typedef std::vector<CFrameworkunifiedAction *> TActionList;

  // Action list iterator
  typedef TActionList::iterator TActionListIterator;

  // List of conditions
  TActionList *m_pActionList;
};
#endif  // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__  // NOLINT  (build/header_guard)
/** @}*/
/** @}*/
/** @}*/
/** @}*/
/** @}*/
//@}