WSF
WsfScriptStateMachine::State Class Reference

#include <WsfScriptStateMachine.hpp>

Collaboration diagram for WsfScriptStateMachine::State:

Public Member Functions

 State ()=default
 State (WsfStringId aStateName, WsfScriptContext &aContext)
 State (const State &aSrc)=delete
const Stateoperator= (const State &aRhs)=delete
virtual ~State ()
virtual StateClone (WsfScriptContext &aContext) const
virtual std::unique_ptr< TransitionCreateTransition (WsfStringId aNextStateName) const
virtual void RemoveTransition (WsfStringId aNextStateName)
 Removes the specified transition from the state.
TransitionListGetTransitions ()
virtual void EnterState ()
 Execute the script associated with entering the state.
virtual int Evaluate (bool aShowStateEvaluations)
virtual void ExitState ()
 Execute the script associated with exiting the state.
int GetStateIndex () const
void SetStateIndex (int aStateIndex)
 Set the state index of this state within the state machine.
WsfStringId GetStateName () const
 Return the name (ID) of this state.
virtual bool Initialize (double aSimTime, WsfScriptStateMachine &aStateMachine, WsfScriptContext &aContext)
virtual bool ProcessInput (UtInput &aInput, WsfStringId aNameSpace=nullptr)
const WsfScenarioGetScenario () const
WsfScriptStateMachineChildStateMachine ()
int ChildStateIndex ()
void SetChildStateIndex (int stateIndex)
WsfAdvancedBehaviorTreeAdvancedBehaviorTree () const

Protected Member Functions

 State (const State &aSrc, WsfScriptContext &aContext)

Protected Attributes

WsfStringId mStateName
 The name (ID) of this state.
int mStateIndex {0}
 The index of this state within the state machine.
WsfScriptContextmContextPtr {nullptr}
 The script context.
UtScript * mOnEntryScriptPtr {nullptr}
WsfStringId mOnEntryScriptName
UtScript * mOnExitScriptPtr {nullptr}
WsfStringId mOnExitScriptName
TransitionList mTransitionList
 The rules that provide for transitions out of this state.
WsfBehaviorTreemBehaviorTreePtr {nullptr}
ut::CloneablePtr< WsfAdvancedBehaviorTreemAdvancedBehaviorTreePtr {nullptr}
WsfScriptStateMachinemChildFiniteStateMachinePtr {nullptr}
int mChildStateIndex {0}

Detailed Description

A 'State' represents an allowable state within the machine. It consists of a set of transitions as well as methods that are called on entry and exit from the state.

Constructor & Destructor Documentation

◆ State() [1/4]

WsfScriptStateMachine::State::State ( )
default

References State().

Referenced by Clone(), Initialize(), operator=(), State(), State(), and State().

◆ State() [2/4]

◆ State() [3/4]

WsfScriptStateMachine::State::State ( const State & aSrc)
delete

References State().

◆ ~State()

WsfScriptStateMachine::State::~State ( )
virtual

◆ State() [4/4]

Member Function Documentation

◆ AdvancedBehaviorTree()

WsfAdvancedBehaviorTree * WsfScriptStateMachine::State::AdvancedBehaviorTree ( ) const
inline

◆ ChildStateIndex()

int WsfScriptStateMachine::State::ChildStateIndex ( )
inline

◆ ChildStateMachine()

◆ Clone()

WsfScriptStateMachine::State * WsfScriptStateMachine::State::Clone ( WsfScriptContext & aContext) const
virtual

Create a clone of the state. This must be provided by a derived class if they extend State.

References State().

Referenced by operator=().

◆ CreateTransition()

std::unique_ptr< WsfScriptStateMachine::Transition > WsfScriptStateMachine::State::CreateTransition ( WsfStringId aNextStateName) const
virtual

A virtual constructor for Transition objects. This must be provided by derived classes if they extend Transition.

Referenced by operator=(), and ProcessInput().

◆ EnterState()

void WsfScriptStateMachine::State::EnterState ( )
virtual

Execute the script associated with entering the state.

References mChildFiniteStateMachinePtr, mChildStateIndex, mContextPtr, mOnEntryScriptPtr, and WsfObserver::StateMachineState().

Referenced by WsfScriptStateMachine::EnterState().

◆ Evaluate()

int WsfScriptStateMachine::State::Evaluate ( bool aShowStateEvaluations)
virtual

Evaluate the transition rules associated with the state. The rules are evaluated in the order in which they are defined. Control returns to the caller when the first rule that would cause a transition is detected.

Returns
The state index of the next state to be executed. If no transition occurs then it simply returns the state index of the current state.

References WsfScriptStateMachine::GetStateName(), mAdvancedBehaviorTreePtr, mBehaviorTreePtr, mChildFiniteStateMachinePtr, mChildStateIndex, mContextPtr, mStateIndex, and mTransitionList.

Referenced by WsfScriptStateMachine::Evaluate(), and WsfScriptStateMachine::EvaluateState().

◆ ExitState()

void WsfScriptStateMachine::State::ExitState ( )
virtual

Execute the script associated with exiting the state.

References mContextPtr, and mOnExitScriptPtr.

Referenced by WsfScriptStateMachine::ExitState().

◆ GetScenario()

const WsfScenario * WsfScriptStateMachine::State::GetScenario ( ) const

References mContextPtr.

◆ GetStateIndex()

int WsfScriptStateMachine::State::GetStateIndex ( ) const
inline

