|
WSF
|
#include <WsfScriptObserver.hpp>


Classes | |
| struct | EventData |
| class | EventGuard |
Public Types | |
| using | ScriptList = std::vector<UtScript*> |
| using | EventList = std::vector<EventData> |
| using | EventToIndexMap = std::map<std::string, int> |
| template<typename... Args> | |
| using | Observer = UtCallbackListN<void(double, Args...)> |
Public Member Functions | |
| WsfScriptObserver (WsfSimulation &aSimulation, const WsfScriptObserverExtension &aScenario) | |
| ~WsfScriptObserver () override=default | |
| void | AddedToSimulation () override |
| bool | Initialize () override |
| void | Start () override |
| WSF_DEPRECATED int | AddEvent (const std::string &aEventName, std::unique_ptr< UtCallback > aCallbackPtr, const std::string &aDefaultScriptName, const std::string &aExpectedArgumentTypes) |
| template<bool EnableGuard = false, typename... Args, typename ArgPacker> | |
| void | AddEvent (const std::string &aEventName, Observer< Args... > &aObserver, const std::string &aDefaultScriptName, const std::string &aExpectedArgumentTypes, const ArgPacker &aArgPacker) |
| template<bool EnableGuard = false, typename... Args> | |
| void | AddEvent (const std::string &aEventName, Observer< Args... > &aObserver, const std::string &aDefaultScriptName, const std::string &aExpectedArgumentTypes) |
| int | GetEventIndex (const std::string &aEventName) const |
| ScriptList & | GetScriptList (int aIndex) |
| const EventList & | GetEvents () const |
| const EventToIndexMap & | GetEventIndexes () const |
| void | EventEntry () |
| void | EventExit () |
| bool | EnableOrDisable (bool aEnable, const std::string &aCallbackName, const std::string &aScriptName) |
| bool | EnableOrDisable (bool aEnable, const std::string &aEventName, const std::string &aScriptName, EventData &aEventData) |
| const EventToIndexMap | GetEventMap () const |
| void | ExecuteScriptList (double aSimTime, const std::vector< UtScript * > &aScriptList) |
| void | ExecuteScriptList (double aSimTime, const std::vector< UtScript * > &aScriptList, UtScriptData &aScriptRetVal, UtScriptDataList &aScriptArgs) |
| Public Member Functions inherited from WsfSimulationExtension | |
| WsfSimulationExtension () | |
| ~WsfSimulationExtension () override=default | |
| WsfSimulation & | GetSimulation () const |
| const WsfScenario & | GetScenario () const |
| virtual bool | PrepareExtension () |
| virtual bool | PlatformsInitialized () |
| virtual void | PendingStart () |
| virtual void | Complete (double aSimTime) |
| Public Member Functions inherited from WsfExtension | |
| virtual | ~WsfExtension ()=default |
| const std::string & | GetExtensionName () const |
Static Public Member Functions | |
| static WsfScriptObserver * | Find (const WsfSimulation &aSimulation) |
| static void | __private_SetSim (WsfSimulationExtension &aExtension, WsfSimulation *aSimPtr) |
Protected Member Functions | |
| WsfScriptObserver (const WsfScriptObserver &aSrc)=delete | |
| Copy constructor is declared but not defined to prevent use. | |
| Protected Member Functions inherited from WsfExtension | |
| void | InitializeExtensionName (const std::string &aName) |
Protected Attributes | |
| UtCallbackHolder | mCallbacks |
| Container to hold registered callbacks. | |
WsfScriptObserver allows script methods to be registered with observer callbacks
| using WsfScriptObserver::EventList = std::vector<EventData> |
| using WsfScriptObserver::EventToIndexMap = std::map<std::string, int> |
| using WsfScriptObserver::Observer = UtCallbackListN<void(double, Args...)> |
| using WsfScriptObserver::ScriptList = std::vector<UtScript*> |
| WsfScriptObserver::WsfScriptObserver | ( | WsfSimulation & | aSimulation, |
| const WsfScriptObserverExtension & | aScenario ) |
References WsfSimulationExtension::WsfSimulation, and WsfSimulationExtension::WsfSimulationExtension().
Referenced by WsfScriptObserver::EventGuard::EventGuard(), Find(), and WsfScriptObserver().
|
overridedefault |
References AddedToSimulation(), Initialize(), and Start().
|
protecteddelete |
Copy constructor is declared but not defined to prevent use.
References WsfScriptObserver().
|
overridevirtual |
Called in response to WsfSimulation::RegisterExtension. The extension has now been registered in the simulation.
Reimplemented from WsfSimulationExtension.
References AddEvent(), WsfObserver::CommAddedToLocal(), WsfObserver::CommAddedToManager(), WsfObserver::Comment(), WsfObserver::CommFrequencyChanged(), WsfObserver::CommRemovedFromLocal(), WsfObserver::CommRemovedFromManager(), WsfObserver::CommTurnedOff(), WsfObserver::CommTurnedOn(), WsfObserver::CrashedIntoGround(), WsfObserver::ExecuteCallback(), WsfObserver::FuelEvent(), WsfSimulationExtension::GetSimulation(), WsfObserver::ImageCreated(), WsfObserver::LinkAddedToLocal(), WsfObserver::LinkAddedToManager(), WsfObserver::LinkDisabledOnLocal(), WsfObserver::LinkDisabledOnManager(), WsfObserver::LinkEnabledOnLocal(), WsfObserver::LinkEnabledOnManager(), WsfObserver::LinkRemovedFromLocal(), WsfObserver::LinkRemovedFromManager(), WsfObserver::LocalTrackCorrelation(), WsfObserver::LocalTrackDecorrelation(), WsfObserver::LocalTrackDropped(), WsfObserver::LocalTrackInitiated(), WsfObserver::LocalTrackUpdated(), WsfObserver::MessageDeliveryAttempt(), WsfObserver::MessageDiscarded(), WsfObserver::MessageFailedRouting(), WsfObserver::MessageHop(), WsfObserver::MessageQueued(), WsfObserver::MessageReceived(), WsfObserver::MessageTransmitEnded(), WsfObserver::MessageTransmitted(), WsfObserver::MessageTransmittedHeartbeat(), WsfObserver::MessageUpdated(), WsfObserver::MoverBroken(), WsfObserver::MoverBurnedOut(), WsfObserver::MoverStaged(), WsfObserver::MoverUpdated(), WsfObserver::NetworkAdded(), WsfObserver::NetworkRemoved(), WsfObserver::OperatingLevelChanged(), WsfObserver::PlatformAdded(), WsfObserver::PlatformAppearanceChanged(), WsfObserver::PlatformBroken(), WsfObserver::PlatformCapabilityChanged(), WsfObserver::PlatformDeleted(), WsfObserver::PlatformInitialized(), WsfObserver::PlatformOmitted(), WsfObserver::ProcessorTurnedOff(), WsfObserver::ProcessorTurnedOn(), WsfObserver::RouterTurnedOff(), WsfObserver::RouterTurnedOn(), WsfObserver::SensorDetectionAttempt(), WsfObserver::SensorDetectionChanged(), WsfObserver::SensorFrequencyChanged(), WsfObserver::SensorModeActivated(), WsfObserver::SensorModeDeactivated(), WsfObserver::SensorRequestCanceled(), WsfObserver::SensorRequestInitiated(), WsfObserver::SensorRequestUpdated(), WsfObserver::SensorTrackCoasted(), WsfObserver::SensorTrackDropped(), WsfObserver::SensorTrackInitiated(), WsfObserver::SensorTrackUpdated(), WsfObserver::SensorTurnedOff(), WsfObserver::SensorTurnedOn(), WsfObserver::SimulationComplete(), WsfObserver::StateEntry(), WsfObserver::StateExit(), WsfObserver::TankingEvent(), WsfObserver::TaskAssigned(), WsfObserver::TaskCanceled(), and WsfObserver::TaskCompleted().
Referenced by ~WsfScriptObserver().
|
inline |
Register an event using the default argument packer, which will pack script arguments directly from the Observer in order (see UtScriptDataPack). Rather than a separate overload, this argument packer could have been provided as the default value for the ArgPacker in the 5-argument version above. However, a bug (#53837) in gcc versions < 4.9 gives a parse error when expanding a parameter pack in a function argument default value.
References AddEvent().
| void WsfScriptObserver::AddEvent | ( | const std::string & | aEventName, |
| Observer< Args... > & | aObserver, | ||
| const std::string & | aDefaultScriptName, | ||
| const std::string & | aExpectedArgumentTypes, | ||
| const ArgPacker & | aArgPacker ) |
Register an event, providing a function that will pack the arguments for the script.
| EnableGuard | Enables the event guard for multi-threading safety (default false) |
| aEventName | The name of the event |
| aObserver | The observer which will trigger the script |
| aDefaultScriptName | The name of the user script to execute, if none is specified |
| aExpectedArgumentTypes | The signature of the script |
| aArgPacker | Callable object to pack the arguments for the script. Should have signature: void fun(UtScriptDataPacker&, Args...) |
References ExecuteScriptList(), WsfSimulation::GetApplication(), GetEventIndex(), GetScriptList(), WsfApplication::GetScriptTypes(), WsfSimulationExtension::GetSimulation(), and detail::make_event_guard().
|
inline |
Referenced by AddedToSimulation(), AddEvent(), and WsfMilScriptObserver::Register_script_observer().
| bool WsfScriptObserver::EnableOrDisable | ( | bool | aEnable, |
| const std::string & | aEventName, | ||
| const std::string & | aScriptName ) |
Enable or disable the callback, specified by event name, with the Observer.
| aEnable | 'true' indicates the callback should be enabled. |
| aEventName | The name of the callback to register. |
| aScriptName | The name of the script to be associated with the callback. |
References EnableOrDisable(), GetEventIndex(), and ok.
Referenced by EnableOrDisable(), and Initialize().
| bool WsfScriptObserver::EnableOrDisable | ( | bool | aEnable, |
| const std::string & | aEventName, | ||
| const std::string & | aScriptName, | ||
| EventData & | aEventData ) |
References WsfScriptContext::FindScript(), WsfSimulation::GetScriptContext(), WsfSimulationExtension::GetSimulation(), WsfScriptObserver::EventData::mCallbackPtr, WsfScriptObserver::EventData::mDefaultScriptName, WsfScriptObserver::EventData::mEnabled, WsfScriptObserver::EventData::mExpectedArgumentTypes, WsfScriptObserver::EventData::mScriptList, and ok.
| void WsfScriptObserver::EventEntry | ( | ) |
Perform initial processing upon entry into processing an event. All registered callback observers that issue output to the event stream should call this method prior to issuing any output for the event.
References WsfSimulationExtension::GetSimulation().
| void WsfScriptObserver::EventExit | ( | ) |
Perform final processing upon exit from processing an event. Registered callback observers that call EventEntry should call this method just prior to leaving the method.
References WsfSimulationExtension::GetSimulation().
| void WsfScriptObserver::ExecuteScriptList | ( | double | aSimTime, |
| const std::vector< UtScript * > & | aScriptList ) |
References ExecuteScriptList(), and WsfSimulationExtension::GetSimulation().
Referenced by AddEvent(), ExecuteScriptList(), ExecuteScriptList(), Initialize(), and Start().
| void WsfScriptObserver::ExecuteScriptList | ( | double | aSimTime, |
| const std::vector< UtScript * > & | aScriptList, | ||
| UtScriptData & | aScriptRetVal, | ||
| UtScriptDataList & | aScriptArgs ) |
References ExecuteScriptList(), and WsfSimulationExtension::GetSimulation().
|
static |
References WsfSimulation::FindExtension(), WsfScriptObserver(), and WsfSimulationExtension::WsfSimulation.
Referenced by wsf::cyber::SimulationExtension::AddedToSimulation(), WsfMilInterface::AddedToSimulation(), WsfBMHEFIRMOELogger::RegisterScriptObservers(), and WsfSpaceExtension::SimulationCreated().
| int WsfScriptObserver::GetEventIndex | ( | const std::string & | aEventName | ) | const |
Referenced by AddEvent(), EnableOrDisable(), Initialize(), and Start().
|
inline |
|
inline |
|
inline |
|
inline |
Referenced by AddEvent(), Initialize(), and Start().
|
overridevirtual |
Called in response to WsfSimulation::Initialize. This is called to allow the extension to perform any initialization that is required.
Reimplemented from WsfSimulationExtension.
References EnableOrDisable(), ExecuteScriptList(), GetEventIndex(), and GetScriptList().
Referenced by ~WsfScriptObserver().
|
overridevirtual |
Called in response to a call to WsfSimulation::Start. WsfSimulation::Start is typically called immediately before entry in the main event loop. The simulation is in its initial state, although the extension may also add additional platforms. using WsfSimulation::AddPlatform.
Reimplemented from WsfSimulationExtension.
References ExecuteScriptList(), GetEventIndex(), and GetScriptList().
Referenced by ~WsfScriptObserver().
|
protected |
Container to hold registered callbacks.