Msrp/MsrpServer/src/TStateFactory.cpp
branchMSRP_FrameWork
changeset 25 505ad3f0ce5c
child 58 cdb720e67852
equal deleted inserted replaced
22:f1578314b8da 25:505ad3f0ce5c
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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 * Initial Contributors:
       
     9 * Nokia Corporation - initial contribution.
       
    10 * Contributors:
       
    11 *
       
    12 * Description:
       
    13 * MSRP Implementation
       
    14 *
       
    15 */
       
    16 
       
    17 #include "TStateFactory.h"
       
    18 
       
    19 #define ADD_STATE_TO_ARRAY(state) \
       
    20     {\
       
    21     CleanupStack::PushL( state ); \
       
    22     iStateArray.InsertL( state, state->identity() ); \
       
    23     CleanupStack::Pop( state ); \
       
    24     }
       
    25 
       
    26 CStateFactory* CStateFactory::NewL()
       
    27     {
       
    28     CStateFactory* factory = CStateFactory::NewLC();
       
    29     CleanupStack::Pop( factory );       
       
    30     return factory;
       
    31     }
       
    32 
       
    33 CStateFactory* CStateFactory::NewLC()
       
    34     {
       
    35     CStateFactory* factory = new ( ELeave ) CStateFactory;
       
    36     CleanupStack::PushL( factory );
       
    37     factory->ConstructL();
       
    38     return factory;       
       
    39     }
       
    40 
       
    41 void CStateFactory::ConstructL( )
       
    42     {
       
    43     TStateBase *state;
       
    44 
       
    45     state = new ( ELeave ) TStateIdle;
       
    46     ADD_STATE_TO_ARRAY( state );
       
    47 
       
    48     state = new ( ELeave ) TStateConnecting;
       
    49     ADD_STATE_TO_ARRAY( state );
       
    50 
       
    51     state = new ( ELeave ) TStateWaitForClient;
       
    52     ADD_STATE_TO_ARRAY( state );
       
    53     
       
    54     state = new ( ELeave ) TStateActive;
       
    55     ADD_STATE_TO_ARRAY( state );
       
    56 
       
    57     state = new ( ELeave ) TStateActiveSend;
       
    58     ADD_STATE_TO_ARRAY( state ); 
       
    59 	
       
    60 	state = new ( ELeave ) TStateFileShare;
       
    61     ADD_STATE_TO_ARRAY( state ); 
       
    62     
       
    63     state = new ( ELeave ) TStateError;
       
    64     ADD_STATE_TO_ARRAY( state );  
       
    65     }
       
    66 
       
    67 CStateFactory::CStateFactory()
       
    68     {   
       
    69     }
       
    70 
       
    71 CStateFactory::~CStateFactory()
       
    72     {    
       
    73     iStateArray.ResetAndDestroy();
       
    74     iStateArray.Close();    
       
    75     }
       
    76   
       
    77 TStateBase* CStateFactory::getStateL(TStates aState)
       
    78     {    
       
    79     return iStateArray[aState];    
       
    80     }
       
    81