|
1 /* |
|
2 * Copyright (c) 2007 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: State machine description. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef NSPSTATEMACHINE_H |
|
19 #define NSPSTATEMACHINE_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include "nsppluginreturndef.h" |
|
23 #include "nsputdefinitions.h" |
|
24 |
|
25 class TNSPStateMachineEvent; |
|
26 class CNSPStateBase; |
|
27 |
|
28 /** |
|
29 * State machine that contains all states, and pointer to current state. |
|
30 * |
|
31 * Machine which used to implement state design pattern. Machine contains |
|
32 * all states, and current state. When processing completes successfully, |
|
33 * state machine observer is used to notify success. Otherwise leave expected. |
|
34 * |
|
35 * @lib natfwsdpprovider.dll |
|
36 * @since S60 3.2 |
|
37 */ |
|
38 class CNSPStateMachine : public CBase |
|
39 { |
|
40 public: // Constructors and destructor |
|
41 |
|
42 /** |
|
43 * A two-phase constructor. |
|
44 */ |
|
45 static CNSPStateMachine* NewL(); |
|
46 |
|
47 /** |
|
48 * A two-phase constructor. |
|
49 */ |
|
50 static CNSPStateMachine* NewLC(); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 virtual ~CNSPStateMachine(); |
|
56 |
|
57 |
|
58 private: // Constructors and destructor |
|
59 |
|
60 CNSPStateMachine(); |
|
61 |
|
62 void ConstructL(); |
|
63 |
|
64 void InitializeStateArrayL(); |
|
65 |
|
66 |
|
67 public: // New functions |
|
68 |
|
69 /** |
|
70 * Current state is applied with this method. |
|
71 * |
|
72 * @since S60 3.2 |
|
73 * @param aEvent State machine event |
|
74 */ |
|
75 void ProcessL( TNSPStateMachineEvent& aEvent ); |
|
76 |
|
77 |
|
78 private: // New functions |
|
79 |
|
80 void IsAcceptableStateTransitionL( TInt aStateIndex ) const; |
|
81 |
|
82 TBool IsAcceptableStateTransition( TInt aStateIndex ) const; |
|
83 |
|
84 |
|
85 private: // data |
|
86 |
|
87 /** |
|
88 * Array containing each state object. |
|
89 * Own. |
|
90 */ |
|
91 RPointerArray<CNSPStateBase> iStateArray; |
|
92 |
|
93 /** |
|
94 * Pointer to a object which is the 'CURRENT' state |
|
95 * Not own. |
|
96 */ |
|
97 CNSPStateBase* iCurrentState; |
|
98 |
|
99 /** |
|
100 * Definitions for unit testing. |
|
101 */ |
|
102 NSP_UT_DEFINITIONS |
|
103 |
|
104 }; |
|
105 |
|
106 #endif // NSPSTATEMACHINE_H |
|
107 |
|
108 // end of file |