|
1 /* |
|
2 * Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Finite State Machine class for Charging Context Controller. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CHARGINGCONTEXTFSMBODY_H |
|
21 #define C_CHARGINGCONTEXTFSMBODY_H |
|
22 |
|
23 |
|
24 |
|
25 #include "FiniteStateMachine.h" |
|
26 #include "AccSrvChargingContextController.h" |
|
27 |
|
28 |
|
29 class CAccSrvChargingContextController; |
|
30 |
|
31 /** Constants for states of Charging Context FSM. */ |
|
32 enum TChargerContextState |
|
33 { |
|
34 EChargerContextStateUndefined = 0, |
|
35 EChargerContextStateWaitForCharger, |
|
36 EChargerContextStateCharging, |
|
37 EChargerContextStateMaintainActivity, |
|
38 // Add new constants before this row. |
|
39 // Following constant is not a state. |
|
40 // It just indicates maximum index value. |
|
41 EChargerContextStateMaxValue |
|
42 }; |
|
43 |
|
44 /** |
|
45 * Finite State Machine class for Charging Context Controller. |
|
46 * |
|
47 * @code |
|
48 * ?good_class_usage_example(s) |
|
49 * @endcode |
|
50 * |
|
51 * @lib AccServer.exe |
|
52 * @since S60 5.1 |
|
53 */ |
|
54 NONSHARABLE_CLASS( CChargingContextFSMBody ): public CBase, public MFSMBody |
|
55 { |
|
56 |
|
57 public: |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * @param aChargingContextController Host class object that owns the FSM. |
|
62 */ |
|
63 static CChargingContextFSMBody* NewL( |
|
64 CAccSrvChargingContextController* aChargingContextController ); |
|
65 |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 virtual ~CChargingContextFSMBody(); |
|
71 |
|
72 |
|
73 // from base class MFSMBody |
|
74 |
|
75 |
|
76 /** |
|
77 * From MFSMBody. |
|
78 * Function is called by host object to indicate that FSM can proceed to |
|
79 * initial state and make necessary initialization actions. |
|
80 * |
|
81 * @since S60 5.1 |
|
82 * @param none. |
|
83 * @return void. |
|
84 */ |
|
85 virtual void Start(); |
|
86 |
|
87 /** |
|
88 * From MFSMBody. |
|
89 * Function is called by current state to indicate that FSM has to change |
|
90 * its state. Pervious state has performed necessary exit actions if any. |
|
91 * |
|
92 * @since S60 5.1 |
|
93 * @param aNextState Next state where to transit. |
|
94 * @return TBool True is transition valid. False if nextstate value invalid. |
|
95 */ |
|
96 virtual TBool Transit( TFSMState aNextState ); |
|
97 |
|
98 /** |
|
99 * From MFSMBody. |
|
100 * Get the id of current state. |
|
101 * |
|
102 * @since S60 5.1 |
|
103 * @param none. |
|
104 * @return TFSMState Current state identification. |
|
105 */ |
|
106 virtual TFSMState CurrentStateID(); |
|
107 |
|
108 /** |
|
109 * From MFSMBody. |
|
110 * Function is called whenever an event that might have impact |
|
111 * on the state machine occurs. |
|
112 * |
|
113 * @since S60 5.1 |
|
114 * @param none. |
|
115 * @return none. |
|
116 */ |
|
117 virtual void Input(); |
|
118 |
|
119 /** |
|
120 * From MFSMBody. |
|
121 * Get the pointer of current state object. |
|
122 * |
|
123 * @since S60 5.1 |
|
124 * @param none. |
|
125 * @return MFSMState* Current state's interface pointer. |
|
126 */ |
|
127 virtual MFSMState* CurrentState(); |
|
128 |
|
129 /** |
|
130 * From MFSMBody. |
|
131 * Get the name of current state. |
|
132 * |
|
133 * @since S60 5.1 |
|
134 * @param none. |
|
135 * @return TPtrC Name of the current state. |
|
136 */ |
|
137 virtual TPtrC CurrentStateName(); |
|
138 |
|
139 |
|
140 protected: |
|
141 |
|
142 |
|
143 private: |
|
144 |
|
145 /** |
|
146 * C++ default constructor. |
|
147 */ |
|
148 CChargingContextFSMBody(); |
|
149 |
|
150 /** |
|
151 * By default Symbian OS constructor is private. |
|
152 * @param aChargingContextController Host class object that owns the FSM. |
|
153 */ |
|
154 void ConstructL( |
|
155 CAccSrvChargingContextController* aChargingContextController ); |
|
156 |
|
157 |
|
158 private: // data |
|
159 |
|
160 /** |
|
161 * An array for state object pointers. |
|
162 * Own |
|
163 */ |
|
164 // TFixedArray< > ... |
|
165 MFSMState* iStateArray[ EChargerContextStateMaxValue ]; |
|
166 |
|
167 /** |
|
168 * Identification of the current state. Used to point the |
|
169 * corresponding state object in the above array. |
|
170 * 0 < a valid state id =< EChargerContextStateMaxValue |
|
171 */ |
|
172 TFSMState iCurrentStateId; |
|
173 |
|
174 /** |
|
175 * Host class object that owns the FSM. |
|
176 * Not own. |
|
177 */ |
|
178 CAccSrvChargingContextController* iChargingContextController; |
|
179 |
|
180 }; |
|
181 |
|
182 |
|
183 #endif // C_CHARGINGCONTEXTFSMBODY_H |