summaryrefslogtreecommitdiffstats
path: root/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsm.h
blob: 1a8e1d740b214e0d68bc1509c6a943440f1c53da (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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
/*
 * @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 CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
/// This class implements interfaces for connecting child states to parent states, connecting events
/// to state.
///////////////////////////////////////////////////////////////////////////////
//@{
/**
 * @file frameworkunified_sm_hsm.h
 * @brief \~english This file has the CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
 *        This class implements interfaces for connecting child states to parent states, connecting events to 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_HSM_H__  // NOLINT  (build/header_guard)
#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__

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

#include <native_service/frameworkunified_types.h>
#include <native_service/ns_logger_if.h>
#include <native_service/frameworkunified_sm_eventdata.h>
#include <vector>
#include <exception>
#include <map>
#include <string>

class CFrameworkunifiedEvent;

class CFrameworkunifiedState;

class CFrameworkunifiedCompositeState;

class CFrameworkunifiedReaction;

class CFrameworkunifiedOrthogonalState;

class CEventData;

typedef boost::shared_ptr<CEventData> CEventDataPtr;

///////////////////////////////////////////////////////////////////////////////////////////////////
/// This class implements interfaces for connecting child states to parent states, connecting events
/// to state.
///////////////////////////////////////////////////////////////////////////////////////////////////
class CFrameworkunifiedHSM {
 public :

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///        Destructor for CFrameworkunifiedHSM
  /// \~english @retval none
  /// \~english @par Preconditons
  ///          - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal status
  ///                none
  /// \~english @par Conditions of processing failure
  ///                none
  /// \~english @par Detail
  ///          Release class CFrameworkunifiedHistoryState instance.\n
  ///          Release event in postevent list.\n
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///            none
  /// \~english @see none
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// ~CFrameworkunifiedHSM
  /// Class destructor
  ///
  /// \return none
  virtual ~CFrameworkunifiedHSM();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          Constructor for class CFrameworkunifiedHSM.
  /// \~english @param
  /// \~english @retval none
  /// \~english @par Prerequisite
  ///            none
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            none
  /// \~english @par Detail
  ///       CFrameworkunifiedHSM class is the super class of HSM framework.
  ///       this class produce interface to connected super class state with sub class state and to connect event with
  ///       state
  ///       create the instance of CFrameworkunifiedHSM class\n
  ///       create event list as following and hold the member parameter,others will be initialized as NULL
  ///       - event list which is supported in state
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see ~CFrameworkunifiedHSM
  ///////////////////////////////////////////////////////////////////////////////////////////
  CFrameworkunifiedHSM();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          Constructor for class CFrameworkunifiedHSM.
  /// \~english @param f_pHApp
  ///          PVOID - handle of application
  /// \~english @retval none
  /// \~english @par Prerequisite
  ///            none
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            none
  /// \~english @par Detail
  ///       CFrameworkunifiedHSM class is the super class of HSM framework.
  ///       this class produce interface to connected super class state with sub class state and to connect event with
  ///       state
  ///       create the instance of CFrameworkunifiedHSM class\n
  ///       create event list as following and hold the member parameter,others will be initialized as NULL
  ///       - event list which is supported in state
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see ~CFrameworkunifiedHSM
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// CFrameworkunifiedHSM(PVOID f_pHApp)
  /// Class constructor
  ///
  /// \return none
  CFrameworkunifiedHSM(PVOID f_pHApp);  // NOLINT  (readability/nolint)

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          Returns the active state of the statemachine
  /// \~english @param none
  /// \~english @retval CFrameworkunifiedState* - Returns ActiveState
  /// \~english @retval NULL       - failed
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created and active state exist.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            - active state do not exist. [NULL]
  /// \~english @par Detail
  ///       route state search will be continued until current state become active
  ///       route state search will be continued until Leaf State or orthogonal State is found\n
  ///       if there is no active state.reture NULL\n
  ///       if there is active state,this state will be hold in memeber parameter as return value
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see CFrameworkunifiedState::FrameworkunifiedGetActiveState
  ///////////////////////////////////////////////////////////////////////////////////////////
  CFrameworkunifiedState *FrameworkunifiedGetActiveState();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          This creates the default event data and sends the event to the active HSM state.
  /// \~english @param f_uiEventId
  ///           UI_32 - Event Id
  /// \~english @retval eFrameworkunifiedStatusOK            add succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer   set null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///       - Event data instance create faield. [eFrameworkunifiedStatusNullPointer]
  ///       - The pointer of post event list in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - The pointer of active state in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - The name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       create new event data object and send this event to active HSM state,\n
  ///       then add to event queue of the statemachine
  ///       add to event queque in order to process event using statemachine
  ///       event will be deleted from event queue when process complete
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedPostEvent(CEventDataPtr), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedPostEvent
  /// This creates the default event data and sends the event to the active HSM state.
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event Id
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  EFrameworkunifiedStatus FrameworkunifiedPostEvent(UI_32 f_uiEventId);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedPostEvent
  /// This sends the event to the active HSM state
  ///
  /// \~english @par Brief
  ///          Add event data into event queue of state machine.
  /// \~english @param f_pEventData
  ///           CEventDataPtr - Event data
  /// \~english @retval eFrameworkunifiedStatusOK            add succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer   set null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///       - Input parameter f_pEventData is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - The pointer of post event list in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - The pointer of active state in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - The name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedPostEvent(CEventDataPtr f_pEventData);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///         This is pure virtual function to be implemented by the derived classes. Statemachine
  ///         states and events created and connected in this interface.
  /// \~english @param f_pEventData
  ///           PVOID - Event data
  /// \~english @retval EFrameworkunifiedStatus      Returns status of operation
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  //             none
  /// \~english @par Detail
  ///           none
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see none
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_pEventData = NULL) = 0;

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedStart
  /// This starts the state machine
  ///
  /// \~english @par Brief
  ///         Start the state machine.
  /// \~english @param f_pEventData
  ///           CEventDataPtr - Event data
  /// \~english @retval EFrameworkunifiedStatus      eFrameworkunifiedStatusOK   succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer  set null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  //            - Pointer of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedStart(CEventDataPtr f_pEventData = boost::make_shared<CEventData>(0));

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///         Stop the state machine.
  /// \~english @param f_pEventData
  ///           CEventDataPtr - Event data
  /// \~english @retval EFrameworkunifiedStatus
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  //            - Pointer of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///           Stop the state machine.\n
  ///           Release route state of state machine.\n
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedClose(CEventDataPtr f_pEventData = boost::make_shared<CEventData>(0));

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedPrintAllStates
  /// This prints all states and events associated with every state on console.
  ///
  /// \~english @par Brief
  ///         Output log of all states and events name associated with every state.
  /// \~english @param
  /// \~english @retval EFrameworkunifiedStatus      succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///           - Root state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///           - Self instance of CFrameworkunifiedHSM does not create.  [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       print out log for connected state name and event name\n
  ///       following log will be print put
  ///       - super statemachine state name and self-statemachine state name
  ///       - all the event name on event list
  ///       - all the event on delayed event list
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see 
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedPrintAllStates();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///             This connects the reaction to event and add event to child states then add child state
  ///             to parent state.
  /// \~english @param f_pParentState
  ///      CFrameworkunifiedState* - Parent state pointer
  /// \~english @param f_pChildState
  ///      CFrameworkunifiedState* - Child state pointer
  /// \~english @param f_uiEventId
  ///      UI_32 - eventi id
  /// \~english @param f_pReaction
  ///      CFrameworkunifiedReaction* - Reaction object for attaching to event
  /// \~english @param f_eIsDefaultState
  ///      BOOL - Does has default state.(default: FALSE)
  /// \~english @par
  ///      - TRUE : has default state
  ///      - FALSE: not has default state
  /// \~english @param f_eIsDeferredEventType
  ///      BOOL -  Does has the deferred event(default: FALSE)
  /// \~english @par
  ///      - TRUE : has the deferred event
  ///      - FALSE: not has the deferred event
  /// \~english @param f_strEventName
  ///      std::string - name of event(default:"")
  /// \~english @retval eFrameworkunifiedStatusOK           succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///       - Input parameter f_pParentState pointer is NULL.[eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pChildState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pReaction pointer is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pParentState does not instance. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pChildState does not instance. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       connect process with event and add the event to sub state.
  ///       and do following considering the event delay and event declare(f_eIsDeferredEventType)
  ///        - if TRUE : add the event as delayed event(add to event name list and delayed event list)
  ///        - if FALSE:add normal event and event(add to event name list and event list)
  /// \~english @par
  ///       After adding an event to a child state, associate the child state with the parent state and
  ///       set the HSM state machine for the child state only if the parent state is a compound state.
  ///       The following associations are made depending on whether or not a default state is defined (f_eIsDefaultState).
  ///       - TRUE: Associates a child state as the default state with the parent state.
  ///       - FALSE: Associates a child state with a parent state as a normal state.
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,std::string,BOOL),
  ///           FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,BOOL)
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedConnect
  /// This connects the reaction to event and add event to child states then add child state
  /// to parent state.
  ///
  /// \param [in] f_pParentState
  ///     CFrameworkunifiedState* - Parent state
  ///
  /// \param [in] f_pChildState
  ///     CFrameworkunifiedState* - Child state
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event id
  ///
  /// \param [in] f_pReaction
  ///     CFrameworkunifiedReaction* - Reaction object for attaching to event
  ///
  /// \param [in] f_eIsDefaultState
  ///     BOOL - Defines if the state is default state
  ///
  /// \param [in] f_eIsDeferredEventType
  ///     BOOL - defines if the event is deferred event
  ///
  /// \param [in] f_strEventName
  ///     BOOL - Event name
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
                         UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
                         BOOL f_eIsDefaultState = FALSE,
                         BOOL f_eIsDeferredEventType = FALSE,
                         std::string f_strEventName = "");

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///           This add child state to parent state.
  /// \~english @param f_pParentState
  ///      CFrameworkunifiedState* - Parent state pointer
  /// \~english @param f_pChildState
  ///      CFrameworkunifiedState* - Child state pointer
  /// \~english @param f_eIsDefaultState
  ///      BOOL - Does has default state.(default: FALSE)
  /// \~english @par
  ///      - TRUE : has default state
  ///      - FALSE: not has default state
  /// \~english @retval eFrameworkunifiedStatusOK           succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///       - Input parameter f_pParentState pointer is NULL.[eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pChildState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pParentState does not instance. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pChildState does not instance. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       connect super state with sub state and set HSM state machine to sub state only when super state is compond
  ///       state
  ///       according to the default state define(f_eIsDefaultState),doing the connection below
  ///       - if TRUE: connect sub state as default state with super state
  ///       - if FALSE: connect sub state as normal state with super state
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,std::string,BOOL),
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedConnect
  /// This add child state to parent state.
  ///
  /// \param [in] f_pParentState
  ///     CFrameworkunifiedState* - Parent state
  ///
  /// \param [in] f_pChildState
  ///     CFrameworkunifiedState* - Child state
  ///
  /// \param [in] f_eIsDefaultState
  ///     BOOL - Defines if the state is default state
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
                         BOOL f_eIsDefaultState = FALSE);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedConnect
  /// This connects the reaction to event and add event to states
  ///
  /// \~english @par Brief
  ///             This connects the reaction to event and add event to states.
  /// \~english @param f_pState
  ///      CFrameworkunifiedState* - pointer of state class
  /// \~english @param f_uiEventId
  ///      UI_32 - eventi id
  /// \~english @param f_pReaction
  ///      CFrameworkunifiedReaction* - Reaction object for attaching to event
  /// \~english @param f_eIsDefaultState
  ///      BOOL - Does has default state.(default: FALSE)
  /// \~english @par
  ///      - TRUE : has default state
  ///      - FALSE: not has default state
  /// \~english @param f_eIsDeferredEventType
  ///      BOOL -  Does has the deferred event(default: FALSE)
  /// \~english @par
  ///      - TRUE : has the deferred event
  ///      - FALSE: not has the deferred event
  /// \~english @param f_strEventName
  ///      std::string - name of event(default:"")
  /// \~english @retval eFrameworkunifiedStatusOK           succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///       - Input parameter f_pReaction pointer is NULL.[eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pState pointer does not instance. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       connect process with event and add event to sub state
  ///       following will be added according to whether delayed event or event define exsist
  ///        - if TRUE : add event as delayed event(add to event name list and delayed event list)
  ///        - if FALSE: add event as normal event(add to event name list and event list)
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,BOOL,BOOL,std::string)
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pState, UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
                         std::string f_strEventName = "", BOOL f_eIsDeferredEventType = FALSE);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///             This sets the givens state as root state in the state machine
  /// \~english @param f_pRootState
  ///      CFrameworkunifiedState* - Root state
  /// \~english @retval eFrameworkunifiedStatusOK           succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///       - Input parameter f_pRootState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pRootState does not instance. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       set state(f_pRootState, which is designated as route state) to HSM state machine
  ///       set route state pointer(f_pRootState,which is set as parameter value)as pointer of
  ///       active state for member
  ///       parameter and routestate
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,BOOL,BOOL,std::string)
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedConnect
  /// This sets the givens state as root state in the state machine
  ///
  /// \param [in] f_pRootState
  ///     CFrameworkunifiedState* - Root state
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  EFrameworkunifiedStatus  FrameworkunifiedConnect(CFrameworkunifiedState *f_pRootState);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///            Set Composite state as HSM state OrthogonalState.
  /// \~english @param f_pOrthogonalState
  ///     CFrameworkunifiedOrthogonalState* - Orthogonal state pointer
  /// \~english @param f_pOrthogonalRegion
  ///      CFrameworkunifiedCompositeState* - Composite state pointer
  /// \~english @retval eFrameworkunifiedStatusOK           succ
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer(process failed)
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///       - Input parameter f_pOrthogonalState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pOrthogonalRegion pointer is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Input parameter f_pOrthogonalState does not instance. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///          Set Composite state as HSM state OrthogonalState.
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see 
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedConnect
  /// This sets the givens state as root state in the state machine
  ///
  /// \param [in] f_pOrthogonalState
  ///     CFrameworkunifiedOrthogonalState* - Orthogonal state
  ///
  /// \param [in] f_pOrthogonalRegion
  ///     CFrameworkunifiedCompositeState* - Orthogonal region
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  EFrameworkunifiedStatus  FrameworkunifiedConnectOrthogonal(CFrameworkunifiedOrthogonalState *f_pOrthogonalState,
                                   CFrameworkunifiedCompositeState *f_pOrthogonalRegion);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          This interface returns the application handle
  /// \~english @param none
  /// \~english @retval HANDLE  application handle
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            none
  /// \~english @par Detail
  ///           none
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see none
  ///////////////////////////////////////////////////////////////////////////////////////////
  HANDLE FrameworkunifiedGetAppHandle();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          Output statemachine information into XML file.
  /// \~english @param none
  /// \~english @retval EFrameworkunifiedStatus   eFrameworkunifiedStatusOK succ
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            none
  /// \~english @par Detail
  ///            none
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see none
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedPrintXML();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          Push the event in the post event list.
  /// \~english @param f_pEventData
  ///            CEventDataPtr - pointer of event data
  /// \~english @retval EFrameworkunifiedStatus   eFrameworkunifiedStatusOK succ
  ///                                eFrameworkunifiedStatusNullPointer   NULL pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            - If input parameter f_pEventData is NULL. [eFrameworkunifiedStatusNullPointer]
  ///            - If member variable m_pActiveState is NULL. [eFrameworkunifiedStatusNullPointer]
  ///            - If member variable m_pPostEventList is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///           none
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see none
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedQueueEvent(CEventDataPtr f_pEventData);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedHSM
  /// \~english @par Brief
  ///          Remove the all events of eventId f_uiEventId from event queue of statemachine.
  /// \~english @param f_pEventData
  ///            const UI_32 - event id
  /// \~english @retval EFrameworkunifiedStatus   eFrameworkunifiedStatusOK succ
  ///                                eFrameworkunifiedStatusInvldID       Not found event id
  ///                                eFrameworkunifiedStatusNullPointer   NULL pointer
  /// \~english @par Prerequisite
  ///            - Self instance of CFrameworkunifiedHSM created.
  /// \~english @par Change of internal state
  ///            none
  /// \~english @par Conditions of processing failure
  ///            - If not find event id. [eFrameworkunifiedStatusInvldID]
  ///            - If member variable m_pPostEventList is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///           none
  /// \~english @par Classification
  ///           public
  /// \~english @par Type
  ///           none
  /// \~english @see none
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus RemoveEventFromPostedEventQueue(const UI_32 f_uiEventId);

  UI_32 m_uiCurrentEvent;

  /// Application handle
  HANDLE m_pHApp;

 private:
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// ProcessEventQueue
  /// Gets the event from StateMachine events list and post it.
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus ProcessEventQueue();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// ProcessEvent
  /// Processes the event posted to the statemachine
  ///
  /// \param [in] f_pEventData
  ///         CEventDataPtr - Event data
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus ProcessEvent(CEventDataPtr f_pEventData);

  /// pointer to the active state object
  CFrameworkunifiedState *m_pActiveState;

  /// pointer to the root state object
  CFrameworkunifiedState *m_pRootState;

  std::vector<CEventDataPtr> *m_pPostEventList;

  BOOL m_bIsTransitioning;
};

#endif  // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__  // NOLINT  (build/header_guard)
/** @}*/
/** @}*/
/** @}*/
/** @}*/
/** @}*/
//@}