phonebookengines/contactsmodel/cntsrv/src/CCntStateMachine.cpp
changeset 46 efe85016a067
parent 24 0ba2181d7c28
equal deleted inserted replaced
40:b46a585f6909 46:efe85016a067
  2536  Create and add all states to the state machine array	
  2536  Create and add all states to the state machine array	
  2537  
  2537  
  2538  @param aPersistenceLayer. The persistence layer that wraps up access to the database.
  2538  @param aPersistenceLayer. The persistence layer that wraps up access to the database.
  2539 */
  2539 */
  2540 void CCntStateMachine::ConstructL(CPersistenceLayer& aPersistenceLayer)
  2540 void CCntStateMachine::ConstructL(CPersistenceLayer& aPersistenceLayer)
  2541 	{
  2541     {
  2542 	iState = CStateClosed::NewL(*this, aPersistenceLayer);
  2542     // The order in which states are appended must be in sync with
  2543 	CleanupStack::PushL(iState);
  2543     // the declaration order of the state enum.
  2544 	// The order in which states are appended must be in sync with
  2544     for (TInt i = 0; i < 6; ++i)
  2545 	// the declaration order of the state enum.
  2545         {
  2546 	iStateArray.AppendL(iState); 
  2546         CState* state;
  2547 	CleanupStack::Pop(iState);
  2547         switch (i)
  2548 	
  2548             {
  2549 	iStateArray.AppendL(CStateTablesClosed::NewL(*this, aPersistenceLayer)); 
  2549             case 0:  state = CStateClosed::NewL(*this, aPersistenceLayer); iState = state; break;
  2550 	iStateArray.AppendL(CStateWritable	  ::NewL(*this, aPersistenceLayer));
  2550             case 1:  state = CStateTablesClosed::NewL(*this, aPersistenceLayer); break;
  2551 	iStateArray.AppendL(CStateOpening 	  ::NewL(*this, aPersistenceLayer));
  2551             case 2:  state = CStateWritable::NewL(*this, aPersistenceLayer); break;
  2552 	iStateArray.AppendL(CStateTransaction ::NewL(*this, aPersistenceLayer));
  2552             case 3:  state = CStateOpening::NewL(*this, aPersistenceLayer); break;
  2553 	iStateArray.AppendL(CStateBackupRestore::NewL(*this, aPersistenceLayer));
  2553             case 4:  state = CStateTransaction::NewL(*this, aPersistenceLayer); break;
  2554 	}
  2554             default: state = CStateBackupRestore::NewL(*this, aPersistenceLayer); 
       
  2555             }
       
  2556         CleanupStack::PushL(state);
       
  2557         iStateArray.AppendL(state); 
       
  2558         CleanupStack::Pop(state);
       
  2559         }	
       
  2560     }
  2555 
  2561 
  2556 /**
  2562 /**
  2557  Get the current active state		
  2563  Get the current active state		
  2558  
  2564  
  2559  @return The current active state
  2565  @return The current active state