WSF
wsf::comm::medium::Medium Class Referenceabstract

#include <WsfCommMedium.hpp>

Inheritance diagram for wsf::comm::medium::Medium:
Collaboration diagram for wsf::comm::medium::Medium:

Public Types

using ModeIt = std::vector<std::unique_ptr<Mode>>::iterator
using const_ModeIt = std::vector<std::unique_ptr<Mode>>::const_iterator
Public Types inherited from WsfObject
typedef std::vector< WsfStringIdTypeList
 The list of types returned by GetTypeList.

Public Member Functions

 Medium (WsfScenario &aScenario)
 ~Medium () override=default
 Medium (const Medium &aSrc)
Mediumoperator= (Medium &aRhs)
const char * GetScriptClassName () const override
MediumClone () const override=0
bool ProcessInput (UtInput &aInput) override
virtual bool Initialize (double aSimTime)
void SetSimulation (WsfSimulation *aSimPtr)
WsfSimulationGetSimulation () const
Public Member Functions inherited from WsfObject
 WsfObject ()
 This is the constructor for the WsfObject class.
 ~WsfObject () override
 This is the destructor for the WsfObject class.
const char * GetScriptClassName () const override
const std::string & GetType () const
WsfStringId GetTypeId () const
 Get the string ID of the 'type' of the object.
void SetType (WsfStringId aType)
const std::string & GetBaseType () const
WsfStringId GetBaseTypeId () const
const TypeListGetTypeList () const
bool IsA_TypeOf (WsfStringId aType) const
WsfObjectoperator= (const WsfObject &aRhs)
 Assignment operator.
template<typename T>
void Serialize (T &aBuff)
 For XIO (de)serialization.
const std::string & GetName () const
WsfStringId GetNameId () const
void SetName (WsfStringId aName)

Transmission and Propagation Methods

These methods handle the initiation and termination of transmission and propagation of a message/data/signal. They are required for correct implementation of medium types.

std::unordered_map< Message::Identifier, MessageStatusmMessages {}
std::vector< ut::CloneablePtr< Mode > > mModes {}
bool mShared {false}
bool mDebug {false}
 Debug flag.
std::shared_ptr< int > mEventPtr {nullptr}
virtual TransmissionResult TransmitMessage (double aSimTime, Layer *aLayerPtr, Message &aMessage, Comm &aXmtr)=0
virtual void EndTransmission (double aSimTime, const Message::Identifier &aIdentifier)=0
virtual void PropagateMessage (double aSimTime, const Message::Identifier &aIdentifier)=0
virtual void EndPropagation (double aSimTime, const Message::Identifier &aIdentifier)=0
virtual TypeIdentifier GetMediumIdentifier () const =0
size_t GetNumModes () const
size_t GetCurrentModeIndex () const
std::pair< size_t, bool > GetModeIndex (const std::string &aModeName) const
size_t GetNumChannels () const
const std::string & GetActiveModeName () const
bool IsMediumShared () const
bool UserDirectedSharing () const
size_t GetCurrentTransmissions () const
size_t GetNumMessageStatuses () const
bool SetActiveMode (const std::string &aModeName)
bool SetActiveMode (size_t aIndex)
void SetActiveModeDelayed (const std::string &aModeName)
void SetActiveModeDelayed (size_t aIndex)
void SetIsShared (bool aIsShared)
MessageStatusGetMessageStatus (const Message::Identifier &aIdentifier)
MessageStatusGetMessageStatusByIndex (size_t aIndex)
virtual std::unique_ptr< ModeCreateDefaultMode () const =0
ModeGetMode (const std::string &aModeName) const
ModeGetMode (size_t aModeIndex) const
std::string ExecuteModeOnTransmit (double aSimTime, const Message &aMessage, const Comm &aXmtr, const Comm &aRcvr)
void RemoveMessageStatus (const Message::Identifier &aIdentifier)
void SetNumChannels (size_t aNumChannels)
ModeGetModeForTransmission (double aSimTime, Comm &aXmtr, Comm &aRcvr, Message &aMessage)

Additional Inherited Members

 WsfObject (const WsfObject &aSrc)
 Copy constructor (for Clone()).

Detailed Description

The medium class is an interface for a generic object used to determine the capability, capacity, and duration of messages being passed between comm objects. It may handle one or more messages simultaneously (multiplex), and may have multiple defined Modes to change the behavior of the medium.

A single medium is associated with a utilizing object. However, multiple objects may share a medium, s.t. all users of the medium use the same object to facilitate message propagation.

Member Typedef Documentation

◆ const_ModeIt

using wsf::comm::medium::Medium::const_ModeIt = std::vector<std::unique_ptr<Mode>>::const_iterator

◆ ModeIt

using wsf::comm::medium::Medium::ModeIt = std::vector<std::unique_ptr<Mode>>::iterator

Constructor & Destructor Documentation

◆ Medium() [1/2]

wsf::comm::medium::Medium::Medium ( WsfScenario & aScenario)

◆ ~Medium()

wsf::comm::medium::Medium::~Medium ( )
overridedefault

References Medium(), and operator=().

◆ Medium() [2/2]

wsf::comm::medium::Medium::Medium ( const Medium & aSrc)

Member Function Documentation

◆ Clone()

Medium * wsf::comm::medium::Medium::Clone ( ) const
overridepure virtual

Return a copy of this object. Must be implemented by all derived types. If cloning is impossible, a WsfUncloneableException should be thrown.

Implements WsfObject.

Implemented in wsf::comm::medium::Guided, and wsf::comm::medium::Unguided.

References Initialize(), Medium(), and ProcessInput().

◆ CreateDefaultMode()

virtual std::unique_ptr< Mode > wsf::comm::medium::Medium::CreateDefaultMode ( ) const
pure virtual

Returns a default constructed mode of the type associated with this medium implementation.

Implemented in wsf::comm::medium::Guided, and wsf::comm::medium::Unguided.

References ExecuteModeOnTransmit(), GetMode(), and RemoveMessageStatus().

Referenced by ProcessInput().

◆ EndPropagation()

virtual void wsf::comm::medium::Medium::EndPropagation ( double aSimTime,
const Message::Identifier & aIdentifier )
pure virtual

Implemented in wsf::comm::medium::Guided.

◆ EndTransmission()

virtual void wsf::comm::medium::Medium::EndTransmission ( double aSimTime,
const Message::Identifier & aIdentifier )
pure virtual

◆ ExecuteModeOnTransmit()

std::string wsf::comm::medium::Medium::ExecuteModeOnTransmit ( double aSimTime,
const Message & aMessage,
const Comm & aXmtr,
const Comm & aRcvr )

Optional user defined script method overload for mode selection at the time of transmission.

Referenced by CreateDefaultMode(), and GetModeForTransmission().

◆ GetActiveModeName()

const std::string & wsf::comm::medium::Medium::GetActiveModeName ( ) const

References mModes.

Referenced by GetModeForTransmission().

◆ GetCurrentModeIndex()

size_t wsf::comm::medium::Medium::GetCurrentModeIndex ( ) const
inline

◆ GetCurrentTransmissions()

size_t wsf::comm::medium::Medium::GetCurrentTransmissions ( ) const

◆ GetMediumIdentifier()

virtual TypeIdentifier wsf::comm::medium::Medium::GetMediumIdentifier ( ) const
pure virtual

◆ GetMessageStatus()

MessageStatus * wsf::comm::medium::Medium::GetMessageStatus ( const Message::Identifier & aIdentifier)

Gets a currently handled message and its status by provision of the message serial number or by index.

References mMessages.

Referenced by wsf::comm::medium::Guided::EndPropagation(), wsf::comm::medium::Guided::EndTransmission(), and wsf::comm::medium::Guided::PropagateMessage().

◆ GetMessageStatusByIndex()

MessageStatus * wsf::comm::medium::Medium::GetMessageStatusByIndex ( size_t aIndex)

References mMessages.

◆ GetMode() [1/2]

Mode * wsf::comm::medium::Medium::GetMode ( const std::string & aModeName) const

◆ GetMode() [2/2]

Mode * wsf::comm::medium::Medium::GetMode ( size_t aModeIndex) const

References mModes.

◆ GetModeForTransmission()

Mode * wsf::comm::medium::Medium::GetModeForTransmission ( double aSimTime,
Comm & aXmtr,
Comm & aRcvr,
Message & aMessage )
protected

Returns the mode to be used with a message transmission, either by getting the currently active mode, or from a user defined script method overload.

References ExecuteModeOnTransmit(), GetActiveModeName(), and GetMode().

Referenced by wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().

◆ GetModeIndex()

std::pair< size_t, bool > wsf::comm::medium::Medium::GetModeIndex ( const std::string & aModeName) const

◆ GetNumChannels()

size_t wsf::comm::medium::Medium::GetNumChannels ( ) const
inline

◆ GetNumMessageStatuses()

size_t wsf::comm::medium::Medium::GetNumMessageStatuses ( ) const
inline

References mMessages.

◆ GetNumModes()

size_t wsf::comm::medium::Medium::GetNumModes ( ) const
inline

References mModes.

◆ GetScriptClassName()

const char * wsf::comm::medium::Medium::GetScriptClassName ( ) const
inlineoverride

◆ GetSimulation()

◆ Initialize()

bool wsf::comm::medium::Medium::Initialize ( double aSimTime)
virtual

◆ IsMediumShared()

bool wsf::comm::medium::Medium::IsMediumShared ( ) const
inline

References mShared.

◆ operator=()

Medium & wsf::comm::medium::Medium::operator= ( Medium & aRhs)

◆ ProcessInput()

bool wsf::comm::medium::Medium::ProcessInput ( UtInput & aInput)
overridevirtual

Process input from a generic source.

Examine the current input command. If it is NOT one of the commands recognized by this class then it simply returns 'false'. If it is one of the commands recognized by this class then it processes the command and returns 'true'.