Return the index of this state within the state machine.

Returns
the state index in the range [1..N].

References mStateIndex.

Referenced by WsfScriptStateMachine::EnterState(), WsfScriptStateMachine::Evaluate(), WsfScriptStateMachine::EvaluateState(), WsfScriptStateMachine::ExitState(), WsfScriptStateMachine::GetStateIndex(), and Initialize().

◆ GetStateName()

WsfStringId WsfScriptStateMachine::State::GetStateName ( ) const
inline

◆ GetTransitions()

TransitionList & WsfScriptStateMachine::State::GetTransitions ( )
inline

References mTransitionList.

◆ Initialize()

bool WsfScriptStateMachine::State::Initialize ( double aSimTime,
WsfScriptStateMachine & aStateMachine,
WsfScriptContext & aParentContext )
virtual

Initialize the state.

Parameters
aSimTimeThe current simulation time.
aStateMachineThe state machine with which the state is associated.
aParentContextThe script context to which this state context is to be attached.
Returns
true if successful or false if not.

References WsfScriptStateMachine::FindState(), GetStateIndex(), mAdvancedBehaviorTreePtr, mBehaviorTreePtr, mChildFiniteStateMachinePtr, mContextPtr, mOnEntryScriptName, mOnEntryScriptPtr, mOnExitScriptName, mOnExitScriptPtr, mStateName, mTransitionList, ok, WsfScriptStateMachine::Processor(), State(), and WsfScriptStateMachine::WsfScriptStateMachine().

◆ operator=()

const State & WsfScriptStateMachine::State::operator= ( const State & aRhs)
delete

◆ ProcessInput()

bool WsfScriptStateMachine::State::ProcessInput ( UtInput & aInput,
WsfStringId aNameSpace = nullptr )
virtual

Process input for the state.

Parameters
aInputThe input stream.
aNameSpaceThe string name ID of the state namespace
Returns
true if a command was recognized (and processed) or false if the command was not one recognized.

References CreateTransition(), WsfScenario::FromInput(), WsfObject::GetType(), mAdvancedBehaviorTreePtr, mBehaviorTreePtr, mChildFiniteStateMachinePtr, mContextPtr, mOnEntryScriptName, mOnExitScriptName, mStateName, mTransitionList, WsfAdvancedBehaviorTreeLeafNode::ProcessInput(), WsfBehaviorTreeLeafNode::ProcessInput(), and WsfScriptStateMachine::WsfScriptStateMachine().

Referenced by WsfScriptProcessor::ProcessInput().

◆ RemoveTransition()

void WsfScriptStateMachine::State::RemoveTransition ( WsfStringId aNextStateName)
virtual

Removes the specified transition from the state.

References mTransitionList.

Referenced by operator=().

◆ SetChildStateIndex()

void WsfScriptStateMachine::State::SetChildStateIndex ( int stateIndex)

◆ SetStateIndex()

void WsfScriptStateMachine::State::SetStateIndex ( int aStateIndex)
inline

Set the state index of this state within the state machine.

References mStateIndex.

Member Data Documentation

◆ mAdvancedBehaviorTreePtr

ut::CloneablePtr<WsfAdvancedBehaviorTree> WsfScriptStateMachine::State::mAdvancedBehaviorTreePtr {nullptr}
protected

◆ mBehaviorTreePtr

WsfBehaviorTree* WsfScriptStateMachine::State::mBehaviorTreePtr {nullptr}
protected

◆ mChildFiniteStateMachinePtr

WsfScriptStateMachine* WsfScriptStateMachine::State::mChildFiniteStateMachinePtr {nullptr}
protected

◆ mChildStateIndex

int WsfScriptStateMachine::State::mChildStateIndex {0}
protected

◆ mContextPtr

WsfScriptContext* WsfScriptStateMachine::State::mContextPtr {nullptr}
protected

◆ mOnEntryScriptName

WsfStringId WsfScriptStateMachine::State::mOnEntryScriptName
protected

Referenced by Initialize(), ProcessInput(), State(), and State().

◆ mOnEntryScriptPtr

UtScript* WsfScriptStateMachine::State::mOnEntryScriptPtr {nullptr}
protected

The script to be executed when entering the state. Note that this script is 'owned' by the script context under which it was compiled.

Referenced by EnterState(), Initialize(), State(), and State().

◆ mOnExitScriptName

WsfStringId WsfScriptStateMachine::State::mOnExitScriptName
protected

Referenced by Initialize(), ProcessInput(), State(), and State().

◆ mOnExitScriptPtr

UtScript* WsfScriptStateMachine::State::mOnExitScriptPtr {nullptr}
protected

The script to be executed when exiting the state. Note that this script is 'owned' by the script context under which it was compiled.

Referenced by ExitState(), Initialize(), State(), and State().

◆ mStateIndex

int WsfScriptStateMachine::State::mStateIndex {0}
protected

The index of this state within the state machine.

Referenced by Evaluate(), GetStateIndex(), SetStateIndex(), State(), and State().

◆ mStateName

WsfStringId WsfScriptStateMachine::State::mStateName
protected

The name (ID) of this state.

Referenced by GetStateName(), Initialize(), ProcessInput(), State(), and State().

◆ mTransitionList

TransitionList WsfScriptStateMachine::State::mTransitionList
protected

The rules that provide for transitions out of this state.

Referenced by Evaluate(), GetTransitions(), Initialize(), ProcessInput(), RemoveTransition(), State(), and State().


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved