natplugins/natpnatfwsdpprovider/inc/nspstatebase.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     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:  Base class description for all session states.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef NSPSTATEBASE_H
       
    19 #define NSPSTATEBASE_H
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 typedef TInt TNSPStateIndex;
       
    24 const TNSPStateIndex KStateIndexInitializing = 0;
       
    25 const TNSPStateIndex KStateIndexIdle = 1;
       
    26 const TNSPStateIndex KStateIndexLocalCand = 2;
       
    27 const TNSPStateIndex KStateIndexNegotiating = 3;
       
    28 const TNSPStateIndex KStateIndexResolving = 4;
       
    29 const TNSPStateIndex KStateIndexActivating = 5;
       
    30 const TNSPStateIndex KStateIndexConnected = 6;
       
    31 const TNSPStateIndex KStateIndexDeActivating = 7;
       
    32 
       
    33 class TNSPStateMachineEvent;
       
    34 
       
    35 /**
       
    36  *  Base class for all states.
       
    37  *
       
    38  *  Defines a set of methods, which are used by state machine.
       
    39  *  Each state has own definitions for these methods, and
       
    40  *  therefore different behavior.
       
    41  *
       
    42  *  @lib natfwsdpprovider.dll
       
    43  *  @since S60 3.2
       
    44  */
       
    45 class CNSPStateBase : public CBase
       
    46     {
       
    47 public: // Constructors and destructor
       
    48  
       
    49     /**
       
    50      * Destructor.
       
    51      */
       
    52     virtual ~CNSPStateBase();
       
    53 
       
    54 
       
    55 protected: // Constructors and destructor
       
    56 
       
    57     /**
       
    58      * Constructor.
       
    59      */
       
    60     CNSPStateBase();
       
    61 
       
    62 
       
    63 public: // New functions
       
    64 
       
    65     /**
       
    66      * Called to check if individual state accepts event, i.e.
       
    67      * whether to execute DoApplyL.
       
    68      *
       
    69      * @since       S60 3.2
       
    70      * @param       aEvent          State machine event.
       
    71      * @return      ETrue if transition is consumed, EFalse otherwise.
       
    72      */
       
    73     TBool AcceptL( TNSPStateMachineEvent& aEvent );
       
    74     
       
    75     /**
       
    76      * Called when the state is entered.
       
    77      * 
       
    78      * @since       S60 3.2
       
    79      * @param       aEvent          State machine event.
       
    80      */
       
    81     void StateEntryL( TNSPStateMachineEvent& aEvent );
       
    82     
       
    83     /**
       
    84      * Called when state entry to next state will leave, and return
       
    85      * into 'this' state must be done.
       
    86      *
       
    87      * @since       S60 3.2
       
    88      * @param       aEvent          State machine event.
       
    89      */
       
    90     void Reverse( TNSPStateMachineEvent& aEvent );
       
    91     
       
    92     /**
       
    93      * Current state is applied with this method.
       
    94      * 
       
    95      * @since       S60 3.2
       
    96      * @param       aEvent          State machine event.
       
    97      */
       
    98     void ApplyL( TNSPStateMachineEvent& aEvent );
       
    99     
       
   100     /**
       
   101      * Current state is exited with this method.
       
   102      * 
       
   103      * @since       S60 3.2
       
   104      * @param       aEvent          State machine event.
       
   105      */
       
   106     void ExitL( TNSPStateMachineEvent& aEvent );
       
   107 
       
   108 
       
   109 protected:  // New functions
       
   110 
       
   111     /**
       
   112      * Called to check if individual state accepts event, i.e.
       
   113      * whether to execute DoApplyL.
       
   114      *
       
   115      * @since       S60 3.2
       
   116      * @param       aEvent          State machine event.
       
   117      * @return      ETrue if event is accepted, EFalse otherwise.
       
   118      */
       
   119     virtual TBool DoAcceptL( TNSPStateMachineEvent& aEvent ) = 0;
       
   120     
       
   121     /**
       
   122      * Called when the state is entered.
       
   123      *
       
   124      * @since       S60 3.2
       
   125      * @param       aEvent          State machine event.
       
   126      */
       
   127     virtual void DoStateEntryL( TNSPStateMachineEvent& aEvent ) = 0;
       
   128     
       
   129     /**
       
   130      * Called when state entry to next state will leave, and return
       
   131      * into 'this' state must be done. Inverse of DoExitL - method.
       
   132      *
       
   133      * @since       S60 3.2
       
   134      * @param       aEvent          State machine event.
       
   135      */
       
   136     virtual void DoReverse( TNSPStateMachineEvent& aEvent ) = 0;
       
   137     
       
   138     /**
       
   139      * Current state is applied with this method.
       
   140      *
       
   141      * @since       S60 3.2
       
   142      * @param       aEvent          State machine event.
       
   143      */
       
   144     virtual void DoApplyL( TNSPStateMachineEvent& aEvent ) = 0;
       
   145     
       
   146     /**
       
   147      * Current state is exited with this method.
       
   148      *
       
   149      * @since       S60 3.2
       
   150      * @param       aEvent          State machine event.
       
   151      */
       
   152     virtual void DoExitL( TNSPStateMachineEvent& aEvent ) = 0;
       
   153     
       
   154     };
       
   155 
       
   156 #endif // NSPSTATEBASE_H
       
   157 
       
   158 // end of file