summaryrefslogtreecommitdiffstats
path: root/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_state.h
blob: 438e2e5a2a42934f901e92293eb7675e151bc21c (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
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
/*
 * @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 CFrameworkunifiedState class definitions. CFrameworkunifiedState is base class for all types of
/// state classes.This class implements the basic functionality required for HSM state.
/// It provides the standard interfaces for entering, exiting and reacting in a state.
///
///////////////////////////////////////////////////////////////////////////////
//@{
/**
 * @file frameworkunified_sm_state.h
 * @brief \~english This file has the CFrameworkunifiedState class definitions. CFrameworkunifiedState is base class for all types of
 *        state classes.This class implements the basic functionality required for HSM state.
 *        It provides the standard interfaces for entering, exiting and reacting in a 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_STATE_H__  // NOLINT  (build/header_guard)
#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_STATE_H__

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

#include <native_service/frameworkunified_sm_reaction.h>
#include <string>
#include <map>
#include <exception>
#include <vector>

class CFrameworkunifiedReaction;
class CFrameworkunifiedHSM;

/// defines the map of event reactions
typedef std::map<UI_32, CFrameworkunifiedReaction *> EventReactionList;

typedef std::vector<UI_32>  DeferredEventList;

/// defines the map of event names
typedef std::map<UI_32, std::string>   EventNameList;

/// defines the iterator for event reaction map
typedef std::map<UI_32, CFrameworkunifiedReaction *>::iterator EventReactionIterator;;

typedef std::vector<CEventDataPtr>  EventInfoList;

///////////////////////////////////////////////////////////////////////////////////////////////////
/// This class implements the basic functionality required for HSM state. It provides the standard
/// interfaces for entering, exiting and reacting in a state.
///////////////////////////////////////////////////////////////////////////////////////////////////
class CFrameworkunifiedState {
 public :
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        CFrameworkunifiedState constructor
  /// \~english @param [in] f_pName
  ///        std::string   - Name of the state
  /// \~english @retval None
  /// \~english @par Prerequisite
  ///       - None
  /// \~english @par Change of internal state
  ///       - None
  /// \~english @par Conditions of processing failure
  ///       - None
  /// \~english @par Detail
  ///       This clase is a base class of state machine. \n
  ///       It creates object of CFrameworkunifiedState class, and initializes the member variable with state name specified by
  ///       argument(f_pName). \n
  ///       It creates the following event lists, and saves them as member variables. About the other member variables,
  ///       it initialzes them with NULL. \n
  ///       If error occurs, output the error log. \n
  ///       - list of events associated with the state(used for managing state of eace event)
  ///       - list of deferred events associated with the state(used for managing state of deferred event)
  ///       - list of deferred events posted in the state(used for posting list of deferred events)
  ///       - list of event names(used for managing event names)
  /// \~english @par Classification
  ///          public
  /// \~english @par Type
  ///       sync only
  /// \~english @see ~CFrameworkunifiedState
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// CFrameworkunifiedState
  /// Parameterized constructor
  /// \param [in] f_pName
  ///     string - Name of the state
  ///
  /// \return none
  CFrameworkunifiedState(std::string f_pName);  // NOLINT  (readability/nolint)

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        CFrameworkunifiedState destructor
  /// \~english @param None
  /// \~english @retval None
  /// \~english @par Prerequisite
  ///       - Calls constructor to successfully create object.
  /// \~english @par Change of internal state
  ///       - None
  /// \~english @par Conditions of processing failure
  ///       - None
  /// \~english @par Detail
  ///       This class destroys object of CFrameworkunifiedState class.\n
  ///       It destroys the following event list. If error occurs, output the error log.
  ///       - list of events associated with the state
  ///       - list of deferred events associated with the state
  ///       - list of deferred events posted in the state
  ///       - list of event names
  /// \~english @par Classification
  ///          public
  /// \~english @par Type
  ///       sync only
  /// \~english @see CFrameworkunifiedState
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// ~CFrameworkunifiedState
  /// Class destructor
  ///
  /// \return none
  virtual ~CFrameworkunifiedState();

  /////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        add event information
  /// \~english @param [in] f_uiEventId
  ///        UI_32 f_uiEventId  -  event ID
  /// \~english @param [in] f_pReaction
  ///        CFrameworkunifiedReaction *f_pReaction  -  event reaction
  /// \~english @param [in] f_strEventName
  ///        std::string f_strEventName  -  event name
  /// \~english @retval eFrameworkunifiedStatusOK   add event success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  exception occur when add event
  /// \~english @par Prerequisite
  ///        None
  /// \~english @par Change of internal state
  ///        None
  /// \~english @par Conditions of processing failure
  ///        given param is NULL
  /// \~english @par Detail
  ///        add event information to event list, failed if given param is NULL
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see
  ///
  /////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedAddEvent
  /// Associates the event id with the reaction in the state. When the event is posted to the
  /// state the associated reaction is executed. This also adds the event name to the map
  /// which is used for debugging.
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event id of the event to be added in the state
  ///
  /// \param [in] f_pReaction
  ///     CFrameworkunifiedReaction* - Reaction to be associated with the with event id in the state
  ///
  /// \param [in] f_strEventName
  ///     string - Name of the event (used for debugging purpose only)
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedAddEvent(UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName = "");

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        This function processes the event.
  /// \~english @param [in] f_pEventData
  ///      CEventDataPtr - Pointer to event data class
  /// \~english @retval CFrameworkunifiedState*  Pointer to current CFrameworkunifiedState object after processing event
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  ///        - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///        - Failed to call constructor to create object. [this(current CFrameworkunifiedState object]
  ///        - Pointer to event data class is NULL. [NULL]
  /// \~english @par Detail
  ///        This function processes the event. If the reaction for event is available in the current
  ///        state within eventlist and deferred eventlist then it is consumed in the current state
  ///        otherwise forwarded to the parent state. Event forwarding is done recursively till either
  ///        event is consumed or the root state has encountered. This also process the events posted
  ///        in the reactions recursively till all posted events are cleared.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CEventData, FrameworkunifiedIsReactionAvailable
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedOnEvent
  /// This function processes the event. If the reaction for event is available in the current
  /// state within eventlist and deferred eventlist then it is consumed in the current state
  /// otherwise forwarded to the parent state. Event forwarding is done recursively till either
  /// event is consumed or the root state has encountered. This also process the events posted
  /// in the reactions recursively till all posted events are cleared.
  ///
  /// \param [in] f_pEventData
  ///     CEventDataPtr - Event data
  ///
  ///
  /// \return state
  ///         CFrameworkunifiedState* - Returns current state after the event is processed
  ///
  virtual CFrameworkunifiedState *FrameworkunifiedOnEvent(CEventDataPtr f_pEventData);

  /////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        add deferred event information
  /// \~english @param [in] f_uiEventId
  ///        UI_32 f_uiEventId  -  event ID
  /// \~english @param [in] f_strEventName
  ///        std::string f_strEventName  -  event name
  /// \~english @retval eFrameworkunifiedStatusOK   add deferred event success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  exception occur when add deferred event
  /// \~english @par Prerequisite
  ///        None
  /// \~english @par Change of internal state
  ///        None
  /// \~english @par Conditions of processing failure
  ///        given param is NULL
  /// \~english @par Detail
  ///        add deferred event information to event list , failed if given param is NULL
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see
  ///
  /////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedAddDeferredEvent
  /// Associates the deferred event id with the reaction in the state. When the event is posted
  /// to the state the event is deferred and stored in the state. In case of implicit recall
  /// of the deferred events, events are processed before exiting the state. The deferred
  /// events can also be recalled explicitly in the state  This also adds the event name
  /// to the map which is used for debugging.
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event id of the event to be added in the state
  ///
  /// \param [in] f_strEventName
  ///     string - Name of the event (used for debugging purpose only)
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedAddDeferredEvent(UI_32 f_uiEventId, std::string f_strEventName = "");

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        This function creates new eventdata object and add it to event queue of the state machine.
  /// \~english @param [in] f_uiEventId
  ///        UI_32 f_uiEventId  -  event ID
  /// \~english @retval eFrameworkunifiedStatusOK   post event success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  exception occur when post event
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  ///        - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///       - State machine of application is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Failed to create object of eventdata. [eFrameworkunifiedStatusNullPointer]
  ///       - Pointer to event list in which to add eventdata in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Pointer to active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       This function creates new eventdata object and add it to event queue of the state machine.\n
  ///       The events are posted in the reaction which are executed in the state.
  ///       The event queue is processed once the execution of the reaction is completed.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see FrameworkunifiedPostEvent(CEventDataPtr), CEventData, CFrameworkunifiedHSM::FrameworkunifiedQueueEvent, CFrameworkunifiedHSM::ProcessEvent
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedPostEvent
  /// This function creates new eventdata object and add the to event queue of the state.
  /// The events are posted in the reaction which are executed in the state.
  /// The event queue is processed once the execution of the reaction is completed.
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event Id
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  EFrameworkunifiedStatus FrameworkunifiedPostEvent(UI_32 f_uiEventId);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        This function adds event data to event queue of the state machine.
  /// \~english @param [in] f_pEventData
  ///      CEventDataPtr - Pointer to event data class
  /// \~english @retval eFrameworkunifiedStatusOK   post event success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  exception occur when post event
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  ///        - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///      - State machine of application is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Pointer to event data class specified by argument(f_pEventData) is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Pointer to event list in which to add eventdata in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Pointer to active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  ///       - Name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///        This function adds event data to event queue of the state machine. The events are posted in the reaction
  ///        which are executed in the state. The event queue is processed once the execution of the
  ///        reaction is completed.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CEventData, FrameworkunifiedIsReactionAvailable, CFrameworkunifiedHSM::FrameworkunifiedQueueEvent, CFrameworkunifiedHSM::ProcessEvent
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedPostEvent
  /// This function adds the event queue of the state. The events are posted in the reaction
  /// which are executed in the state. The event queue is processed once the execution of the
  /// reaction is completed.
  ///
  /// \param [in] f_pEventData
  ///     CEventDataPtr - Event data
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  EFrameworkunifiedStatus FrameworkunifiedPostEvent(CEventDataPtr f_pEventData);

  /////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        delete event from deferred event list
  /// \~english @param [in] f_uiEventId
  ///        UI_32 f_uiEventId  -  event ID
  /// \~english @retval eFrameworkunifiedStatusOK   delete deferred event success
  /// \~english @retval eFrameworkunifiedStatusInvldID   invalid event ID
  /// \~english @retval eFrameworkunifiedStatusNullPointer  exception occur when delete deferred event
  /// \~english @par Prerequisite
  ///        None
  /// \~english @par Change of internal state
  ///        None
  /// \~english @par Conditions of processing failure
  ///        None
  /// \~english @par Detail
  ///        delete event from deferred event list by event ID
  ///        failed if event id is not exist. exception occur if given param is NULL
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see
  ///
  /////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedRemoveEventFromDeferredEventList
  /// This function removes the event from the posted deferred queue list of the state.
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event id
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if event removed
  ///            eFrameworkunifiedStatusInvldID if event not found in list
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus FrameworkunifiedRemoveEventFromDeferredEventList(UI_32 f_uiEventId);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        This function indicates if the state has sub states.
  /// \~english @param None
  /// \~english @retval BOOL  if the state has sub states
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///        - None
  /// \~english @par Detail
  ///        This function indicates if the state has sub states. It returns TRUE only in the CompositeState
  ///        where this function is overridden
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CFrameworkunifiedCompositeState::FrameworkunifiedHasSubStates
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedHasSubStates
  /// This indicates if the state has sub states. It returns TRUE only in the CompositeState
  /// where this function is overridden
  ///
  /// \return TRUE/FASLE
  ///     BOOL - returns TRUE if it has sub states otherwise returns false.
  virtual BOOL FrameworkunifiedHasSubStates();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        This function indicates if the state has sub states.
  /// \~english @param None
  /// \~english @retval BOOL  if the state has sub states
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///        - None
  /// \~english @par Detail
  ///        This function indicates if the state has sub states. It returns TRUE only in the OrthogonalState
  ///        where this function is overridden
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CFrameworkunifiedOrthogonalState
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedHasOrthogoanlRegions
  /// This indicates if the state has sub states. It returns TRUE only in the OrthogonalState
  /// where this function is overridden
  ///
  /// \return TRUE/FASLE
  ///     BOOL - returns TRUE if it has sub states otherwise returns false.
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual BOOL FrameworkunifiedHasOrthogoanlRegions();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        This logs the state name and event name associated with the state
  /// \~english @param None
  /// \~english @retval eFrameworkunifiedStatusOK  success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  null pointer exception
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///        - Failed to call constructor to create object. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       This logs the state name and event name associated with the state. \n
  ///       It outputs the following logs:
  ///       - state name of parent state machine and self state machine
  ///       - all event names in event list
  ///       - all event names in deferred event list
  ///       CFrameworkunifiedCompositeState and CFrameworkunifiedOrthogonalState class overrides this function
  ///       and use it.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedPrintStates
  /// This logs the state name and events associated with the state
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual  EFrameworkunifiedStatus FrameworkunifiedPrintStates();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        Initialize state.
  /// \~english @param [in] f_pEventData
  ///      CEventDataPtr - Pointer to event data class
  /// \~english @retval CFrameworkunifiedState*  Pointer to current CFrameworkunifiedState object after processing event
  /// \~english @retval NULL        error occurs in internal process
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  ///        - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///        - Failed to call function(FrameworkunifiedOnEntry) recursively. [NULL]
  /// \~english @par Detail
  ///        This function is called recursively till the leaf state is reached. This internally
  ///        calls the Entry function of the current state.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CEventData, FrameworkunifiedOnEntry, FrameworkunifiedOnHSMStop
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedOnHSMStart
  /// This function is called recursively till the leaf state is reached. This internally
  /// calls the Entry function of the current state.
  ///
  /// \param [in] f_pEventData
  ///     CEventDataPtr - Event data
  ///
  /// \return CurrentState
  ///     CFrameworkunifiedState* - Returns current state after operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual CFrameworkunifiedState *FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        Clearup state.
  /// \~english @param [in] f_pEventData
  ///      CEventDataPtr - Pointer to event data class
  /// \~english @retval CFrameworkunifiedState*  Pointer to current CFrameworkunifiedState object after processing event
  /// \~english @retval NULL        error occurs in internal process
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  ///        - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///       - Failed to call constructor to create object. [NULL]
  ///       - Pointer to list of deferred events posted in the state is NULL. [NULL]
  ///       - Pointer to event data getted from list of deferred events posted in the state is NULL. [NULL]
  ///       - Event name of event data getted from list of deferred events posted in the state is NULL. [NULL]
  /// \~english @par Detail
  ///       This function is called recursively till the required parent state is reached. This
  ///       internally calls the Exit function of the current state.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CEventData, FrameworkunifiedOnExit, FrameworkunifiedOnHSMStart
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedOnHSMStop
  /// This function is called recursively till the required parent state is reached. This
  /// internally calls the Exit function of the current state.
  ///
  /// \param [in] f_pEventData
  ///     CECEventDataPtr Event data
  /// \return CurrentState
  ///     CFrameworkunifiedState* - Returns current state after operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual CFrameworkunifiedState *FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        Check the availability of event.
  /// \~english @param [in] f_uiEventId
  ///       UI_32  -  event ID
  /// \~english @retval TRUE  reaction is available for this event
  /// \~english @retval FALSE reaction is not available for this event
  /// \~english @par Prerequisite
  ///       - Calls constructor to successfully create object.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///       - None
  /// \~english @par Detail
  ///       If the event specified by argument(f_uiEventId) is in event list,
  ///       the reaction is available for this event, return TRUE.
  ///       If the event specified by argument(f_uiEventId) is in deferred event list
  ///       but not in event list, the reaction is available for this event, return TRUE.
  ///       Otherwise, the event specified by argument(f_uiEventId) isn't available, return FALSE.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see FrameworkunifiedPostEvent
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedIsReactionAvailable
  ///
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event identifier
  ///
  /// \return TRUE/FASLE
  ///     BOOL - returns TRUE if it reaction is available for this event
  virtual BOOL FrameworkunifiedIsReactionAvailable(UI_32 f_uiEventId);

  /////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Summary
  ///       pure virtual fuction
  /// \~english @param None
  /// \~english @retval CFrameworkunifiedState* depend on implement class
  /// \~english @par Preconditions
  ///       - None.
  /// \~english @par Change of the internal state
  ///       - None
  /// \~english @par Causes of failures
  ///       None
  /// \~english @par Classification
  ///       Public
  /// \~english @par Type
  ///       sync only
  /// \~english @par Detail
  ///       pure virtual function , implement by child class
  /// \~english @see
  ////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedGetActiveState
  /// This interface returns the Active state of the current composite state. In case of
  /// non-composite state current state is active state
  ///
  /// \return Active state
  ///     CFrameworkunifiedState* - Active state
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState() = 0;

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        This Interface associates the gives statemachine with the current state
  /// \~english @param [in] f_pStatemachine
  ///      CFrameworkunifiedHSM*  - Statemachine associated with the state.
  /// \~english @retval eFrameworkunifiedStatusOK  success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  NULL pointer exception
  /// \~english @par Prerequisite
  ///       - Calls constructor to successfully create object.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///       - Pointer to state machine(CFrameworkunifiedHSM class) specified by argument(f_pStatemachine) is NULL.
  ///       [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       This Interface sets state machine of member variable to state machine specified by argument,
  ///       so it can associate the giving statemachine with current state.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CFrameworkunifiedHSM
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedSetHSM
  /// This Interface associates the gives statemachine with the current state
  ///
  /// \param [in] f_pStatemachine
  ///     CFrameworkunifiedHSM* - Statemachine associated with the state.
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  virtual EFrameworkunifiedStatus FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        Get application handle.
  /// \~english @param None
  /// \~english @retval HANDLE  application handle
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  ///        - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///       - Failed to get application handle. [NULL]
  /// \~english @par Detail
  ///       This interface gets and returns the application handle with following steps:
  ///       - If member variable used for state machine of application is not setted, return NULL.
  ///       - Get application handle from state machine of application.
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CFrameworkunifiedHSM::FrameworkunifiedGetAppHandle
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedGetAppHandle
  /// This interface returns the application handle
  ///
  /// \return HANDLE
  ///         HANDLE - Application Handle
  ///
  virtual HANDLE FrameworkunifiedGetAppHandle();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Brief
  ///        Update the State information in the given stream in the form of XML tags
  /// \~english @param [out] f_strXMLString
  ///      std::ostringstream &  - reference to the XML stream
  /// \~english @retval eFrameworkunifiedStatusOK  success
  /// \~english @retval eFrameworkunifiedStatusNullPointer  NULL pointer exception
  /// \~english @par Prerequisite
  ///        - Calls constructor to successfully create object.
  ///        - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
  /// \~english @par Change of internal state
  ///        - None
  /// \~english @par Conditions of processing failure
  ///       - Failed to call constructor to create object. [eFrameworkunifiedStatusNullPointer]
  /// \~english @par Detail
  ///       Update the following State information in the given stream in the form of XML tags
  ///       - state name
  ///       - all event information in event list(eventID, event name)
  ///       - all event information in deferred event list(eventID, event name)
  /// \~english @par Classification
  ///        Public
  /// \~english @par Type
  ///        sync only
  /// \~english @see CEventData, FrameworkunifiedIsReactionAvailable, CFrameworkunifiedHSM::FrameworkunifiedQueueEvent, CFrameworkunifiedHSM::ProcessEvent
  ///////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedPrintXML
  /// Update the State information in the given stream in the form of XML tags
  ///
  /// \param [in] f_strXMLString
  ///     std::ostringstream & - reference to the XML stream
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  virtual EFrameworkunifiedStatus FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString);

  /////////////////////////////////////////////////////////////////////////////////////
  /// \ingroup CFrameworkunifiedState
  /// \~english @par Summary
  ///       pure virtual fuction
  /// \~english @param None
  /// \~english @retval None
  /// \~english @par Preconditions
  ///       - None.
  /// \~english @par Change of the internal state
  ///       - None
  /// \~english @par Causes of failures
  ///       None
  /// \~english @par Classification
  ///       Public
  /// \~english @par Type
  ///       sync only
  /// \~english @par Detail
  ///       pure virtual function , implement by child class
  /// \~english @see
  ////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// UpdateHistory
  /// This function stores the last active state
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual EFrameworkunifiedStatus UpdateHistory() = 0;

 protected :
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedOnEntry
  /// This is pure virtual function implemented by the derived classes of the application.
  /// state initialization can be performed in this function.
  ///
  /// \param [in] f_pEventData
  ///     CEventDataPtr - Event data
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) = 0;

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedOnExit
  /// This is pure virtual function implemented by the derived classes of the application.
  /// state cleanup can be performed in this function.
  ///
  /// \param [in] f_pEventData
  ///     CEventDataPtr - Event data
  ///
  /// \return EFrameworkunifiedStatus
  ///     EFrameworkunifiedStatus - Returns status of operation
  ///////////////////////////////////////////////////////////////////////////////////////////
  virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData) = 0;

 private:
  ///////////////////////////////////////////////////////////////////////////////////////////
  /// IsEventDeferred
  /// This checks if the given event is marked as deferred in the state.
  ///
  /// \param [in] f_uiEventId
  ///     UI_32 - Event identifier
  ///
  /// \return BOOL
  ///     BOOL - event deferred or not
  ///////////////////////////////////////////////////////////////////////////////////////////
  BOOL IsEventDeferred(UI_32 f_uiEventId);

 public:
  /// state name
  std::string m_strStateName;

  /// Pointer to the parent state
  CFrameworkunifiedState *m_pParentState;

  /// pointer to the default state
  CFrameworkunifiedState *m_pDefaultState;

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

  /// pointer to the map that stores the event name against event id
  EventNameList *m_pEventName;

 protected :
  /// pointer to the map that stores the reaction against event id
  EventReactionList *m_pEventList;

  /// pointer to the map that stores deferred event ids
  DeferredEventList *m_pDeferredEventList;

  /// pointer to the vector that stores the eventinfo of the posted deferred event
  EventInfoList *m_pDeferredPostEventList;

  /// pointer to the application statemachine
  CFrameworkunifiedHSM *m_pStateMachine;
};

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