12#ifndef WSFXIO_INTERFACE_HPP
13#define WSFXIO_INTERFACE_HPP
15#include "wsf_export.h"
23#include "GenInternetSocketAddress.hpp"
24#include "GenUniqueId.hpp"
25#include "PakConnection.hpp"
26#include "PakProcessor.hpp"
28class PakTCP_Connector;
30#include "PakThreadedIO.hpp"
31#include "UtCallback.hpp"
32#include "UtCallbackHolder.hpp"
33#include "UtWallClock.hpp"
81 void AdvanceTime(
double aSimTime);
86 double GetSimTime()
const {
return mClockSourcePtr->GetSimTime(); }
88 void SetClockSource(ClockSource* aClockSourcePtr);
97 void Send(
WsfXIO_Packet& aPktPtr,
const std::vector<PakSocketIO*>& aConnections);
130 std::unique_ptr<UtCallbackN<void()>>
TimeoutConnect(
double aWaitTime,
const std::function<
void()>& aFunction);
133 const ConnectionCallback::FunctionType& aFunction);
148 void RegisterServiceType(std::string aServiceType, std::string aServiceVersion = std::string());
153 void AddUDP_Target(UDP_Target aTarget);
154 bool RemoveUDP_Target(
int aTargetIndex);
180 void GetBytesCommunicated(
size_t& aBytesSent,
size_t& aBytesReceived);
184 void SendHeartbeat();
194 void ProcessMessages(
double aSimTime);
196 bool ProcessSynchronizedPacket(
double aSimTime,
WsfXIO_Packet& aPkt);
198 void TriggerTimeouts();
206 void AcceptConnections();
208 void HandleDisconnect(PakSocketIO* aIOPtr, PakConnection* aConnectionPtr);
210 bool ConnectToTarget(UDP_Target& aTarget);
214 UtCallbackListN<void()>* mCallbackListPtr;
216 bool operator<(
const Timeout& aRHS)
const {
return mTime < aRHS.mTime; }
221 HeartbeatInfo(GenUniqueId aId)
225 bool operator<(
const HeartbeatInfo& aInfo)
const {
return mUniqueId < aInfo.mUniqueId; }
226 GenUniqueId mUniqueId;
227 WsfXIO_Connection* mConnectionPtr;
230 using TimeoutQueue = std::priority_queue<Timeout>;
232 using AddrPort = std::pair<unsigned int, short>;
233 using ConnectionCallbackMap = std::map<WsfXIO_Connection*, UtCallbackListN<void(WsfXIO_Connection*)>*>;
234 using PendingConnectionInfo = std::pair<GenSockets::GenInternetSocketAddress, WsfXIO_Connection*>;
235 using SenderConnectionMap = std::map<SenderAddress, WsfXIO_Connection*>;
236 using ConnectionIdMap = std::map<int, WsfXIO_Connection*>;
237 using PacketBuffer = std::deque<WsfXIO_Packet*>;
239 UtCallbackHolder mCallbacks;
241 GenUniqueId mApplicationId;
244 ClockSource* mClockSourcePtr;
245 WsfXIO_UDP_Header* mUDP_HeaderPtr;
246 WsfXIO_RequestManager* mRequestManagerPtr;
247 WsfXIO_QueryManager* mQueryManagerPtr;
248 WsfXIO_Publisher* mPublisherPtr;
249 PakTCP_Connector* mConnectorPtr;
251 TimeoutQueue mTimeouts;
255 double mLastAdvanceTime;
260 double mPreviousHeartbeatTime;
261 double mPreviousConnectionUpdateTime;
262 double mConnectionUpdateInterval;
265 std::set<HeartbeatInfo> mProcessedHeartbeats;
268 SenderConnectionMap mSenderConnections;
271 ConnectionList mConnections;
274 ConnectionList mConnectedConnections;
277 ConnectionIdMap mConnectionsById;
280 PakThreadedIO mThreadedIO;
282 ConnectionCallbackMap mDisconnectCallbacks;
284 PacketBuffer mReceivePacketBuffer;
285 std::map<std::string, std::string> mAvailableServices;
287 size_t mTotalBytesSent;
288 size_t mTotalBytesReceived;
290 size_t mPreviousBytesSent;
291 size_t mPreviousBytesReceived;
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfXIO_Connection.hpp:37
Definition WsfXIO_Destination.hpp:26
Sent at regular intervals over the UDP connections.
Definition WsfXIO_PacketRegistry.hpp:91
Sent at regular intervals over the UDP connections.
Definition WsfXIO_PacketRegistry.hpp:109
Definition WsfXIO_Interface.hpp:57
virtual ~ClockSource()
Definition WsfXIO_Interface.hpp:59
virtual double GetSimTime() const =0
void SetXIO_Requested()
Definition WsfXIO_Interface.hpp:170
const ConnectionList & GetReliableConnections() const
Definition WsfXIO_Interface.hpp:158
UtCallbackListN< void(double, GenUniqueId, bool)> OnHeartbeatUpdate
Definition WsfXIO_Interface.hpp:122
UtCallbackListN< void(WsfXIO_Connection *)> OnDisconnected
Invoked when a connection is no longer connected, prior to deletion.
Definition WsfXIO_Interface.hpp:116
void SetApplicationName(const std::string &aApplicationName)
Definition WsfXIO_Interface.hpp:75
double GetSimTime() const
Returns the current simulation time.
Definition WsfXIO_Interface.hpp:86
void SetDebugEnabled(bool aIsEnabled)
Definition WsfXIO_Interface.hpp:178
WsfXIO_QueryManager & GetQueryManager() const
Definition WsfXIO_Interface.hpp:141
const std::vector< UDP_Target > & GetUDP_Targets()
Definition WsfXIO_Interface.hpp:155
bool IsDebugEnabled() const
Was detailed debugging information requested?
Definition WsfXIO_Interface.hpp:177
WsfXIO_Publisher & GetPublisher() const
Definition WsfXIO_Interface.hpp:143
const GenUniqueId & GetApplicationId() const
Definition WsfXIO_Interface.hpp:74
const ConnectionList & GetConnections() const
Definition WsfXIO_Interface.hpp:157
UtCallbackN< void(WsfXIO_Connection *)> ConnectionCallback
Definition WsfXIO_Interface.hpp:65
void SetShowConnections(bool aShowConnections)
Definition WsfXIO_Interface.hpp:174
std::unique_ptr< ConnectionCallback > DisconnectConnect(WsfXIO_Connection *aConnectionPtr, const ConnectionCallback::FunctionType &aFunction)
Definition WsfXIO_Interface.cpp:426
void SetApplicationType(wsf::xio::ApplicationType aApplicationType)
Definition WsfXIO_Interface.hpp:77
WsfXIO_Connection * GetSender(PakPacket &aPkt)
Definition WsfXIO_Interface.cpp:372
void SetValidApplicationTypes(const std::vector< int > &aApplicationTypes)
UtCallbackListN< void(WsfXIO_Connection *)> ConnectionCallbackList
Definition WsfXIO_Interface.hpp:66
bool ShowConnections() const
Should connection status messages be shown?
Definition WsfXIO_Interface.hpp:173
std::pair< int, int > SenderAddress
Definition WsfXIO_Interface.hpp:63
std::string GetApplicationName() const
Definition WsfXIO_Interface.hpp:76
double GetLastAdvanceTime() const
Definition WsfXIO_Interface.hpp:87
UtCallbackListN< void(WsfXIO_Connection *)> OnConnected
Invoked when a connection is initialized.
Definition WsfXIO_Interface.hpp:113
std::vector< WsfXIO_Connection * > ConnectionList
Definition WsfXIO_Interface.hpp:64
bool IsXIO_Requested() const
Was a network connection requested?
Definition WsfXIO_Interface.hpp:169
UtCallbackListN< void(int, int, int, int, double)> BandwidthDataEvent
Executes on the heartbeat to provide bandwidth information to event output.
Definition WsfXIO_Interface.hpp:128
WsfXIO_Interface()
This form is used when the caller is not a WSF simulation.
Definition WsfXIO_Interface.cpp:59
WsfXIO_RequestManager & GetRequestManager()
Definition WsfXIO_Interface.hpp:139
UtCallbackListN< void(bool, const std::string &)> OnApplicationBehind
Invoked when a connected application has fallen behind the real-time clock by some threshold,...
Definition WsfXIO_Interface.hpp:125
std::unique_ptr< UtCallbackN< void()> > TimeoutConnect(double aWaitTime, const std::function< void()> &aFunction)
Definition WsfXIO_Interface.cpp:327
Base class for XIO Packets. Provides the header information.
Definition WsfXIO_Packet.hpp:46
WsfXIO_Publisher Provides a basic Publish/Subscribe mechanism.
Definition WsfXIO_Publisher.hpp:75
Definition WsfXIO_QueryManager.hpp:26
Maintains a group of WsfXIO_Requests.
Definition WsfXIO_Request.hpp:31
Definition WsfXIO_PacketRegistry.hpp:1092
ApplicationType
Definition WsfXIO.hpp:24