?? gdpstatemc.cpp
字號(hào):
// 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();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -