1a8e1d740b214e0d68bc1509c6a943440f1c53da
[staging/basesystem.git] / service / native / framework_unified / client / include / native_service / frameworkunified_sm_hsm.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 CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
22 /// This class implements interfaces for connecting child states to parent states, connecting events
23 /// to state.
24 ///////////////////////////////////////////////////////////////////////////////
25 //@{
26 /**
27  * @file frameworkunified_sm_hsm.h
28  * @brief \~english This file has the CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
29  *        This class implements interfaces for connecting child states to parent states, connecting events to state.
30  */
31 /** @addtogroup BaseSystem
32  *  @{
33  */
34 /** @addtogroup native_service
35  *  @ingroup BaseSystem
36  *  @{
37  */
38 /** @addtogroup framework_unified
39  *  @ingroup native_service
40  *  @{
41  */
42 /** @addtogroup framework
43  *  @ingroup framework_unified
44  *  @{
45  */
46 /** @addtogroup statemachine
47  *  @ingroup framework
48  *  @{
49  */
50 #ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__  // NOLINT  (build/header_guard)
51 #define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__
52
53 ///////////////////////////////////////////////////////////////////////////////////////////////////
54 // Include Files
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56
57 #include <native_service/frameworkunified_types.h>
58 #include <native_service/ns_logger_if.h>
59 #include <native_service/frameworkunified_sm_eventdata.h>
60 #include <vector>
61 #include <exception>
62 #include <map>
63 #include <string>
64
65 class CFrameworkunifiedEvent;
66
67 class CFrameworkunifiedState;
68
69 class CFrameworkunifiedCompositeState;
70
71 class CFrameworkunifiedReaction;
72
73 class CFrameworkunifiedOrthogonalState;
74
75 class CEventData;
76
77 typedef boost::shared_ptr<CEventData> CEventDataPtr;
78
79 ///////////////////////////////////////////////////////////////////////////////////////////////////
80 /// This class implements interfaces for connecting child states to parent states, connecting events
81 /// to state.
82 ///////////////////////////////////////////////////////////////////////////////////////////////////
83 class CFrameworkunifiedHSM {
84  public :
85
86   ///////////////////////////////////////////////////////////////////////////////////////////
87   /// \ingroup CFrameworkunifiedHSM
88   /// \~english @par Brief
89   ///        Destructor for CFrameworkunifiedHSM
90   /// \~english @retval none
91   /// \~english @par Preconditons
92   ///          - Self instance of CFrameworkunifiedHSM created.
93   /// \~english @par Change of internal status
94   ///                none
95   /// \~english @par Conditions of processing failure
96   ///                none
97   /// \~english @par Detail
98   ///          Release class CFrameworkunifiedHistoryState instance.\n
99   ///          Release event in postevent list.\n
100   /// \~english @par Classification
101   ///           public
102   /// \~english @par Type
103   ///            none
104   /// \~english @see none
105   ///////////////////////////////////////////////////////////////////////////////////////////
106   /// ~CFrameworkunifiedHSM
107   /// Class destructor
108   ///
109   /// \return none
110   virtual ~CFrameworkunifiedHSM();
111
112   ///////////////////////////////////////////////////////////////////////////////////////////
113   /// \ingroup CFrameworkunifiedHSM
114   /// \~english @par Brief
115   ///          Constructor for class CFrameworkunifiedHSM.
116   /// \~english @param
117   /// \~english @retval none
118   /// \~english @par Prerequisite
119   ///            none
120   /// \~english @par Change of internal state
121   ///            none
122   /// \~english @par Conditions of processing failure
123   ///            none
124   /// \~english @par Detail
125   ///       CFrameworkunifiedHSM class is the super class of HSM framework.
126   ///       this class produce interface to connected super class state with sub class state and to connect event with
127   ///       state
128   ///       create the instance of CFrameworkunifiedHSM class\n
129   ///       create event list as following and hold the member parameter,others will be initialized as NULL
130   ///       - event list which is supported in state
131   /// \~english @par Classification
132   ///           public
133   /// \~english @par Type
134   ///           none
135   /// \~english @see ~CFrameworkunifiedHSM
136   ///////////////////////////////////////////////////////////////////////////////////////////
137   CFrameworkunifiedHSM();
138
139   ///////////////////////////////////////////////////////////////////////////////////////////
140   /// \ingroup CFrameworkunifiedHSM
141   /// \~english @par Brief
142   ///          Constructor for class CFrameworkunifiedHSM.
143   /// \~english @param f_pHApp
144   ///          PVOID - handle of application
145   /// \~english @retval none
146   /// \~english @par Prerequisite
147   ///            none
148   /// \~english @par Change of internal state
149   ///            none
150   /// \~english @par Conditions of processing failure
151   ///            none
152   /// \~english @par Detail
153   ///       CFrameworkunifiedHSM class is the super class of HSM framework.
154   ///       this class produce interface to connected super class state with sub class state and to connect event with
155   ///       state
156   ///       create the instance of CFrameworkunifiedHSM class\n
157   ///       create event list as following and hold the member parameter,others will be initialized as NULL
158   ///       - event list which is supported in state
159   /// \~english @par Classification
160   ///           public
161   /// \~english @par Type
162   ///           none
163   /// \~english @see ~CFrameworkunifiedHSM
164   ///////////////////////////////////////////////////////////////////////////////////////////
165   ///////////////////////////////////////////////////////////////////////////////////////////
166   /// CFrameworkunifiedHSM(PVOID f_pHApp)
167   /// Class constructor
168   ///
169   /// \return none
170   CFrameworkunifiedHSM(PVOID f_pHApp);  // NOLINT  (readability/nolint)
171
172   ///////////////////////////////////////////////////////////////////////////////////////////
173   /// \ingroup CFrameworkunifiedHSM
174   /// \~english @par Brief
175   ///          Returns the active state of the statemachine
176   /// \~english @param none
177   /// \~english @retval CFrameworkunifiedState* - Returns ActiveState
178   /// \~english @retval NULL       - failed
179   /// \~english @par Prerequisite
180   ///            - Self instance of CFrameworkunifiedHSM created and active state exist.
181   /// \~english @par Change of internal state
182   ///            none
183   /// \~english @par Conditions of processing failure
184   ///            - active state do not exist. [NULL]
185   /// \~english @par Detail
186   ///       route state search will be continued until current state become active
187   ///       route state search will be continued until Leaf State or orthogonal State is found\n
188   ///       if there is no active state.reture NULL\n
189   ///       if there is active state,this state will be hold in memeber parameter as return value
190   /// \~english @par Classification
191   ///           public
192   /// \~english @par Type
193   ///           none
194   /// \~english @see CFrameworkunifiedState::FrameworkunifiedGetActiveState
195   ///////////////////////////////////////////////////////////////////////////////////////////
196   CFrameworkunifiedState *FrameworkunifiedGetActiveState();
197
198   ///////////////////////////////////////////////////////////////////////////////////////////
199   /// \ingroup CFrameworkunifiedHSM
200   /// \~english @par Brief
201   ///          This creates the default event data and sends the event to the active HSM state.
202   /// \~english @param f_uiEventId
203   ///           UI_32 - Event Id
204   /// \~english @retval eFrameworkunifiedStatusOK            add succ
205   /// \~english @retval eFrameworkunifiedStatusNullPointer   set null pointer
206   /// \~english @par Prerequisite
207   ///            - Self instance of CFrameworkunifiedHSM created.
208   /// \~english @par Change of internal state
209   ///            none
210   /// \~english @par Conditions of processing failure
211   ///       - Event data instance create faield. [eFrameworkunifiedStatusNullPointer]
212   ///       - The pointer of post event list in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
213   ///       - The pointer of active state in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
214   ///       - The name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
215   /// \~english @par Detail
216   ///       create new event data object and send this event to active HSM state,\n
217   ///       then add to event queue of the statemachine
218   ///       add to event queque in order to process event using statemachine
219   ///       event will be deleted from event queue when process complete
220   /// \~english @par Classification
221   ///           public
222   /// \~english @par Type
223   ///           none
224   /// \~english @see FrameworkunifiedPostEvent(CEventDataPtr), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
225   ///////////////////////////////////////////////////////////////////////////////////////////
226   ///////////////////////////////////////////////////////////////////////////////////////////
227   /// FrameworkunifiedPostEvent
228   /// This creates the default event data and sends the event to the active HSM state.
229   ///
230   /// \param [in] f_uiEventId
231   ///     UI_32 - Event Id
232   ///
233   /// \return EFrameworkunifiedStatus
234   ///         EFrameworkunifiedStatus - Returns status of operation
235   ///
236   EFrameworkunifiedStatus FrameworkunifiedPostEvent(UI_32 f_uiEventId);
237
238   ///////////////////////////////////////////////////////////////////////////////////////////
239   /// \ingroup CFrameworkunifiedHSM
240   ///////////////////////////////////////////////////////////////////////////////////////////
241   ///////////////////////////////////////////////////////////////////////////////////////////
242   /// FrameworkunifiedPostEvent
243   /// This sends the event to the active HSM state
244   ///
245   /// \~english @par Brief
246   ///          Add event data into event queue of state machine.
247   /// \~english @param f_pEventData
248   ///           CEventDataPtr - Event data
249   /// \~english @retval eFrameworkunifiedStatusOK            add succ
250   /// \~english @retval eFrameworkunifiedStatusNullPointer   set null pointer
251   /// \~english @par Prerequisite
252   ///            - Self instance of CFrameworkunifiedHSM created.
253   /// \~english @par Change of internal state
254   ///            none
255   /// \~english @par Conditions of processing failure
256   ///       - Input parameter f_pEventData is NULL. [eFrameworkunifiedStatusNullPointer]
257   ///       - The pointer of post event list in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
258   ///       - The pointer of active state in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
259   ///       - The name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
260   /// \~english @par Detail
261   ///
262   /// \~english @par Classification
263   ///           public
264   /// \~english @par Type
265   ///           none
266   /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
267   ///////////////////////////////////////////////////////////////////////////////////////////
268   EFrameworkunifiedStatus FrameworkunifiedPostEvent(CEventDataPtr f_pEventData);
269
270   ///////////////////////////////////////////////////////////////////////////////////////////
271   /// \ingroup CFrameworkunifiedHSM
272   /// \~english @par Brief
273   ///         This is pure virtual function to be implemented by the derived classes. Statemachine
274   ///         states and events created and connected in this interface.
275   /// \~english @param f_pEventData
276   ///           PVOID - Event data
277   /// \~english @retval EFrameworkunifiedStatus      Returns status of operation
278   /// \~english @par Prerequisite
279   ///            - Self instance of CFrameworkunifiedHSM created.
280   /// \~english @par Change of internal state
281   ///            none
282   /// \~english @par Conditions of processing failure
283   //             none
284   /// \~english @par Detail
285   ///           none
286   /// \~english @par Classification
287   ///           public
288   /// \~english @par Type
289   ///           none
290   /// \~english @see none
291   ///////////////////////////////////////////////////////////////////////////////////////////
292   virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_pEventData = NULL) = 0;
293
294   ///////////////////////////////////////////////////////////////////////////////////////////
295   /// \ingroup CFrameworkunifiedHSM
296   ///////////////////////////////////////////////////////////////////////////////////////////
297   ///////////////////////////////////////////////////////////////////////////////////////////
298   /// FrameworkunifiedStart
299   /// This starts the state machine
300   ///
301   /// \~english @par Brief
302   ///         Start the state machine.
303   /// \~english @param f_pEventData
304   ///           CEventDataPtr - Event data
305   /// \~english @retval EFrameworkunifiedStatus      eFrameworkunifiedStatusOK   succ
306   /// \~english @retval eFrameworkunifiedStatusNullPointer  set null pointer
307   /// \~english @par Prerequisite
308   ///            - Self instance of CFrameworkunifiedHSM created.
309   /// \~english @par Change of internal state
310   ///            none
311   /// \~english @par Conditions of processing failure
312   //            - Pointer of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
313   /// \~english @par Detail
314   ///
315   /// \~english @par Classification
316   ///           public
317   /// \~english @par Type
318   ///           none
319   /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
320   ///////////////////////////////////////////////////////////////////////////////////////////
321   EFrameworkunifiedStatus FrameworkunifiedStart(CEventDataPtr f_pEventData = boost::make_shared<CEventData>(0));
322
323   ///////////////////////////////////////////////////////////////////////////////////////////
324   /// \ingroup CFrameworkunifiedHSM
325   /// \~english @par Brief
326   ///         Stop the state machine.
327   /// \~english @param f_pEventData
328   ///           CEventDataPtr - Event data
329   /// \~english @retval EFrameworkunifiedStatus
330   /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
331   /// \~english @par Prerequisite
332   ///            - Self instance of CFrameworkunifiedHSM created.
333   /// \~english @par Change of internal state
334   ///            none
335   /// \~english @par Conditions of processing failure
336   //            - Pointer of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
337   /// \~english @par Detail
338   ///           Stop the state machine.\n
339   ///           Release route state of state machine.\n
340   /// \~english @par Classification
341   ///           public
342   /// \~english @par Type
343   ///           none
344   /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
345   ///////////////////////////////////////////////////////////////////////////////////////////
346   EFrameworkunifiedStatus FrameworkunifiedClose(CEventDataPtr f_pEventData = boost::make_shared<CEventData>(0));
347
348   ///////////////////////////////////////////////////////////////////////////////////////////
349   /// \ingroup CFrameworkunifiedHSM
350   ///////////////////////////////////////////////////////////////////////////////////////////
351   ///////////////////////////////////////////////////////////////////////////////////////////
352   /// FrameworkunifiedPrintAllStates
353   /// This prints all states and events associated with every state on console.
354   ///
355   /// \~english @par Brief
356   ///         Output log of all states and events name associated with every state.
357   /// \~english @param
358   /// \~english @retval EFrameworkunifiedStatus      succ
359   /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
360   /// \~english @par Prerequisite
361   ///            - Self instance of CFrameworkunifiedHSM created.
362   /// \~english @par Change of internal state
363   ///            none
364   /// \~english @par Conditions of processing failure
365   ///           - Root state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
366   ///           - Self instance of CFrameworkunifiedHSM does not create.  [eFrameworkunifiedStatusNullPointer]
367   /// \~english @par Detail
368   ///       print out log for connected state name and event name\n
369   ///       following log will be print put
370   ///       - super statemachine state name and self-statemachine state name
371   ///       - all the event name on event list
372   ///       - all the event on delayed event list
373   /// \~english @par Classification
374   ///           public
375   /// \~english @par Type
376   ///           none
377   /// \~english @see 
378   ///////////////////////////////////////////////////////////////////////////////////////////
379   EFrameworkunifiedStatus FrameworkunifiedPrintAllStates();
380
381   ///////////////////////////////////////////////////////////////////////////////////////////
382   /// \ingroup CFrameworkunifiedHSM
383   /// \~english @par Brief
384   ///             This connects the reaction to event and add event to child states then add child state
385   ///             to parent state.
386   /// \~english @param f_pParentState
387   ///      CFrameworkunifiedState* - Parent state pointer
388   /// \~english @param f_pChildState
389   ///      CFrameworkunifiedState* - Child state pointer
390   /// \~english @param f_uiEventId
391   ///      UI_32 - eventi id
392   /// \~english @param f_pReaction
393   ///      CFrameworkunifiedReaction* - Reaction object for attaching to event
394   /// \~english @param f_eIsDefaultState
395   ///      BOOL - Does has default state.(default: FALSE)
396   /// \~english @par
397   ///      - TRUE : has default state
398   ///      - FALSE: not has default state
399   /// \~english @param f_eIsDeferredEventType
400   ///      BOOL -  Does has the deferred event(default: FALSE)
401   /// \~english @par
402   ///      - TRUE : has the deferred event
403   ///      - FALSE: not has the deferred event
404   /// \~english @param f_strEventName
405   ///      std::string - name of event(default:"")
406   /// \~english @retval eFrameworkunifiedStatusOK           succ
407   /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
408   /// \~english @par Prerequisite
409   ///            - Self instance of CFrameworkunifiedHSM created.
410   /// \~english @par Change of internal state
411   ///            none
412   /// \~english @par Conditions of processing failure
413   ///       - Input parameter f_pParentState pointer is NULL.[eFrameworkunifiedStatusNullPointer]
414   ///       - Input parameter f_pChildState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
415   ///       - Input parameter f_pReaction pointer is NULL. [eFrameworkunifiedStatusNullPointer]
416   ///       - Input parameter f_pParentState does not instance. [eFrameworkunifiedStatusNullPointer]
417   ///       - Input parameter f_pChildState does not instance. [eFrameworkunifiedStatusNullPointer]
418   /// \~english @par Detail
419   ///       connect process with event and add the event to sub state.
420   ///       and do following considering the event delay and event declare(f_eIsDeferredEventType)
421   ///        - if TRUE : add the event as delayed event(add to event name list and delayed event list)
422   ///        - if FALSE:add normal event and event(add to event name list and event list)
423   /// \~english @par
424   ///       After adding an event to a child state, associate the child state with the parent state and
425   ///       set the HSM state machine for the child state only if the parent state is a compound state.
426   ///       The following associations are made depending on whether or not a default state is defined (f_eIsDefaultState).
427   ///       - TRUE: Associates a child state as the default state with the parent state.
428   ///       - FALSE: Associates a child state with a parent state as a normal state.
429   /// \~english @par Classification
430   ///           public
431   /// \~english @par Type
432   ///           none
433   /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,std::string,BOOL),
434   ///           FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,BOOL)
435   ///////////////////////////////////////////////////////////////////////////////////////////
436   ///////////////////////////////////////////////////////////////////////////////////////////
437   /// FrameworkunifiedConnect
438   /// This connects the reaction to event and add event to child states then add child state
439   /// to parent state.
440   ///
441   /// \param [in] f_pParentState
442   ///     CFrameworkunifiedState* - Parent state
443   ///
444   /// \param [in] f_pChildState
445   ///     CFrameworkunifiedState* - Child state
446   ///
447   /// \param [in] f_uiEventId
448   ///     UI_32 - Event id
449   ///
450   /// \param [in] f_pReaction
451   ///     CFrameworkunifiedReaction* - Reaction object for attaching to event
452   ///
453   /// \param [in] f_eIsDefaultState
454   ///     BOOL - Defines if the state is default state
455   ///
456   /// \param [in] f_eIsDeferredEventType
457   ///     BOOL - defines if the event is deferred event
458   ///
459   /// \param [in] f_strEventName
460   ///     BOOL - Event name
461   ///
462   /// \return EFrameworkunifiedStatus
463   ///         EFrameworkunifiedStatus - Returns status of operation
464   ///
465   EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
466                          UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
467                          BOOL f_eIsDefaultState = FALSE,
468                          BOOL f_eIsDeferredEventType = FALSE,
469                          std::string f_strEventName = "");
470
471   ///////////////////////////////////////////////////////////////////////////////////////////
472   /// \ingroup CFrameworkunifiedHSM
473   /// \~english @par Brief
474   ///           This add child state to parent state.
475   /// \~english @param f_pParentState
476   ///      CFrameworkunifiedState* - Parent state pointer
477   /// \~english @param f_pChildState
478   ///      CFrameworkunifiedState* - Child state pointer
479   /// \~english @param f_eIsDefaultState
480   ///      BOOL - Does has default state.(default: FALSE)
481   /// \~english @par
482   ///      - TRUE : has default state
483   ///      - FALSE: not has default state
484   /// \~english @retval eFrameworkunifiedStatusOK           succ
485   /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
486   /// \~english @par Prerequisite
487   ///            - Self instance of CFrameworkunifiedHSM created.
488   /// \~english @par Change of internal state
489   ///            none
490   /// \~english @par Conditions of processing failure
491   ///       - Input parameter f_pParentState pointer is NULL.[eFrameworkunifiedStatusNullPointer]
492   ///       - Input parameter f_pChildState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
493   ///       - Input parameter f_pParentState does not instance. [eFrameworkunifiedStatusNullPointer]
494   ///       - Input parameter f_pChildState does not instance. [eFrameworkunifiedStatusNullPointer]
495   /// \~english @par Detail
496   ///       connect super state with sub state and set HSM state machine to sub state only when super state is compond
497   ///       state
498   ///       according to the default state define(f_eIsDefaultState),doing the connection below
499   ///       - if TRUE: connect sub state as default state with super state
500   ///       - if FALSE: connect sub state as normal state with super state
501   /// \~english @par Classification
502   ///           public
503   /// \~english @par Type
504   ///           none
505   /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,std::string,BOOL),
506   ///
507   ///////////////////////////////////////////////////////////////////////////////////////////
508   ///////////////////////////////////////////////////////////////////////////////////////////
509   /// FrameworkunifiedConnect
510   /// This add child state to parent state.
511   ///
512   /// \param [in] f_pParentState
513   ///     CFrameworkunifiedState* - Parent state
514   ///
515   /// \param [in] f_pChildState
516   ///     CFrameworkunifiedState* - Child state
517   ///
518   /// \param [in] f_eIsDefaultState
519   ///     BOOL - Defines if the state is default state
520   ///
521   /// \return EFrameworkunifiedStatus
522   ///         EFrameworkunifiedStatus - Returns status of operation
523   ///
524   EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
525                          BOOL f_eIsDefaultState = FALSE);
526
527   ///////////////////////////////////////////////////////////////////////////////////////////
528   /// \ingroup CFrameworkunifiedHSM
529   ///////////////////////////////////////////////////////////////////////////////////////////
530   ///////////////////////////////////////////////////////////////////////////////////////////
531   /// FrameworkunifiedConnect
532   /// This connects the reaction to event and add event to states
533   ///
534   /// \~english @par Brief
535   ///             This connects the reaction to event and add event to states.
536   /// \~english @param f_pState
537   ///      CFrameworkunifiedState* - pointer of state class
538   /// \~english @param f_uiEventId
539   ///      UI_32 - eventi id
540   /// \~english @param f_pReaction
541   ///      CFrameworkunifiedReaction* - Reaction object for attaching to event
542   /// \~english @param f_eIsDefaultState
543   ///      BOOL - Does has default state.(default: FALSE)
544   /// \~english @par
545   ///      - TRUE : has default state
546   ///      - FALSE: not has default state
547   /// \~english @param f_eIsDeferredEventType
548   ///      BOOL -  Does has the deferred event(default: FALSE)
549   /// \~english @par
550   ///      - TRUE : has the deferred event
551   ///      - FALSE: not has the deferred event
552   /// \~english @param f_strEventName
553   ///      std::string - name of event(default:"")
554   /// \~english @retval eFrameworkunifiedStatusOK           succ
555   /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
556   /// \~english @par Prerequisite
557   ///            - Self instance of CFrameworkunifiedHSM created.
558   /// \~english @par Change of internal state
559   ///            none
560   /// \~english @par Conditions of processing failure
561   ///       - Input parameter f_pReaction pointer is NULL.[eFrameworkunifiedStatusNullPointer]
562   ///       - Input parameter f_pState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
563   ///       - Input parameter f_pState pointer does not instance. [eFrameworkunifiedStatusNullPointer]
564   /// \~english @par Detail
565   ///       connect process with event and add event to sub state
566   ///       following will be added according to whether delayed event or event define exsist
567   ///        - if TRUE : add event as delayed event(add to event name list and delayed event list)
568   ///        - if FALSE: add event as normal event(add to event name list and event list)
569   /// \~english @par Classification
570   ///           public
571   /// \~english @par Type
572   ///           none
573   /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,BOOL,BOOL,std::string)
574   ///////////////////////////////////////////////////////////////////////////////////////////
575   EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pState, UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
576                          std::string f_strEventName = "", BOOL f_eIsDeferredEventType = FALSE);
577
578   ///////////////////////////////////////////////////////////////////////////////////////////
579   /// \ingroup CFrameworkunifiedHSM
580   /// \~english @par Brief
581   ///             This sets the givens state as root state in the state machine
582   /// \~english @param f_pRootState
583   ///      CFrameworkunifiedState* - Root state
584   /// \~english @retval eFrameworkunifiedStatusOK           succ
585   /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
586   /// \~english @par Prerequisite
587   ///            - Self instance of CFrameworkunifiedHSM created.
588   /// \~english @par Change of internal state
589   ///            none
590   /// \~english @par Conditions of processing failure
591   ///       - Input parameter f_pRootState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
592   ///       - Input parameter f_pRootState does not instance. [eFrameworkunifiedStatusNullPointer]
593   /// \~english @par Detail
594   ///       set state(f_pRootState, which is designated as route state) to HSM state machine
595   ///       set route state pointer(f_pRootState,which is set as parameter value)as pointer of
596   ///       active state for member
597   ///       parameter and routestate
598   /// \~english @par Classification
599   ///           public
600   /// \~english @par Type
601   ///           none
602   /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,BOOL,BOOL,std::string)
603   ///////////////////////////////////////////////////////////////////////////////////////////
604   ///////////////////////////////////////////////////////////////////////////////////////////
605   /// FrameworkunifiedConnect
606   /// This sets the givens state as root state in the state machine
607   ///
608   /// \param [in] f_pRootState
609   ///     CFrameworkunifiedState* - Root state
610   ///
611   /// \return EFrameworkunifiedStatus
612   ///         EFrameworkunifiedStatus - Returns status of operation
613   ///
614   EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pRootState);
615
616   ///////////////////////////////////////////////////////////////////////////////////////////
617   /// \ingroup CFrameworkunifiedHSM
618   /// \~english @par Brief
619   ///            Set Composite state as HSM state OrthogonalState.
620   /// \~english @param f_pOrthogonalState
621   ///     CFrameworkunifiedOrthogonalState* - Orthogonal state pointer
622   /// \~english @param f_pOrthogonalRegion
623   ///      CFrameworkunifiedCompositeState* - Composite state pointer
624   /// \~english @retval eFrameworkunifiedStatusOK           succ
625   /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer(process failed)
626   /// \~english @par Prerequisite
627   ///            - Self instance of CFrameworkunifiedHSM created.
628   /// \~english @par Change of internal state
629   ///            none
630   /// \~english @par Conditions of processing failure
631   ///       - Input parameter f_pOrthogonalState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
632   ///       - Input parameter f_pOrthogonalRegion pointer is NULL. [eFrameworkunifiedStatusNullPointer]
633   ///       - Input parameter f_pOrthogonalState does not instance. [eFrameworkunifiedStatusNullPointer]
634   /// \~english @par Detail
635   ///          Set Composite state as HSM state OrthogonalState.
636   /// \~english @par Classification
637   ///           public
638   /// \~english @par Type
639   ///           none
640   /// \~english @see 
641   ///////////////////////////////////////////////////////////////////////////////////////////
642   ///////////////////////////////////////////////////////////////////////////////////////////
643   /// FrameworkunifiedConnect
644   /// This sets the givens state as root state in the state machine
645   ///
646   /// \param [in] f_pOrthogonalState
647   ///     CFrameworkunifiedOrthogonalState* - Orthogonal state
648   ///
649   /// \param [in] f_pOrthogonalRegion
650   ///     CFrameworkunifiedCompositeState* - Orthogonal region
651   ///
652   /// \return EFrameworkunifiedStatus
653   ///         EFrameworkunifiedStatus - Returns status of operation
654   ///
655   EFrameworkunifiedStatus  FrameworkunifiedConnectOrthogonal(CFrameworkunifiedOrthogonalState *f_pOrthogonalState,
656                                    CFrameworkunifiedCompositeState *f_pOrthogonalRegion);
657
658   ///////////////////////////////////////////////////////////////////////////////////////////
659   /// \ingroup CFrameworkunifiedHSM
660   /// \~english @par Brief
661   ///          This interface returns the application handle
662   /// \~english @param none
663   /// \~english @retval HANDLE  application handle
664   /// \~english @par Prerequisite
665   ///            - Self instance of CFrameworkunifiedHSM created.
666   /// \~english @par Change of internal state
667   ///            none
668   /// \~english @par Conditions of processing failure
669   ///            none
670   /// \~english @par Detail
671   ///           none
672   /// \~english @par Classification
673   ///           public
674   /// \~english @par Type
675   ///           none
676   /// \~english @see none
677   ///////////////////////////////////////////////////////////////////////////////////////////
678   HANDLE FrameworkunifiedGetAppHandle();
679
680   ///////////////////////////////////////////////////////////////////////////////////////////
681   /// \ingroup CFrameworkunifiedHSM
682   /// \~english @par Brief
683   ///          Output statemachine information into XML file.
684   /// \~english @param none
685   /// \~english @retval EFrameworkunifiedStatus   eFrameworkunifiedStatusOK succ
686   /// \~english @par Prerequisite
687   ///            - Self instance of CFrameworkunifiedHSM created.
688   /// \~english @par Change of internal state
689   ///            none
690   /// \~english @par Conditions of processing failure
691   ///            none
692   /// \~english @par Detail
693   ///            none
694   /// \~english @par Classification
695   ///           public
696   /// \~english @par Type
697   ///           none
698   /// \~english @see none
699   ///////////////////////////////////////////////////////////////////////////////////////////
700   EFrameworkunifiedStatus FrameworkunifiedPrintXML();
701
702   ///////////////////////////////////////////////////////////////////////////////////////////
703   /// \ingroup CFrameworkunifiedHSM
704   /// \~english @par Brief
705   ///          Push the event in the post event list.
706   /// \~english @param f_pEventData
707   ///            CEventDataPtr - pointer of event data
708   /// \~english @retval EFrameworkunifiedStatus   eFrameworkunifiedStatusOK succ
709   ///                                eFrameworkunifiedStatusNullPointer   NULL pointer
710   /// \~english @par Prerequisite
711   ///            - Self instance of CFrameworkunifiedHSM created.
712   /// \~english @par Change of internal state
713   ///            none
714   /// \~english @par Conditions of processing failure
715   ///            - If input parameter f_pEventData is NULL. [eFrameworkunifiedStatusNullPointer]
716   ///            - If member variable m_pActiveState is NULL. [eFrameworkunifiedStatusNullPointer]
717   ///            - If member variable m_pPostEventList is NULL. [eFrameworkunifiedStatusNullPointer]
718   /// \~english @par Detail
719   ///           none
720   /// \~english @par Classification
721   ///           public
722   /// \~english @par Type
723   ///           none
724   /// \~english @see none
725   ///////////////////////////////////////////////////////////////////////////////////////////
726   EFrameworkunifiedStatus FrameworkunifiedQueueEvent(CEventDataPtr f_pEventData);
727
728   ///////////////////////////////////////////////////////////////////////////////////////////
729   /// \ingroup CFrameworkunifiedHSM
730   /// \~english @par Brief
731   ///          Remove the all events of eventId f_uiEventId from event queue of statemachine.
732   /// \~english @param f_pEventData
733   ///            const UI_32 - event id
734   /// \~english @retval EFrameworkunifiedStatus   eFrameworkunifiedStatusOK succ
735   ///                                eFrameworkunifiedStatusInvldID       Not found event id
736   ///                                eFrameworkunifiedStatusNullPointer   NULL pointer
737   /// \~english @par Prerequisite
738   ///            - Self instance of CFrameworkunifiedHSM created.
739   /// \~english @par Change of internal state
740   ///            none
741   /// \~english @par Conditions of processing failure
742   ///            - If not find event id. [eFrameworkunifiedStatusInvldID]
743   ///            - If member variable m_pPostEventList is NULL. [eFrameworkunifiedStatusNullPointer]
744   /// \~english @par Detail
745   ///           none
746   /// \~english @par Classification
747   ///           public
748   /// \~english @par Type
749   ///           none
750   /// \~english @see none
751   ///////////////////////////////////////////////////////////////////////////////////////////
752   EFrameworkunifiedStatus RemoveEventFromPostedEventQueue(const UI_32 f_uiEventId);
753
754   UI_32 m_uiCurrentEvent;
755
756   /// Application handle
757   HANDLE m_pHApp;
758
759  private:
760   ///////////////////////////////////////////////////////////////////////////////////////////
761   /// ProcessEventQueue
762   /// Gets the event from StateMachine events list and post it.
763   ///
764   /// \return EFrameworkunifiedStatus
765   ///     EFrameworkunifiedStatus - Returns status of operation
766   ///////////////////////////////////////////////////////////////////////////////////////////
767   EFrameworkunifiedStatus ProcessEventQueue();
768
769   ///////////////////////////////////////////////////////////////////////////////////////////
770   /// ProcessEvent
771   /// Processes the event posted to the statemachine
772   ///
773   /// \param [in] f_pEventData
774   ///         CEventDataPtr - Event data
775   ///
776   /// \return EFrameworkunifiedStatus
777   ///     EFrameworkunifiedStatus - Returns status of operation
778   ///////////////////////////////////////////////////////////////////////////////////////////
779   EFrameworkunifiedStatus ProcessEvent(CEventDataPtr f_pEventData);
780
781   /// pointer to the active state object
782   CFrameworkunifiedState *m_pActiveState;
783
784   /// pointer to the root state object
785   CFrameworkunifiedState *m_pRootState;
786
787   std::vector<CEventDataPtr> *m_pPostEventList;
788
789   BOOL m_bIsTransitioning;
790 };
791
792 #endif  // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__  // NOLINT  (build/header_guard)
793 /** @}*/
794 /** @}*/
795 /** @}*/
796 /** @}*/
797 /** @}*/
798 //@}