Example #1
0
 void ICreature::SetActionStateChangeHandler(const ActionStateChangedHandler& stateChangeHandler)
 {
   switch(m_ActionPrevState)
   {
     case IActionBase::State::INVALID:
     {
       break;
     }
     
     case IActionBase::State::PROCESSING:
     {
       HandleStateChange(IActionBase::State::CANCELED);
       break;
     }
     
     default:
     {
       HandleStateChange(IActionBase::State::FINISHED);
       break;
     }
   }
   
   m_ActionPrevState = IActionBase::State::PROCESSING;
   m_StateChangeHandler = stateChangeHandler;
 }
Example #2
0
void Widget::SetState( State state ) {
	// Do nothing if state wouldn't change.
	if( GetState() == state ) {
		return;
	}

	auto old_state = GetState();

	// Store the new state.
	m_state = state;

	auto emit_state_change = false;

	// If HandleStateChange() changed the state, do not call observer, will be
	// done from there too.
	if( GetState() != old_state ) {
		HandleStateChange( static_cast<State>( old_state ) );
		emit_state_change = true;
	}

	if( state == State::ACTIVE ) {
		GrabFocus( shared_from_this() );
		SetActiveWidget( shared_from_this() );
	}
	else if( old_state == State::ACTIVE ) {
		SetActiveWidget( Ptr() );
	}

	if( emit_state_change ) {
		GetSignals().Emit( OnStateChange );
	}
}
Example #3
0
void Widget::SetState( State state ) {
	// Do nothing if state wouldn't change.
	if( GetState() == state ) {
		return;
	}

	unsigned char old_state( GetState() );

	// Clear the state bits to 0s.
	m_bitfield &= static_cast<unsigned char>( 0xf1 );

	// Store the new state.
	m_bitfield |= static_cast<unsigned char>( state << 1 );

	// If HandleStateChange() changed the state, do not call observer, will be
	// done from there too.
	if( GetState() != old_state ) {
		HandleStateChange( static_cast<State>( old_state ) );
		GetSignals().Emit( OnStateChange );
	}

	if( state == ACTIVE ) {
		GrabFocus( shared_from_this() );
		SetActiveWidget( shared_from_this() );
	}
	else if( old_state == ACTIVE ) {
		SetActiveWidget( Ptr() );
	}
}
// --------------------------------------------------------
//
// ---------------------------------------------------------
//
void CAlmAlarmControl::SetState(TInt aState)
{
    TRACE_ENTRY_POINT;
    const TInt oldState( iState );
    iState = aState;
    // handle state transitions
    HandleStateChange( oldState );
    TRACE_EXIT_POINT;
}
void AbstractHandlerWithState::AddState(const QString& stateId, const SmartPointer<State>& state)
{
  if (state.IsNull())
  {
    throw ctkInvalidArgumentException("Cannot add a null state");
  }

  states.insert(stateId, state);
  state->AddListener(this);
  HandleStateChange(state, Object::Pointer(0));
}
Example #6
0
 void ICreature::HandleMotionStateChange(MotionTaskState currentState)
 {
   if(m_CurrCustomAction == NULL)
   {
     const IActionBase::State motionToCreatureState[MotionTaskState::AMOUNT] =
     {
       IActionBase::State::INVALID, IActionBase::State::PROCESSING, IActionBase::State::REACHED
     };
     const IActionBase::State creatureActionState = motionToCreatureState[currentState];
     HandleStateChange(creatureActionState);
   }
 }
void Node::SetState( NodeState newState )
{
   NodeState old;

   {
      MutexLocker ml( mtx );
      old = state;
      state = newState;
   }

   if( old != newState )
      HandleStateChange( old, newState );
}
Example #8
0
void Widget::SetState( State state ) {
	// Do nothing if state wouldn't change.
	if( m_state == state ) {
		return;
	}

	State old_state( m_state );
	m_state = state;

	// If HandleStateChange() changed the state, do not call observer, will be
	// done from there too.
	if( m_state != old_state ) {
		HandleStateChange( old_state );
		OnStateChange();
	}

	if( state == Active ) {
		GrabFocus( shared_from_this() );
	}
}
Example #9
0
 void ICreature::HandleCustomAction(TimeStep dt)
 {
   if(m_CurrCustomAction != NULL)
   {
     m_CurrCustomAction->HandleTick(dt);
     const IActionBase::State actionState = (m_CurrCustomAction != NULL ?
       m_CurrCustomAction->GetState() : (IActionBase::State)IActionBase::State::CANCELED);
     HandleStateChange(actionState);
     if(actionState == IActionBase::State::CANCELED || actionState == IActionBase::State::FINISHED)
     {
       if(m_CurrCustomAction != NULL)
       {
         m_CurrCustomAction->Stop();
         m_CurrCustomAction = NULL;
       }
       
       m_CurrentActionId = CreatureActionId::NONE;
     }
   }
   else
   {
     /* motion system's simple action is active */
   }
 }
Example #10
0
void WorkerTCP::Init()
{
    globalData = new char[ProgramVariables::K4];
    globalLength = 0;
    state = Peers::STATE::FREE;
    board = new Board();

    time = new QTimer();
    connect(time,SIGNAL(timeout()),this,SLOT(Reconnect()));

    waitForOKMessageTimer = new QTimer();
    connect(waitForOKMessageTimer,SIGNAL(timeout()),this,SLOT(NoResponseFromServer()));
    waitForOKMessageTimer->setInterval(ProgramVariables::GetMaxTimeWaitToServer());

    tcpSocket = new QTcpSocket(this);
    connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(ReadDataFromServer()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(ConnectionError(QAbstractSocket::SocketError)));
    connect(tcpSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(HandleStateChange(QAbstractSocket::SocketState)));
    connect(tcpSocket,SIGNAL(connected()),this,SLOT(Connected()));

    waitForIATimer = new QTimer();
    waitForIATimer->setInterval(10);
    connect(waitForIATimer,SIGNAL(timeout()), this, SLOT(CheckStatus()));
}