natplugins/natpnatfwsdpprovider/tsrc/testconsole/inc/nsptestconsolestatemach.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef NSPTESTCONSOLESTATEMACH_H
       
    19 #define NSPTESTCONSOLESTATEMACH_H
       
    20 
       
    21 #include <e32keys.h>
       
    22 #include "nsptestconsoleactions.h"
       
    23 
       
    24 typedef TInt TNSPTestConsoleStateIndex;
       
    25 const TNSPTestConsoleStateIndex KStateMain = 0;
       
    26 const TNSPTestConsoleStateIndex KStateSettings = 1;
       
    27 const TNSPTestConsoleStateIndex KStateDomainSettings = 2;
       
    28 const TNSPTestConsoleStateIndex KStateRelease = 3;
       
    29 const TNSPTestConsoleStateIndex KStateRunning = 4;
       
    30 const TNSPTestConsoleStateIndex KStateResults = 5;
       
    31 const TNSPTestConsoleStateIndex KStateIce = 6;
       
    32 
       
    33 class TNSPStateEvent
       
    34 	{
       
    35 public: // New methods
       
    36 	
       
    37 	inline TNSPStateEvent(
       
    38 				MNSPTestConsoleActions& aActions,
       
    39 				TKeyCode aKeyCode,
       
    40 				TInt aStatus = KErrNone,
       
    41 				TNSPTestConsoleStateIndex aNextState = KStateMain )
       
    42 		: iActions( aActions ),
       
    43 		  iKeyCode( aKeyCode ),
       
    44 		  iStatus( aStatus ),
       
    45 		  iNextState( aNextState )
       
    46 		{
       
    47 		}
       
    48 	
       
    49 	inline MNSPTestConsoleActions& Actions()
       
    50 		{
       
    51 		return iActions;
       
    52 		}
       
    53 	
       
    54 	inline TKeyCode KeyCode()
       
    55 		{
       
    56 		return iKeyCode;
       
    57 		}
       
    58 	
       
    59 	inline TInt& Status()
       
    60 		{
       
    61 		return iStatus;
       
    62 		}
       
    63 	
       
    64 	inline TNSPTestConsoleStateIndex& NextState()
       
    65 		{
       
    66 		return iNextState;
       
    67 		}
       
    68 	
       
    69 private: // data
       
    70 	MNSPTestConsoleActions& iActions;
       
    71 	TKeyCode iKeyCode;
       
    72 	TInt iStatus;
       
    73 	TNSPTestConsoleStateIndex iNextState;
       
    74 	};
       
    75 
       
    76 class TNSPTestConsoleState
       
    77 	{
       
    78 public:
       
    79 	virtual void EntryL( TNSPStateEvent& aEvent ) = 0;
       
    80 	virtual void ExitL( TNSPStateEvent& aEvent ) = 0;
       
    81 	};
       
    82 
       
    83 /**
       
    84  * Main menu.
       
    85  */
       
    86 class TNPSTestConsoleStateMain : public TNSPTestConsoleState
       
    87 	{
       
    88 	void EntryL( TNSPStateEvent& aEvent );
       
    89 	void ExitL( TNSPStateEvent& aEvent );
       
    90 	};
       
    91 
       
    92 /**
       
    93  * Settings menu.
       
    94  */
       
    95 class TNPSTestConsoleStateSettings : public TNSPTestConsoleState
       
    96 	{
       
    97 	void EntryL( TNSPStateEvent& aEvent );
       
    98 	void ExitL( TNSPStateEvent& aEvent );
       
    99 	};
       
   100 
       
   101 /**
       
   102  * Domain settings menu.
       
   103  */
       
   104 class TNPSTestConsoleStateDomainSettings : public TNSPTestConsoleState
       
   105 	{
       
   106 	void EntryL( TNSPStateEvent& aEvent );
       
   107 	void ExitL( TNSPStateEvent& aEvent );
       
   108 	};
       
   109 
       
   110 /**
       
   111  * Release menu.
       
   112  */
       
   113 class TNPSTestConsoleStateRelease : public TNSPTestConsoleState
       
   114 	{
       
   115 	void EntryL( TNSPStateEvent& aEvent );
       
   116 	void ExitL( TNSPStateEvent& aEvent );
       
   117 	};
       
   118 
       
   119 /**
       
   120  * Run menu.
       
   121  */
       
   122 class TNPSTestConsoleStateRunning : public TNSPTestConsoleState
       
   123 	{
       
   124 	void EntryL( TNSPStateEvent& aEvent );
       
   125 	void ExitL( TNSPStateEvent& aEvent );
       
   126 	};
       
   127 
       
   128 /**
       
   129  * Results menu.
       
   130  */
       
   131 class TNPSTestConsoleStateResults : public TNSPTestConsoleState
       
   132 	{
       
   133 	void EntryL( TNSPStateEvent& aEvent );
       
   134 	void ExitL( TNSPStateEvent& aEvent );
       
   135 	};
       
   136 
       
   137 /**
       
   138  * Results menu.
       
   139  */
       
   140 class TNPSTestConsoleStateIce : public TNSPTestConsoleState
       
   141 	{
       
   142 	void EntryL( TNSPStateEvent& aEvent );
       
   143 	void ExitL( TNSPStateEvent& aEvent );
       
   144 	};
       
   145 
       
   146 
       
   147 /**
       
   148  * State machine.
       
   149  */
       
   150 class CNSPTestConsoleStateMachine : public CBase
       
   151 	{
       
   152 public:
       
   153 	static CNSPTestConsoleStateMachine* NewL();
       
   154 	~CNSPTestConsoleStateMachine();
       
   155 	
       
   156 	TInt Start( TNSPStateEvent& aEvent );
       
   157 	void ProcessL( TNSPStateEvent& aEvent );
       
   158 
       
   159 private:
       
   160 	CNSPTestConsoleStateMachine();
       
   161 	void ConstructL();
       
   162 
       
   163 private: // data
       
   164 	TNSPTestConsoleState* iCurrentState; // not own
       
   165 	RPointerArray<TNSPTestConsoleState> iStateArray; // own
       
   166 	};
       
   167 
       
   168 #endif // NSPTESTCONSOLESTATEMACH_H