|
WSF
|
#include <WsfScriptMessageHandler.hpp>

Classes | |
| struct | Handler |
| A 'Handler' represents a 'type' and one or more 'subtypes' that share a common script. More... | |
Public Member Functions | |
| WsfScriptMessageHandler ()=default | |
| WsfScriptMessageHandler (WsfScriptContext &aContext) | |
| WsfScriptMessageHandler (const WsfScriptMessageHandler &aSrc, WsfScriptContext &aContext) | |
| virtual | ~WsfScriptMessageHandler ()=default |
| bool | HasMessageHandler () const |
| virtual bool | Initialize (double aSimTime, WsfPlatform *aPlatformPtr) |
| virtual bool | ProcessInput (UtInput &aInput) |
| virtual bool | ProcessMessage (double aSimTime, const WsfMessage &aMessage) |
| void | SetTimeAndMessage (double aSimTime, const WsfMessage &aMessage) |
Protected Attributes | |
| WsfPlatform * | mPlatformPtr {nullptr} |
| WsfScriptContext * | mContextPtr {nullptr} |
| The context used for compiling and executing scripts. | |
| std::vector< Handler > | mHandlers |
| The list of message handlers. | |
| std::vector< WsfStringId > | mScriptNames |
| The list of script names, indexed by the handlers script index. | |
| std::vector< UtScript * > | mScriptPtrs |
| UtScript * | mOnMessageScriptPtr {nullptr} |
| The pointer to the explicit 'script void on_message()' if it was defined. | |
| bool | mHasMessageHandler {false} |
| true if 'on_message' or 'script void on_message()' has been defined. | |
| UtScriptData * | mMessageVarPtr {nullptr} |
| The message script variable's memory index. | |
| int | mMessageVarIndex {-1} |
A script-based message handler.
This object provides the ability to define scripts to process messages. It provides the 'on_message' command and also maintains the 'MESSAGE' script variable that refers to the current message being processed. Any variables defined by WsfScriptContext ('PLATFORM', 'PROCESSOR', 'TIME_NOW') are also available.
The user of this class is responsible for the following:
|
default |
References WsfScriptMessageHandler().
Referenced by WsfScriptMessageHandler(), and WsfScriptMessageHandler().
| WsfScriptMessageHandler::WsfScriptMessageHandler | ( | WsfScriptContext & | aContext | ) |
Constructor
| aContext | The script context to be used for compiling and executing scripts. |
References WsfScriptContext::GetContext(), mContextPtr, mHandlers, mHasMessageHandler, mMessageVarPtr, mOnMessageScriptPtr, mPlatformPtr, mScriptNames, and mScriptPtrs.
| WsfScriptMessageHandler::WsfScriptMessageHandler | ( | const WsfScriptMessageHandler & | aSrc, |
| WsfScriptContext & | aContext ) |
Copy constructor
| aSrc | The source object. |
| aContext | The script context to be used for compiling and executing scripts. |
References WsfScriptContext::GetContext(), mContextPtr, mHandlers, mHasMessageHandler, mMessageVarPtr, mOnMessageScriptPtr, mPlatformPtr, mScriptNames, mScriptPtrs, and WsfScriptMessageHandler().
|
virtualdefault |
|
inline |
Return true if there is a message handler defined.
References mHasMessageHandler.
|
virtual |
Initialize the message handler object.
| aSimTime | The current simulation time. |
| aPlatformPtr | The platform with which the message handler is associated. |
References mContextPtr, mHandlers, mHasMessageHandler, mOnMessageScriptPtr, mPlatformPtr, mScriptNames, mScriptPtrs, and ok.
|
virtual |
Check for and process message handler commands.
| aInput | The input stream. |
References mContextPtr, mHandlers, WsfScriptMessageHandler::Handler::mScriptIndex, mScriptNames, and WsfScriptMessageHandler::Handler::mType.
|
virtual |
Invoke the appropriate message handling script if one is defined. If a script has been defined for the message then:
| aSimTime | The current simulation time. |
| aMessage | The message being processed. |
References WsfMessage::GetSubType(), WsfMessage::GetType(), mContextPtr, mHandlers, mHasMessageHandler, mMessageVarPtr, mOnMessageScriptPtr, mPlatformPtr, mScriptPtrs, and SetTimeAndMessage().
Referenced by WsfSA_Perceive::ProcessMessage(), and WsfTrackProcessor::ProcessMessage().
| void WsfScriptMessageHandler::SetTimeAndMessage | ( | double | aSimTime, |
| const WsfMessage & | aMessage ) |
Set the TIME_NOW and MESSAGE script variables.
| aSimTime | The current simulation time. |
| aMessage | The message that is being processed. |
References mMessageVarPtr.
Referenced by ProcessMessage().
|
protected |
The context used for compiling and executing scripts.
Referenced by Initialize(), ProcessInput(), ProcessMessage(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().
|
protected |
The list of message handlers.
Referenced by Initialize(), ProcessInput(), ProcessMessage(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().
|
protected |
true if 'on_message' or 'script void on_message()' has been defined.
Referenced by HasMessageHandler(), Initialize(), ProcessMessage(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().
|
protected |
|
protected |
The message script variable's memory index.
Referenced by ProcessMessage(), SetTimeAndMessage(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().
|
protected |
The pointer to the explicit 'script void on_message()' if it was defined.
Referenced by Initialize(), ProcessMessage(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().
|
protected |
Referenced by Initialize(), ProcessMessage(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().
|
protected |
The list of script names, indexed by the handlers script index.
Referenced by Initialize(), ProcessInput(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().
|
protected |
The list of scripts, indexed by the handles script index. This is valid only after Initialize() has been called. The scripts are owned by the script context.
Referenced by Initialize(), ProcessMessage(), WsfScriptMessageHandler(), and WsfScriptMessageHandler().