Parameters
aInputa reference to a UtInput object.
Returns
'true' if the command was one recognized by the class or 'false' if not.
Exceptions
UtInput::ExceptionBase(or an object derived from it) if the command was recognized but contains some sort of error.
Note
If a derived class does not recognize the command (i.e.: the return value is false) then it should call the base class ProcessInput method. This chain should continue until either the command is recognized or the top-level base class is encountered.

Reimplemented from WsfObject.

Reimplemented in wsf::comm::medium::Unguided.

References CreateDefaultMode(), GetMode(), WsfObject::GetType(), mDebug, mModes, ProcessInput(), WsfObject::ProcessInput(), and SetNumChannels().

Referenced by Clone(), wsf::comm::medium::Guided::ProcessInput(), and ProcessInput().

◆ PropagateMessage()

virtual void wsf::comm::medium::Medium::PropagateMessage ( double aSimTime,
const Message::Identifier & aIdentifier )
pure virtual

Implemented in wsf::comm::medium::Guided.

◆ RemoveMessageStatus()

void wsf::comm::medium::Medium::RemoveMessageStatus ( const Message::Identifier & aIdentifier)
protected

◆ SetActiveMode() [1/2]

bool wsf::comm::medium::Medium::SetActiveMode ( const std::string & aModeName)

Mode Set Methods These methods change the current active mode of the medium. The SetActiveMode methods execute immediately, where the delayed versions execute via simulation event scheduling. The delayed calls allow processing the order of calls also delayed by event scheduling (such as call to send a message), where multiple calls to change the mode in a single time frame with the non-delayed methods would just result in the last called method being applied (as multiple calls would resolve prior to a non-scheduled event).

References mModes.

Referenced by Initialize(), SetActiveModeDelayed(), and SetActiveModeDelayed().

◆ SetActiveMode() [2/2]

bool wsf::comm::medium::Medium::SetActiveMode ( size_t aIndex)

References mModes.

◆ SetActiveModeDelayed() [1/2]

void wsf::comm::medium::Medium::SetActiveModeDelayed ( const std::string & aModeName)

◆ SetActiveModeDelayed() [2/2]

void wsf::comm::medium::Medium::SetActiveModeDelayed ( size_t aIndex)

◆ SetIsShared()

void wsf::comm::medium::Medium::SetIsShared ( bool aIsShared)
inline

References mShared.

◆ SetNumChannels()

void wsf::comm::medium::Medium::SetNumChannels ( size_t aNumChannels)
inlineprotected

Referenced by ProcessInput().

◆ SetSimulation()

void wsf::comm::medium::Medium::SetSimulation ( WsfSimulation * aSimPtr)
inline

◆ TransmitMessage()

virtual TransmissionResult wsf::comm::medium::Medium::TransmitMessage ( double aSimTime,
Layer * aLayerPtr,
Message & aMessage,
Comm & aXmtr )
pure virtual

◆ UserDirectedSharing()

bool wsf::comm::medium::Medium::UserDirectedSharing ( ) const
inline

Member Data Documentation

◆ mDebug

◆ mEventPtr

std::shared_ptr<int> wsf::comm::medium::Medium::mEventPtr {nullptr}
protected

A shared pointer for correct termination of events when the owning medium is removed from the simulation prior to event execution, using wsf::comm::GenericEvent.

Referenced by Medium(), operator=(), wsf::comm::medium::Guided::PropagateMessage(), SetActiveModeDelayed(), SetActiveModeDelayed(), wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().

◆ mMessages

std::unordered_map<Message::Identifier, MessageStatus> wsf::comm::medium::Medium::mMessages {}
protected

This container holds all messages currently being handled by this medium, along with their status and relevant bookkeeping.

Note
A message indicated to abort must be set before the delivery event.
This object is not retained after any delivery event, regardless if indicated to actually deliver the message or not. As such, any message retained by the medium is assumed to be actively propagating.

Referenced by GetCurrentTransmissions(), GetMessageStatus(), GetMessageStatusByIndex(), GetNumMessageStatuses(), RemoveMessageStatus(), wsf::comm::medium::Guided::TransmitMessage(), and wsf::comm::medium::Unguided::TransmitMessage().

◆ mModes

std::vector<ut::CloneablePtr<Mode> > wsf::comm::medium::Medium::mModes {}
protected

The modes associated with this medium. The base class adds the base Mode object as the "default" mode. Pointers are used for potential polymorphism of the Mode object.

Referenced by GetActiveModeName(), GetMode(), GetMode(), GetModeIndex(), GetNumModes(), wsf::comm::medium::Guided::Guided(), Initialize(), Medium(), operator=(), ProcessInput(), SetActiveMode(), SetActiveMode(), and wsf::comm::medium::Unguided::Unguided().

◆ mShared

bool wsf::comm::medium::Medium::mShared {false}
protected

This is a special flag for indicating the origin of this medium. When set to true, it indicates the medium is of a type that was explicitly added to its owner based on user input (such as "add medium"), and can potentially be shared among multiple containers. If set to false, it indicates this medium is added as a default instance, and unique to this container.

This is necessary in order to support legacy input, and to provide useful feedback to users to avoid confusion when providing input at varying scopes for medium usage.

Referenced by IsMediumShared(), Medium(), operator=(), and SetIsShared().


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