kerneltest/f32test/smassstorage/inc/tstate.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __TSTATE_H__
       
    17 #define __TSTATE_H__
       
    18 
       
    19 #include "usbmsshared.h"
       
    20 #include "cpropertywatch.h"
       
    21 
       
    22 class TState
       
    23 {
       
    24 public:
       
    25     TState(int id) : stateId(id) {}
       
    26     virtual ~TState() {}
       
    27     
       
    28     virtual void MoveTo(int aStateId) const = 0;
       
    29     TInt GetStateId() const {return stateId;}
       
    30 
       
    31 private:
       
    32     const TInt stateId;
       
    33 };
       
    34 
       
    35 //////////////////////////////////////////////////////////////
       
    36 
       
    37 class TDisconnected : public TState
       
    38 {
       
    39 public:
       
    40     TDisconnected() : TState(EUsbMsDriveState_Disconnected){}
       
    41     ~TDisconnected(){}
       
    42 
       
    43     void MoveTo(TInt aStateId) const;
       
    44 
       
    45 private:
       
    46     void MoveToConnecting() const;
       
    47     void MoveToConnected() const;
       
    48 };
       
    49 
       
    50 //////////////////////////////////////////////////////////////
       
    51 
       
    52 class TConnecting : public TState
       
    53 {
       
    54 public:
       
    55     TConnecting() : TState(EUsbMsDriveState_Connecting){}
       
    56     ~TConnecting(){}
       
    57 
       
    58     void MoveTo(TInt aStateId) const;
       
    59 
       
    60 private:
       
    61     void MoveToWritten() const;
       
    62 };
       
    63 
       
    64 //////////////////////////////////////////////////////////////
       
    65 
       
    66 class TConnected : public TState
       
    67 {
       
    68 public:
       
    69     TConnected() : TState(EUsbMsDriveState_Connected){}
       
    70     ~TConnected(){}
       
    71 
       
    72     void MoveTo(TInt aStateId) const;
       
    73 
       
    74 private:
       
    75     void MoveToActive() const;
       
    76 };
       
    77 
       
    78 //////////////////////////////////////////////////////////////
       
    79 
       
    80 class TDisconnecting : public TState
       
    81 {
       
    82 public:
       
    83     TDisconnecting() : TState(EUsbMsDriveState_Disconnecting){}
       
    84     ~TDisconnecting(){}
       
    85 
       
    86     void MoveTo(TInt aStateId) const;
       
    87 
       
    88 private:
       
    89     void MoveToDisconnected() const;
       
    90 };
       
    91 
       
    92 //////////////////////////////////////////////////////////////
       
    93 
       
    94 class TActive : public TState
       
    95 {
       
    96 public:
       
    97     TActive() : TState(EUsbMsDriveState_Active){}
       
    98     ~TActive(){}
       
    99 
       
   100     void MoveTo(TInt aStateId) const;
       
   101     
       
   102 private:
       
   103     void MoveToLocked() const;
       
   104     void MoveToDisconnecting() const;
       
   105 };
       
   106 
       
   107 //////////////////////////////////////////////////////////////
       
   108 
       
   109 class TLocked : public TState
       
   110 {
       
   111 public:
       
   112     TLocked() : TState(EUsbMsDriveState_Locked){}
       
   113     ~TLocked(){}
       
   114 
       
   115     void MoveTo(TInt aStateId) const;
       
   116 
       
   117 private:
       
   118     void MoveToDisconnecting() const;
       
   119 };
       
   120 
       
   121 //////////////////////////////////////////////////////////////
       
   122 
       
   123 class TWritten : public TState
       
   124 {
       
   125 public:
       
   126     TWritten() : TState(EUsbMsState_Written){}
       
   127     ~TWritten(){}
       
   128 
       
   129     void MoveTo(TInt aStateId) const;
       
   130 
       
   131 private:
       
   132     void MoveToRead() const;
       
   133 };
       
   134 
       
   135 //////////////////////////////////////////////////////////////
       
   136 
       
   137 class TRead : public TState
       
   138 {
       
   139 public:
       
   140     TRead() : TState(EUsbMsState_Read){}
       
   141     ~TRead(){}
       
   142 
       
   143     void MoveTo(TInt aStateId) const;
       
   144 
       
   145 private:
       
   146     void MoveToDisconnected() const;
       
   147 };
       
   148 
       
   149 #endif // __TSTATE_H__    
       
   150    
       
   151 
       
   152