void agent_t::so_change_state( const state_t & new_state ) { ensure_operation_is_on_working_thread( "so_change_state" ); if( new_state.is_target( this ) ) { auto actual_new_state = new_state.actual_state_to_enter(); if( !( *actual_new_state == *m_current_state_ptr ) ) { // New state differs from the current one. // Actual state switch must be performed. do_state_switch( *actual_new_state ); // State listener should be informed. m_state_listener_controller->changed( *this, *m_current_state_ptr ); } } else SO_5_THROW_EXCEPTION( rc_agent_unknown_state, "unable to switch agent to alien state " "(the state that doesn't belong to this agent)" ); }