MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rtiMessageForwarder.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992, 1997 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: rtiMessageForwarder.h,v $ $Revision: 1.19 $ $State: Exp $
7 *********************************************************************/
8 #ifndef DtRtiMsgForwarder_H_
9 #define DtRtiMsgForwarder_H_
10 
14 
15 #include "rtiMsConfig.h"
16 #include "RIDparams.h"
17 #include "multicastDiscoveryMgr.h"
18 #include "rtiVersion.h"
19 #include <vlutil/vlRunnable.h>
20 #include <vlutil/vlThreadSafe.h>
21 //#include "execThreadEvents.h"
22 
23 #include <vlutil/vlSelectParamW.h>
24 #include <vlutil/vlSmartPointers.h>
25 #include <vlutil/vlInetAddr.h>
26 
27 #include <utility>
28 #include <deque>
29 
32 class DtRtiMsg;
33 class DtRtiMsgForwarder;
35 class DtMessageFilter;
41 class DtFedexMsgFilter;
43 class DtMsgFwdrFunctor;
44 class DtRtiMsgForwarder;
47 class DtTcpMsgSocket;
48 class DtTcpMsgSocketMgr;
49 
51 typedef DtRtiMsgForwarder* (*DtRtiMsgFwderCreator)( unsigned long, const DtRIDParameters& params );
52 
59 {
60 protected:
62  DtRtiMsgForwarder( unsigned long id, const DtRIDParameters& params );
63 
64 public:
65 
67  {
68  ConnectionInfo( unsigned long connId, DtTcpMsgSocket* socket,
69  const MAKRti::DtInetAddr& ipAddr, int port,
70  unsigned long federateHandle = 0,
71  const MAKRti::DtString& federateName = "",
72  const MAKRti::DtString& federateType = "",
73  const MAKRti::DtString& fedexName = "",
74  DtHlaVersionId hlaVersion = DtHla13);
75 
77  bool operator==( const ConnectionInfo& rhs );
78  bool operator<( const ConnectionInfo& rhs );
79 
81  void setFederateInfo( unsigned long fedexHandle, unsigned long handle,
82  const MAKRti::DtString& name, const MAKRti::DtString& type,
83  const MAKRti::DtString& fedexName, DtHlaVersionId hlaVersion );
84  void setConnectionId( unsigned long connId );
85 
86  unsigned long myConnId;
87  unsigned long myFederationHandle;
88  unsigned long myHandle;
89  unsigned long myProcessID;
90  MAKRti::DtInetAddr myIp;
91  int myPort;
92  MAKRti::DtString myName;
93  MAKRti::DtString myType;
94  MAKRti::DtString myFederationName;
95  MAKRti::DtString myProcessName;
96  MAKRti::DtString myCommandArgs;
99 
100 
103  };
104 
105  typedef DtBoost::shared_ptr<ConnectionInfo> ConnectionInfoSP;
106  typedef DtBoost::weak_ptr<ConnectionInfo> ConnectionInfoWP;
107  typedef std::map< const DtTcpMsgSocket*, ConnectionInfoSP > SocketToConnInfoMap;
108 
109 
110 public:
111 
113  virtual ~DtRtiMsgForwarder();
114 
116  virtual void init();
117 
119  virtual bool hasExec() const;
120 
124  virtual void run();
125 
127 
129  virtual void setEnableBundling( unsigned int maxBundleSize );
130 
132  virtual void setUseSmartForwarding( bool yesNo );
133 
135  virtual void setUseInternalSmartForwarding( bool yesNo );
136 
138  virtual void setRouteFedexMessages( bool yesNo );
139 
140 
143  virtual void addPacketFilter( DtMessageFilter* filter );
144  virtual void removePacketFilter( DtMessageFilter* filter );
145 
147  virtual inline unsigned long forwarderId() const;
148 
150  virtual void setForwarderId(unsigned long newId);
151 
153  void updateTcpForwarderQueuedSockets();
154 
155 public:
156 
159 
161  virtual inline const DtRtiMsgForwarder::SocketToConnInfoMap& getConnToConnInfoMap() const;
162 
164  virtual ConnectionInfoSP getConnectionInfoByConnId( unsigned long connId ) const;
165 
167  virtual ConnectionInfoSP getConnectionInfoByHandle( unsigned long federateHandle ) const;
168 
170  virtual ConnectionInfoSP getConnectionInfoBySocket( const DtTcpMsgSocket* sock ) const;
171 
173  virtual std::pair< bool, unsigned long > rtiExecConnected() const;
174 
176  virtual void sendMessage( const DtRtiMsg& msg, const DtTcpMsgSocket* src = 0 );
177 
181  virtual void requestCloseAllConnections();
182 
188  virtual void requestKillSingleConnection( const DtTcpMsgSocket* sock );
189 
194  virtual void markConnectionAsAboutToBeDeleted(DtTcpMsgSocket const* socket, unsigned int connectionId);
195 
197  virtual bool isConnectionMarkedForDeletion(unsigned int connectionId) const;
198 
202  virtual void removeOldConnection(unsigned int connectionId);
203 
206  virtual void shutdownRequestedByExec();
207 
211  virtual bool updateFederateConnectionId( unsigned long orig, unsigned long final );
212 
214  virtual void updateConnectionProcessParameters( unsigned long connId, unsigned long processId, MAKRti::DtString processName, MAKRti::DtString commandArgs );
215 
217  virtual bool shouldStop();
218 
219 public:
220 
222  static DtRtiMsgForwarder* create( unsigned long id, const DtRIDParameters& params );
223 
227  static void setCreatorFunction(DtRtiMsgFwderCreator fn);
228 
230  static void tcpSocketAdditionCb(DtTcpMsgSocket* sock, void* usr);
231  static void tcpSocketRemovalCb(DtTcpMsgSocket* sock, void* usr);
232 
233 protected:
234 
235  virtual void performMcastDiscovery();
236 
239  virtual void applyRegisteredFilters();
240  virtual void disableRegisteredFilters();
241 
244  virtual void waitForIo();
245 
246 
247  virtual void tcpSocketAdditionCb(DtTcpMsgSocket* sock);
248  virtual void tcpSocketRemovalCb(DtTcpMsgSocket* sock);
249 
251  virtual unsigned long consumeConnId();
252 
256  virtual void preRunLoopEvent() {};
257  virtual void runLoopEvent() {};
258  virtual void postRunLoopEvent() {};
259 
260 
261  virtual bool populateConnectionInformation(
262  unsigned int& numForwarderToForwarderConns,
263  std::vector<MAKRti::DtString>& forwarderIdentifiers,
264  std::vector<MAKRti::DtString>& forwarderConnectionHostNames,
265  std::vector<MAKRti::DtInetAddr>& forwarderConnectionAddrs,
266  unsigned int& numForwarderClientConns,
267  std::vector<MAKRti::DtString>& clientConnectionHostNames,
268  std::vector<MAKRti::DtInetAddr>& clientConnectionAddrs) const;
269 
271  virtual void closeAllConnectionsIfRequested();
272 
274  DtRtiMsgForwarder( const DtRtiMsgForwarder& orig );
275  DtRtiMsgForwarder& operator=( const DtRtiMsgForwarder& orig );
276 
277 protected:
278 
280 
283  unsigned long myForwarderId;
284 
286  MAKRti::DtInetAddr myForwarderAddr;
287 
290 
293 
296 
298  int myPort;
300 
304 
306  unsigned int myPacketBundleSize;
307 
310 
316 
319 
322 
326 
329 
331  DtThreadSafe< std::deque<DtMsgFwdrFunctor*> > myPendingProxyCommands;
332 
334  std::vector< DtMessageFilter* > myRegisteredFilters;
335 
341 
343  std::set<DtTcpMsgSocket const*> myConnectionsAboutToBeDeleted;
344 
345  MAKRti::DtSelectParamWithWrite mySelectParams;
346 
349 
350  MAKRti::DtString myHostname;
351 
352 protected:
353 
355 };
356 
357 
358 
360 {
361  return myConnToConnInfoMap;
362 }
363 
364 inline unsigned long DtRtiMsgForwarder::forwarderId() const
365 {
366  return myForwarderId;
367 }
368 
369 
370 #endif
371 
int myPort
Port for local federate connections.
Definition: rtiMessageForwarder.h:298
unsigned long myProcessID
Definition: rtiMessageForwarder.h:89
DtFedexMsgFilter * myFedexMsgRouter
Fedex Routing Filter.
Definition: rtiMessageForwarder.h:318
DtHlaVersionId myHlaVersion
Definition: rtiMessageForwarder.h:97
bool myCloseAllConnectionsRequested
Connection shutdown requested?
Definition: rtiMessageForwarder.h:289
Helper class reads and prints message routing info in Verbose mode.
Definition: updateInterRoutingFilter.h:54
MAKRti::DtString myCommandArgs
Definition: rtiMessageForwarder.h:96
virtual void preRunLoopEvent()
Plug-in defined Run Loop operations Gives users the ability to add functionality to the Run() loop wi...
Definition: rtiMessageForwarder.h:256
DtRoutePrinterFilter * myRoutePrinter
Smart DM Forwarding Filters.
Definition: rtiMessageForwarder.h:312
unsigned int myPacketBundleSize
Packet Bundle size (if bundle size = 0, bundling is disabled)
Definition: rtiMessageForwarder.h:306
virtual void postRunLoopEvent()
Definition: rtiMessageForwarder.h:258
unsigned long myConnId
Definition: rtiMessageForwarder.h:86
const DtRIDParameters & myParams
Local access to the RID Parameters.
Definition: rtiMessageForwarder.h:328
This class manages the RTI&#39;s start-up configuration using both MTL variables and functions.
Definition: RIDparams.h:87
Helper class Routes internal messages according to attached subscriber lists.
Definition: updateInterRoutingFilter.h:113
Definition: rtiMessageForwarder.h:66
SocketToConnInfoMap myConnToConnInfoMap
Map from socket (conn) to ConnectionInfo object for that connection notes:
Definition: rtiMessageForwarder.h:340
Definition: tcpMsgSocketMgr.h:45
DtInternalRoutingFilter * myIntMsgRouter
Definition: rtiMessageForwarder.h:315
unsigned long myNextConnectionIdOffset
The ID to be assigned to the next Federate or Forwarder connection The IDs are offset from the forwar...
Definition: rtiMessageForwarder.h:303
DtHlaVersionId
Definition: rtiVersion.h:42
MAKRti::DtString myName
Definition: rtiMessageForwarder.h:92
virtual void runLoopEvent()
Definition: rtiMessageForwarder.h:257
Definition: rtiVersion.h:44
MAKRti::DtInetAddr myIp
Definition: rtiMessageForwarder.h:90
virtual const DtRtiMsgForwarder::SocketToConnInfoMap & getConnToConnInfoMap() const
WARNING: These methods are not thread-safe and may only be called by the back-end forwarder thread! ...
Definition: rtiMessageForwarder.h:359
Helper class captures DtNetConnectConfirmMsg Messages and extracts information required by the forwar...
Definition: connectConfirmFilter.h:23
unsigned long myHandle
Definition: rtiMessageForwarder.h:88
DtBoost::shared_ptr< ConnectionInfo > ConnectionInfoSP
Definition: rtiMessageForwarder.h:105
DtRtiMsg is the base class for messages between RTI components.
Definition: rtiMsg.h:45
MAKRti::DtString myFederationName
Definition: rtiMessageForwarder.h:94
DtInternalRoutePrinterFilter * myInternalRoutePrinter
Definition: rtiMessageForwarder.h:313
unsigned long myForwarderId
Data Members.
Definition: rtiMessageForwarder.h:283
The DtMulitcastDiscoveryMgr can act as either a Requester or a Responder.
Definition: multicastDiscoveryMgr.h:33
DtRtiMsgForwarder *(* DtRtiMsgFwderCreator)(unsigned long, const DtRIDParameters &params)
DtRtiMsgForwarder creator callback signature.
Definition: rtiMessageForwarder.h:51
MAKRti::DtInetAddr myForwarderAddr
Local host IP address (used by rtiExec monitor filter, among other uses)
Definition: rtiMessageForwarder.h:286
Helper class captures DtNetDeleteSocketMsg (DtNetConnectMsg) Messages and extracts information requir...
Definition: deleteSocketFilter.h:23
DtThreadSafe< std::deque< DtMsgFwdrFunctor * > > myPendingProxyCommands
Definition: rtiMessageForwarder.h:331
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages...
Definition: tcpMsgSocket.h:42
DtMessageFilter is a base class for filters applied to DtFilteredTcpForwarder.
Definition: filteredTcpForwarder.h:32
std::map< const DtTcpMsgSocket *, ConnectionInfoSP > SocketToConnInfoMap
Definition: rtiMessageForwarder.h:107
unsigned long myFederationHandle
Definition: rtiMessageForwarder.h:87
Helper class monitors rtiexec connections and handles rtiexec handshaking and disconnects.
Definition: rtiExecTrackingFilter.h:34
static DtRtiMsgFwderCreator theCreator
Definition: rtiMessageForwarder.h:354
Fedex Msg Filter class: Ensures that message to/from the Fedex are delivered ONLY to required destina...
Definition: fedexMsgFilter.h:30
std::set< DtTcpMsgSocket const * > myConnectionsAboutToBeDeleted
Set of connections that when deleted there should be no complaint.
Definition: rtiMessageForwarder.h:343
DtDeleteSocketFilter * mySocketMonitor
Marks sockets that are being disconnected normally so that no complaint is given when they disconnect...
Definition: rtiMessageForwarder.h:325
int myPort
Definition: rtiMessageForwarder.h:91
MAKRti::DtString myProcessName
Definition: rtiMessageForwarder.h:95
DtBitMask myFedIdMask
Single bit mask for federate handle.
Definition: rtiMessageForwarder.h:102
DtRtiMsgForwarder manages connections and message distribution to local federates and remote Forwarde...
Definition: rtiMessageForwarder.h:58
DtMulitcastDiscoveryMgr myMcastDiscoveryMgr
Definition: rtiMessageForwarder.h:330
DtFilteredTcpForwarder * myTcpForwarder
Tcp Forwarder with Filtering Capabilities.
Definition: rtiMessageForwarder.h:292
const DtTcpMsgSocket * mySocket
Definition: rtiMessageForwarder.h:98
MAKRti::DtString myHostname
Definition: rtiMessageForwarder.h:350
DtBitMask represents a variable length bit-field which may be used to represent an array of boolean d...
Definition: bitMask.h:24
DtTcpMsgSocketMgr * mySocketMgr
Tcp Socket Manager (handles passive connections to Federates)
Definition: rtiMessageForwarder.h:295
DtBoost::weak_ptr< ConnectionInfo > ConnectionInfoWP
Definition: rtiMessageForwarder.h:106
DtRtiExecTrackingFilter * myRtiExecMonitor
If registered, Monitors rtiexec connection life-cycle.
Definition: rtiMessageForwarder.h:309
#define DT_DLL_FORWARDER
Definition: rtiMsConfig.h:124
MAKRti::DtString myType
Definition: rtiMessageForwarder.h:93
Helper class Routes Update and Interaction messages according to attached subscriber lists...
Definition: updateInterRoutingFilter.h:83
DtConnectConfirmFilter * myConnectConfirmFilter
Extracts info from connect confirm messages.
Definition: rtiMessageForwarder.h:321
MAKRti::DtSelectParamWithWrite mySelectParams
Definition: rtiMessageForwarder.h:345
Helper class reads and prints message routing info in Verbose mode.
Definition: updateInterRoutingFilter.h:27
int myTcpNoDelay
Definition: rtiMessageForwarder.h:299
DtFilteredTcpForwarder maintains a list of open connections and explodes received messages to all des...
Definition: filteredTcpForwarder.h:123
DtUpdateInterRoutingFilter * myDmMsgRouter
Definition: rtiMessageForwarder.h:314
bool myShouldStop
should this forwarder stop.
Definition: rtiMessageForwarder.h:348
std::vector< DtMessageFilter * > myRegisteredFilters
Registered Message Filters.
Definition: rtiMessageForwarder.h:334
virtual unsigned long forwarderId() const
Return the forwarder ID (defines the address space for connIds for this forwarder) ...
Definition: rtiMessageForwarder.h:364

Document ID: Generated on Thu May 11 15:55:32 EDT 2023 from SVN revision 254743
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)