mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsstatemachine.h
branchRCL_3
changeset 20 4a793f564d72
parent 19 0aa8cc770c8a
child 21 74aa6861c87d
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
     1 /*
       
     2 * Copyright (c) 2006, 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:  This class defines the dps state machine. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DPSSTATEMACHINE_H
       
    20 #define DPSSTATEMACHINE_H
       
    21 
       
    22 #include "dpsconst.h"
       
    23 #include "dpsdefs.h"
       
    24 
       
    25 class CDpsTransaction;
       
    26 class CDpsEngine;
       
    27 class CDpsScriptReceiver;
       
    28 class MDpsState;
       
    29 class TMDpsOperation;
       
    30 class CDpsScriptSender;
       
    31 
       
    32 /**
       
    33 *   This class defines the dps state machine using the state design pattern
       
    34 */
       
    35 NONSHARABLE_CLASS(CDpsStateMachine) : public CBase
       
    36     {
       
    37 	    
       
    38     public:
       
    39         /**
       
    40         *   Two phase constructor
       
    41         *   @param aEngine a pointer to dps engine object
       
    42         *   @return the CDpsOperator instance
       
    43         */
       
    44         static CDpsStateMachine* NewL(CDpsEngine *aEngine);
       
    45         
       
    46         /**
       
    47         *   Destructor
       
    48         */
       
    49         ~CDpsStateMachine();   
       
    50         
       
    51         /**
       
    52         *   Creates the dps transaction. It further calls CreateRequest()
       
    53         *   to create dps device request script.
       
    54         *   @param aParam the dps operation object, passed from UI
       
    55         */
       
    56         void StartTransactionL(TMDpsOperation* aOperation);
       
    57         
       
    58         /**
       
    59         *   Initializes the state machine
       
    60         */
       
    61         void Initialize();
       
    62         
       
    63         /**
       
    64         *   Handles errors
       
    65         */    
       
    66         inline void Error(TInt err);
       
    67                 
       
    68         /**
       
    69         *   Notifies script sent
       
    70         */
       
    71         inline void ScriptSentNotifyL(TBool aReply);
       
    72             
       
    73         /**
       
    74         *   Notifies script received
       
    75         */    
       
    76         inline void ScriptReceivedNotifyL(TBool aReply);
       
    77          
       
    78         /**
       
    79         *   Sets the current state
       
    80         *   @param aState the state to be set
       
    81         */    
       
    82         inline void SetState(MDpsState* aState);
       
    83           
       
    84         /**
       
    85         *   Gets the idle state
       
    86         */    
       
    87         inline MDpsState* IdleState() const; 
       
    88           
       
    89         /**
       
    90         *   @return the sending request state object
       
    91         */    
       
    92         inline MDpsState* SendingReqState() const;
       
    93           
       
    94         /**
       
    95         *   @return the waiting for reply state object
       
    96         */    
       
    97         inline MDpsState* WaitingRepState() const;
       
    98              
       
    99         /**
       
   100         *   @return the sending reply state object
       
   101         */    
       
   102         inline MDpsState* SendingRepState() const;
       
   103           
       
   104         /**
       
   105         *   @return the CDpsScriptReceiver object
       
   106         */    
       
   107         inline CDpsScriptReceiver* ScriptReceiver() const;
       
   108         
       
   109         /**
       
   110         *   @return CDpsScriptSender pointer 
       
   111         */
       
   112         inline CDpsScriptSender* ScriptSender() const;
       
   113           
       
   114         /**
       
   115         *   @return the CDpsTransaction object
       
   116         */    
       
   117         inline CDpsTransaction* Trader() const;
       
   118           
       
   119         /**
       
   120         *   @return the current Dps operation enum 
       
   121         */    
       
   122         inline TDpsOperation Operation() const;
       
   123           
       
   124         /**
       
   125         *   Sets the current Dps operation enum
       
   126         *   @param aOp the Dps operation enum to be set
       
   127         */    
       
   128         inline void SetOperation(TDpsOperation aOp);
       
   129           
       
   130         /**
       
   131         *   @return the Dps operation object
       
   132         */    
       
   133         inline TMDpsOperation* MOperation() const;
       
   134           
       
   135         /**
       
   136         *   @return the Dps event enum
       
   137         */    
       
   138         inline TDpsEvent Event() const;
       
   139           
       
   140         /**
       
   141         *   Sets the current Dps event
       
   142         *   @param aEvent the Dps event to be set
       
   143         */    
       
   144         inline void SetEvent(TDpsEvent aEvent);
       
   145         
       
   146         /**
       
   147         *   @return the current state.
       
   148         */
       
   149         inline MDpsState* CurState() const;
       
   150         
       
   151         /**
       
   152         *   @return the dps engine object.
       
   153         */
       
   154         inline CDpsEngine* DpsEngine() const;
       
   155         
       
   156         /**
       
   157         *
       
   158         */
       
   159         inline TInt CurError() const;
       
   160             
       
   161     private:
       
   162         /**
       
   163         *   Default constructor
       
   164         *   @param aEngine a pointer to dps engine object
       
   165         */
       
   166         CDpsStateMachine(CDpsEngine* aEngine);
       
   167         
       
   168         /**
       
   169         *   Two phase constructor. The functions which called in constructor
       
   170         *   and might leave should be called here
       
   171         */
       
   172         void ConstructL();     
       
   173         
       
   174                                     
       
   175     private:
       
   176         // owned by this class
       
   177         MDpsState* iIdleState;
       
   178         // owned by this class
       
   179         MDpsState* iSendingReqState;
       
   180         // owned by this class
       
   181         MDpsState* iWaitingRepState;
       
   182         // owned by this class
       
   183         MDpsState* iSendingRepState;
       
   184         // pointer to the current state object
       
   185         MDpsState* iCurState;
       
   186         // not owned by this class
       
   187         TMDpsOperation* iMOperation;
       
   188      
       
   189         // not owned by this class  
       
   190         CDpsEngine  *iEngine;
       
   191         // the current dps operation, can be empty
       
   192         TDpsOperation iOperation;
       
   193         // the current dps event, can be empty
       
   194         TDpsEvent iEvent;
       
   195         // the pointer to dps operation object, which takes
       
   196         // care of creating and parsing dps script
       
   197          // owned by this class
       
   198         CDpsTransaction *iTrader;
       
   199         // the pointer to dps script receiving notifier
       
   200         // owned by this class
       
   201         CDpsScriptReceiver* iScriptReceiver;
       
   202         
       
   203         // the pointer to script sender object, owned by this class
       
   204         CDpsScriptSender* iScriptSender;
       
   205         TInt iCurError;
       
   206     };
       
   207 
       
   208 #include "dpsstatemachine.inl"
       
   209 #endif