WSF
wsf::comm::ProtocolStack Class Reference

This class represents a communication devices protocol stack. More...

#include <WsfCommProtocolStack.hpp>

Collaboration diagram for wsf::comm::ProtocolStack:

Public Types

using LayerType = Layer::LayerType
using ProtocolVector = std::vector<std::unique_ptr<Layer>>
using RawProtocolVector = std::vector<Layer*>

Public Member Functions

 ProtocolStack ()=default
 Constructors and virtual destructor.
 ProtocolStack (const ProtocolStack &aSrc)
ProtocolStackoperator= (const ProtocolStack &aRhs)=delete
virtual ~ProtocolStack ()=default
LayerAddLayer (std::unique_ptr< Layer > aLayerPtr)
bool RemoveLayer (size_t aLayerIndex)
 Removes a layer at the indicated position.
bool RemoveLayerByID (size_t aLayerID)
 Removes a layer via unique ID.
std::unique_ptr< LayerReplaceLayer (size_t aLayerIndex, std::unique_ptr< Layer > aLayerPtr)
LayerInsertLayer (size_t aLayerIndex, std::unique_ptr< Layer > aLayerPtr)

Comm event methods.

ProtocolVector mProtocolStack {}
 Protocol stack for communication device.
CommmParent {nullptr}
 Pointer to the stack Parent.
virtual bool ProcessLayerMessage (double aSimTime, size_t aLayerIndex, layer::Message aLayerMessage, Message *aCommMessagePtr)
 Process a layer event.
void ValidateAdjacentLayers ()
 Reconciles upper/lower stack settings upon modifications.
ProtocolVector::iterator FindLayerByID (size_t aID)
 Wrapped helper methods for finding a layer by ID.
ProtocolVector::const_iterator FindLayerByID (size_t aID) const

Layer Retrieval Methods

LayerGetLayer (size_t aLayerIndex) const
 Returns a pointer to the layer at the indicated position.
LayerGetLayer (LayerType aLayerType) const
RawProtocolVector GetLayers (LayerType aLayerType) const
template<typename T>
T * GetLayer () const
 Template method for return of the first layer of the template object type.
template<typename T>
std::vector< T * > GetLayers () const
 Template method for return of all layers of the template type.
LayerGetLayerByID (size_t aLayerID) const
size_t Size () const
 Returns the number of layers in the stack.
void ClearLayers ()
 Removes all layers from the stack.

Common infrastructure methods.

virtual bool Initialize (double aSimTime)
virtual bool Initialize2 (double aSimTime)
virtual bool ProcessInput (UtInput &aInput)
void SetParent (Comm *aParentCommPtr)
CommGetParent () const
void SetDebugEnabled (bool aDebugEnabled)

Send/Receive methods

virtual bool Receive (double aSimTime, Comm *aXmtrPtr, Message &aMessage)
virtual bool Send (double aSimTime, Message &aMessage)

Detailed Description

This class represents a communication devices protocol stack.

Member Typedef Documentation

◆ LayerType

◆ ProtocolVector

using wsf::comm::ProtocolStack::ProtocolVector = std::vector<std::unique_ptr<Layer>>

◆ RawProtocolVector

Constructor & Destructor Documentation

◆ ProtocolStack() [1/2]

wsf::comm::ProtocolStack::ProtocolStack ( )
default

Constructors and virtual destructor.

References ProtocolStack().

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

◆ ProtocolStack() [2/2]

wsf::comm::ProtocolStack::ProtocolStack ( const ProtocolStack & aSrc)

◆ ~ProtocolStack()

virtual wsf::comm::ProtocolStack::~ProtocolStack ( )
virtualdefault

Member Function Documentation

◆ AddLayer()

Layer * wsf::comm::ProtocolStack::AddLayer ( std::unique_ptr< Layer > aLayerPtr)

Adds a layer at the top (end) of the stack. Returns a pointer to the added layer.

Adds the layer on the top of the stack. The stack takes ownership.

Parameters
aLayerPtr[input] A pointer to a communication protocol layer.
Note
Pointer must be non-null. Implementation does not support 'empty' or null layer.

References GetParent(), mProtocolStack, and wsf::comm::Layer::SetIndex().

Referenced by ~ProtocolStack().

◆ ClearLayers()

void wsf::comm::ProtocolStack::ClearLayers ( )
inline

Removes all layers from the stack.

References mProtocolStack.

◆ FindLayerByID() [1/2]

ProtocolStack::ProtocolVector::iterator wsf::comm::ProtocolStack::FindLayerByID ( size_t aID)
protected

Wrapped helper methods for finding a layer by ID.

References mProtocolStack.

Referenced by GetLayerByID(), and RemoveLayerByID().

◆ FindLayerByID() [2/2]

ProtocolStack::ProtocolVector::const_iterator wsf::comm::ProtocolStack::FindLayerByID ( size_t aID) const
protected

References mProtocolStack.

◆ GetLayer() [1/3]

template<typename T>
T * wsf::comm::ProtocolStack::GetLayer ( ) const
inline

Template method for return of the first layer of the template object type.

References mProtocolStack.

◆ GetLayer() [2/3]

Layer * wsf::comm::ProtocolStack::GetLayer ( LayerType aLayerType) const

References mProtocolStack.

◆ GetLayer() [3/3]

Layer * wsf::comm::ProtocolStack::GetLayer ( size_t aLayerIndex) const

Returns a pointer to the layer at the indicated position.

Parameters
aLayerIndex[input] The index of the layer to return.
Returns
A pointer to the layer at the provided index.

References mProtocolStack.

Referenced by WsfJTIDS_Terminal::Initialize(), wsf::comm::LASER_XmtrRcvr::LASER_XmtrRcvr(), wsf::comm::NetworkLayer::ProcessLayerMessage(), WsfJTIDS_Terminal::TurnOff(), and ~ProtocolStack().

◆ GetLayerByID()

Layer * wsf::comm::ProtocolStack::GetLayerByID ( size_t aLayerID) const

References FindLayerByID(), and mProtocolStack.

◆ GetLayers() [1/2]

template<typename T>
std::vector< T * > wsf::comm::ProtocolStack::GetLayers ( ) const
inline

Template method for return of all layers of the template type.

References mProtocolStack.

◆ GetLayers() [2/2]

ProtocolStack::RawProtocolVector wsf::comm::ProtocolStack::GetLayers ( LayerType aLayerType) const

References mProtocolStack.

Referenced by ~ProtocolStack().

◆ GetParent()

Comm * wsf::comm::ProtocolStack::GetParent ( ) const
inline

References mParent.

Referenced by AddLayer(), Send(), and ValidateAdjacentLayers().

◆ Initialize()

bool wsf::comm::ProtocolStack::Initialize ( double aSimTime)
virtual

Initializes the layers in the protocol stack.

Parameters
aSimTime[input] The current simulation time.
Returns
'true' if all layers are successfully initialized or 'false' if any one layer failed initialization.

References mProtocolStack, and ok.

◆ Initialize2()

bool wsf::comm::ProtocolStack::Initialize2 ( double aSimTime)
virtual

Initializes the layers in the protocol stack.

Parameters
aSimTime[input] The current simulation time.
Returns
'true' if all layers are successfully initialized or 'false' if any one layer failed initialization.

References mProtocolStack, and ok.

◆ InsertLayer()

Layer * wsf::comm::ProtocolStack::InsertLayer ( size_t aLayerIndex,
std::unique_ptr< Layer > aLayerPtr )

Inserts a layer at the indicated position. Returns a pointer to inserted layer, or a nullptr upon failure.

References mProtocolStack, and ValidateAdjacentLayers().

Referenced by ~ProtocolStack().

◆ operator=()

ProtocolStack & wsf::comm::ProtocolStack::operator= ( const ProtocolStack & aRhs)
delete

References ProtocolStack().

◆ ProcessInput()

bool wsf::comm::ProtocolStack::ProcessInput ( UtInput & aInput)
virtual

References mProtocolStack.

◆ ProcessLayerMessage()

bool wsf::comm::ProtocolStack::ProcessLayerMessage ( double aSimTime,
size_t aLayerIndex,
layer::Message aLayerMessage,
Message * aCommMessagePtr )
virtual

Process a layer event.

References mProtocolStack.

◆ Receive()

bool wsf::comm::ProtocolStack::Receive ( double aSimTime,
Comm * aXmtrPtr,
Message & aMessage )
virtual

Called from the communication device on receipt of a communication message.

Parameters
aSimTime[input] The current simulation time.
aXmtrPtr{input] The comm device that sent the message.
aMessage[input] The communication message being received.
Returns
'true' if protocol stack successfully processed the message.

References mProtocolStack.

◆ RemoveLayer()

bool wsf::comm::ProtocolStack::RemoveLayer ( size_t aLayerIndex)

Removes a layer at the indicated position.

References mProtocolStack, and ValidateAdjacentLayers().

Referenced by ~ProtocolStack().

◆ RemoveLayerByID()

bool wsf::comm::ProtocolStack::RemoveLayerByID ( size_t aLayerID)

Removes a layer via unique ID.

References FindLayerByID(), mProtocolStack, and ValidateAdjacentLayers().

Referenced by ~ProtocolStack().

◆ ReplaceLayer()

std::unique_ptr< Layer > wsf::comm::ProtocolStack::ReplaceLayer ( size_t aLayerIndex,
std::unique_ptr< Layer > aLayerPtr )

Replaces a layer with the provided layer. The replaced layer is returned for potential further usage.

Replace a layer and returns the layer being removed.

Parameters
aLayerIndex[input] The index of the layer to replace.
aLayerPtr[input] A pointer to the new communication protocol layer.
Returns
A pointer to the layer being removed. It is left to the caller to delete.

References mProtocolStack, and ValidateAdjacentLayers().

Referenced by ~ProtocolStack().

◆ Send()

bool wsf::comm::ProtocolStack::Send ( double aSimTime,
Message & aMessage )
virtual

Called by the communication device to send a communication message.

Parameters
aSimTime[input] The current simulation time.
aMessage[input] The communication message being received.
Returns
'true' if protocol stack successfully processed the message.

Set the required fields for the message. We don't leave this up to the specific implementations of comm objects due to being required across all comm objects. In addition, this avoids having to query the network manager within the implementations.

References GetParent(), mProtocolStack, and wsf::comm::Message::SourceMessage().

◆ SetDebugEnabled()

void wsf::comm::ProtocolStack::SetDebugEnabled ( bool aDebugEnabled)

References mProtocolStack.

◆ SetParent()

void wsf::comm::ProtocolStack::SetParent ( Comm * aParentCommPtr)

Provides each layer with a pointer to the parent communication device.

Parameters
aParentCommPtr[input] A pointer to the communication device that owns this stack.
Note
Pointer must be non-null. Implementation does not support 'empty' or null pointer.

References mParent, and mProtocolStack.

◆ Size()

size_t wsf::comm::ProtocolStack::Size ( ) const
inline

Returns the number of layers in the stack.

References mProtocolStack.

◆ ValidateAdjacentLayers()

void wsf::comm::ProtocolStack::ValidateAdjacentLayers ( )
protected

Reconciles upper/lower stack settings upon modifications.

References GetParent(), and mProtocolStack.

Referenced by InsertLayer(), RemoveLayer(), RemoveLayerByID(), and ReplaceLayer().

Member Data Documentation

◆ mParent

Comm* wsf::comm::ProtocolStack::mParent {nullptr}
protected

Pointer to the stack Parent.

Referenced by GetParent(), ProtocolStack(), and SetParent().

◆ mProtocolStack


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