WSF
wsf::event::output::SimulationExtension Class Referenceabstract

A simulation extension that serves as an abstract base class for observers which write an event output file. More...

#include <WsfEventOutputBase.hpp>

Inheritance diagram for wsf::event::output::SimulationExtension:
Collaboration diagram for wsf::event::output::SimulationExtension:

Classes

class  EventGuard

Public Member Functions

 SimulationExtension (Data &aData)
bool PrepareExtension () override
virtual void OnSimulationComplete (double aSimTime)
bool OpenFile (const std::string &aFileName)
const std::string & GetFileName () const
 Returns the name of the file in which the events are output.
std::ostream & StreamRef () const
bool IsEnabled (const std::string &aEventName) const
void AddEvent (const std::string &aEventName, std::unique_ptr< UtCallback > aCallbackPtr)
template<typename RESULT, typename... Args>
void AddEvent (const std::string &aEventName, UtCallbackListN< void(Args...)> &aObserver)
void AddEventAlias (const std::string &aAliasEventName, const std::string &aCurrentEventName)
bool EnableOrDisableEvent (const std::string &aEventName, bool aEnable)
void RegisterMessagePrinter (WsfStringId aMessageType, const Settings::MessagePrintFunction &aFunction)
SettingsGetSettings ()
virtual void PrintEvent (const Result &aResult) const =0
 Print an event result in the desired format. Must be implemented by derived classes.
Public Member Functions inherited from WsfSimulationExtension
 WsfSimulationExtension ()
 ~WsfSimulationExtension () override=default
WsfSimulationGetSimulation () const
const WsfScenarioGetScenario () const
virtual bool Initialize ()
virtual bool PlatformsInitialized ()
virtual void PendingStart ()
virtual void Start ()
virtual void Complete (double aSimTime)
Public Member Functions inherited from WsfExtension
virtual ~WsfExtension ()=default
const std::string & GetExtensionName () const

Additional Inherited Members

static void __private_SetSim (WsfSimulationExtension &aExtension, WsfSimulation *aSimPtr)
Protected Member Functions inherited from WsfExtension
void InitializeExtensionName (const std::string &aName)

Detailed Description

A simulation extension that serves as an abstract base class for observers which write an event output file.

Constructor & Destructor Documentation

◆ SimulationExtension()

wsf::event::output::SimulationExtension::SimulationExtension ( Data & aData)
inline

Member Function Documentation

◆ AddEvent() [1/2]

void wsf::event::output::SimulationExtension::AddEvent ( const std::string & aEventName,
std::unique_ptr< UtCallback > aCallbackPtr )

Adds a new output event.

Parameters
aEventNameThe name of the event. This name is used to reference the event in the input file.
aCallbackPtrA callback that is already connected to the event source. UtCallback::Block() will be called if the event is disabled.

Referenced by wsf::altloc::SimulationExtension::AddedToSimulation(), and AddEvent().

◆ AddEvent() [2/2]

template<typename RESULT, typename... Args>
void wsf::event::output::SimulationExtension::AddEvent ( const std::string & aEventName,
UtCallbackListN< void(Args...)> & aObserver )
inline

Register an event that will be produced upon invocation of the specified Observer

Template Parameters
RESULTis the subclass of wsf::event::Result which will be printed
Argsare types passed by the Observer, which should be deduced from the aObserver argument
Parameters
aEventNameis the name of the event as it will appear in the output
aObserveris the Observer whose invocation will trigger this event

References AddEvent().

◆ AddEventAlias()

void wsf::event::output::SimulationExtension::AddEventAlias ( const std::string & aAliasEventName,
const std::string & aCurrentEventName )

Adds an alternative name for an event. The new name is usable from the input file.

Parameters
aAliasEventNameThe new event alias name.
aCurrentEventNameThe name of the existing event to be aliased.

◆ EnableOrDisableEvent()

bool wsf::event::output::SimulationExtension::EnableOrDisableEvent ( const std::string & aEventName,
bool aEnable )

References ok.

Referenced by PrepareExtension().

◆ GetFileName()

const std::string & wsf::event::output::SimulationExtension::GetFileName ( ) const
inline

Returns the name of the file in which the events are output.

Referenced by engage::SimulationExtension::Initialize().

◆ GetSettings()

Settings & wsf::event::output::SimulationExtension::GetSettings ( )
inline

◆ IsEnabled()

bool wsf::event::output::SimulationExtension::IsEnabled ( const std::string & aEventName) const

◆ OnSimulationComplete()

virtual void wsf::event::output::SimulationExtension::OnSimulationComplete ( double aSimTime)
inlinevirtual

Derived classes can override this method to be notified when the 'SimulationComplete' event is fired, but before EventOutput shuts down (i.e. closes its output stream).

◆ OpenFile()

bool wsf::event::output::SimulationExtension::OpenFile ( const std::string & aFileName)

◆ PrepareExtension()

bool wsf::event::output::SimulationExtension::PrepareExtension ( )
overridevirtual

Called in response to a call to WsfSimulation::Initialize and WsfSimulation::PrepareSimulation.

A simulation extension will typically implement either WsfSimulationExtension::Initialize or WsfSimulationExtension::PrepareExtension, or a combination of both. The main difference is that:

  • WsfSimulationExtension::Initialize is called only when a simulation is initialized after being loaded from input files (the normal mode of operation).
  • WsfSimulation::PrepareExecution is called in the former case AND when a simulation is reloaded from a snapshot.

The primary criteria for deciding which method to use is to look at the extension and see if it uses any external resources such as files or sockets. If the extension uses external resources and wants to support snapshotting then it MUST use this this method so it can (re)establish connections to external resources (A snapshot cannot save the state of an open file or socket and so it must be reopened.)

Reimplemented from WsfSimulationExtension.

References EnableOrDisableEvent(), WsfExtension::GetExtensionName(), ok, and OpenFile().

◆ PrintEvent()

virtual void wsf::event::output::SimulationExtension::PrintEvent ( const Result & aResult) const
pure virtual

Print an event result in the desired format. Must be implemented by derived classes.

◆ RegisterMessagePrinter()

void wsf::event::output::SimulationExtension::RegisterMessagePrinter ( WsfStringId aMessageType,
const Settings::MessagePrintFunction & aFunction )

◆ StreamRef()

std::ostream & wsf::event::output::SimulationExtension::StreamRef ( ) const
inline

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