WSF
WsfCommLayer.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2017 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFCOMMLAYER_HPP
13#define WSFCOMMLAYER_HPP
14
15#include "wsf_export.h"
16
17#include <vector>
18
20#include "WsfUniqueId.hpp"
21
22// Forward Declarations
23class UtInput;
24class WsfPlatform;
25
26namespace wsf
27{
28namespace comm
29{
30
31class Comm;
32class LayerImp;
33class Message;
34
40{
41public:
44 enum class LayerType : size_t
45 {
46 cPHYSICAL,
47 cDATALINK,
48 cNETWORK,
49 cTRANSPORT,
50 cSESSION,
51 cPRESENTATION,
52 cAPPLICATION,
53 cNONE
54 };
55
56 // Constructor and destructor
57 Layer(Layer::LayerType aCommLayerType, LayerImp* aCommLayerImpPtr);
58 virtual ~Layer();
59
61
62 virtual Layer* Clone() const;
63 virtual bool Initialize(double aSimTime);
64 virtual bool Initialize2(double aSimTime);
65 virtual bool ProcessInput(UtInput& aInput);
67
69
70 virtual bool Receive(double aSimTime, Comm* aXmtrPtr, Message& aMessage);
71 virtual bool Send(double aSimTime, Message& aMessage);
73
75
76 virtual bool ProcessLayerMessage(double aSimTime, layer::Message aLayerMessage, Message* aCommMessagePtr);
78
80
81 Comm* Parent() const;
82 void SetParent(Comm* aParentCommPtr);
84
85 void SetDebugEnabled(bool aDebugEnabled);
86
87 LayerType GetLayerType() const { return mCommLayerType; }
88
91 void SetID(WsfSimulation& aSim);
92
96 void SetUpperLayer(Layer* aLayerPtr);
97 void SetLowerLayer(Layer* aLayerPtr);
98 void SetIndex(size_t aIndex);
99 Layer* GetUpperLayer() const { return mUpperCommLayerPtr; }
100 Layer* GetLowerLayer() const { return mLowerCommLayerPtr; }
101
102
103 // Access to implementation
104 LayerImp* GetCommLayerImp();
105
106protected:
107 // Copy constructor
108 Layer(const Layer& aSrc);
109
110private:
112 Layer& operator=(const Layer& aRhs) = delete;
113
114 // Pointer to the layer implementation (Implementor)
115 LayerImp* mCommLayerImpPtr;
116
117 LayerType mCommLayerType; // OSI layer type
118 size_t mCommLayerIndex; // Layer index is 0-based
119
120 Layer* mUpperCommLayerPtr; // Pointer to the layer above, if it exists
121 Layer* mLowerCommLayerPtr; // Pointer to the layer below, if it exists
122};
123
124// ****************************************************************************
127{
128public:
129 virtual ~LayerImp() = default;
130
132
133 virtual LayerImp* Clone() const = 0;
134 virtual bool Initialize(double aSimTime) = 0;
135 virtual bool Initialize2(double aSimTime) { return true; }
136 virtual bool ProcessInput(UtInput& aInput) = 0;
138
145 virtual bool Receive(double aSimTime, Comm* aXmtrPtr, Message& aMessage, bool& aNotifyNextLayer) = 0;
146
153 virtual bool Send(double aSimTime, size_t aLayerIndex, Message& aMessage, bool& aNotifyNextLayer) = 0;
154
159 virtual bool ProcessLayerMessage(double aSimTime, layer::Message aLayerMessage, Message* aCommMessagePtr) = 0;
160
162
163 Comm* Parent() const;
164 void SetParent(Comm* aParentCommPtr);
166
169 void SetIndex(size_t aIndex) { mIndex = aIndex; }
170 size_t GetIndex() const { return mIndex; }
171
174 void SetUpperLayer(Layer* aLayerPtr) { mUpperCommLayerPtr = aLayerPtr; }
175 Layer* GetUpperLayer() const { return mUpperCommLayerPtr; }
176 void SetLowerLayer(Layer* aLayerPtr) { mLowerCommLayerPtr = aLayerPtr; }
177 Layer* GetLowerLayer() const { return mLowerCommLayerPtr; }
178
180 bool DebugEnabled() const { return mDebugEnabled; }
181
184 void SetDebugEnabled(bool aDebugEnabled) { mDebugEnabled = aDebugEnabled; }
186
187private:
188 Comm* mParentCommPtr{nullptr}; // Pointer back to the owning communications device
189 bool mDebugEnabled{false};
190 size_t mIndex;
191 Layer* mUpperCommLayerPtr{nullptr};
192 Layer* mLowerCommLayerPtr{nullptr};
193};
194
195} // namespace comm
196} // namespace wsf
197
198#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
The main controller for a simulation.
Definition WsfSimulation.hpp:109
WsfUniqueId()
Construtor initializes the unique identifier to 0.
Definition WsfUniqueId.hpp:38
Definition WsfComm.hpp:43
A base class defining the interface for the implementation classes. (Implementor).
Definition WsfCommLayer.hpp:127
virtual bool Initialize(double aSimTime)=0
void SetIndex(size_t aIndex)
Definition WsfCommLayer.hpp:169
void SetDebugEnabled(bool aDebugEnabled)
Definition WsfCommLayer.hpp:184
virtual bool Receive(double aSimTime, Comm *aXmtrPtr, Message &aMessage, bool &aNotifyNextLayer)=0
Comm * Parent() const
Definition WsfCommLayer.cpp:193
virtual bool Initialize2(double aSimTime)
Definition WsfCommLayer.hpp:135
void SetParent(Comm *aParentCommPtr)
Definition WsfCommLayer.cpp:199
virtual ~LayerImp()=default
virtual bool ProcessLayerMessage(double aSimTime, layer::Message aLayerMessage, Message *aCommMessagePtr)=0
Layer * GetLowerLayer() const
Definition WsfCommLayer.hpp:177
virtual bool ProcessInput(UtInput &aInput)=0
void SetLowerLayer(Layer *aLayerPtr)
Definition WsfCommLayer.hpp:176
virtual bool Send(double aSimTime, size_t aLayerIndex, Message &aMessage, bool &aNotifyNextLayer)=0
bool DebugEnabled() const
Determine if debugging is enabled.
Definition WsfCommLayer.hpp:180
virtual LayerImp * Clone() const =0
void SetUpperLayer(Layer *aLayerPtr)
Definition WsfCommLayer.hpp:174
Layer * GetUpperLayer() const
Definition WsfCommLayer.hpp:175
size_t GetIndex() const
Definition WsfCommLayer.hpp:170
Definition WsfCommLayer.hpp:40
LayerType GetLayerType() const
Definition WsfCommLayer.hpp:87
Layer * GetUpperLayer() const
Definition WsfCommLayer.hpp:99
Layer * GetLowerLayer() const
Definition WsfCommLayer.hpp:100
Layer(Layer::LayerType aCommLayerType, LayerImp *aCommLayerImpPtr)
Definition WsfCommLayer.cpp:29
LayerType
Definition WsfCommLayer.hpp:45
Definition WsfCommMessage.hpp:51
Definition WsfCommLayerMessage.hpp:36
Definition WsfComm.cpp:34
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved