⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdpstatemc.cpp

📁 Symbian C++ scmp.zip
💻 CPP
字号:
// gdpstatemc.cpp
//
// Copyright (c) 1999 Symbian Ltd.  All rights reserved.
//


#include "gdpstatemc.h"

/**************** CGdpStateMachine ****************/

CGdpStateMachine::CGdpStateMachine(TPriority aPriority)
	: CActive(aPriority)
	{
	CActiveScheduler::Add(this);
	}

CGdpStateMachine::~CGdpStateMachine()
	{
//	Deque();
	}

void CGdpStateMachine::RunL()
	{
	// Make sure we're in a state, if we're not, something is awry so panic
	__ASSERT_ALWAYS(iState != NULL, GdpUtil::Panic(GdpUtil::EStateMachineStateError));
	
	// See how the last SetActive ended up
	TInt err = iStatus.Int();

	// Depending on how that went, decide where to go next
	TState* nextState = NULL;
	if(err == KErrNone)
		{
		// Everything was OK, leave this state
		nextState = iState->CompleteL();
		}
	else
		{
		// Something went wrong, ERROR
		nextState = iState->ErrorL(err);
		}

	// Just move on to the next state (could be NULL, in which case we're done)
	ChangeState(nextState);
	}

TInt CGdpStateMachine::RunError(TInt aError)
/**
	This is called if RunL leaves.
	This will be through CompleteL or ErrorL leaving.
	Handle the error in the state machine.
**/
	{
	TState* nextState = ErrorOnStateExit(aError);
	ChangeState(nextState);
	return KErrNone;
	}

void CGdpStateMachine::ChangeState(CGdpStateMachine::TState* aNextState)
//
// Enter aNextState, and make it our current state.
//
	{
	// We'd better not be waiting for something
	__ASSERT_ALWAYS(!IsActive(), GdpUtil::Panic(GdpUtil::EStateMachineStateError));

	TInt err;
	while (aNextState) // Note how easy it is to endless loop!
		{// State change required.
		iState = aNextState;
		TRAP(err, iState->EnterL());
		aNextState = err ? ErrorOnStateEntry(err) : NULL;
		}
	}

void CGdpStateMachine::SetNextState(TState* aNextState)
//
// Set the current state, but don't actually enter it.
//
	{
	__ASSERT_ALWAYS(!IsActive(), GdpUtil::Panic(GdpUtil::EStateMachineStateError));
	iState = aNextState;
	}

void CGdpStateMachine::ReEnterCurrentState()
//
// Re-enter the state we're currently in.
//	
	{
	ChangeState(iState);
	}

void CGdpStateMachine::DoCancel()
//
// Cancel the current state action (only called if active)
//
	{
	iState->Cancel();
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -