MAK RTIspy API Documentation for HLA 1.3
inOutForwarderPort.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: inOutForwarderPort.h,v $ $Revision: 1.18 $ $State: Exp $
7 *******************************************************************************/
10 
11 #ifndef DtInOutForwarderPort_H_
12 #define DtInOutForwarderPort_H_
13 
14 #include "forwarderPort.h"
15 #include "routeMap.h"
16 #include "rtiMsConfig.h"
17 #include "peerToPeerSockMgr.h"
18 #include <vlutil/vlTime.h>
19 #include <udpMsgSocket.h>
20 #include <map>
21 
22 class DtRIDParameters;
23 class DtRouteMap;
24 class DtTcpSocketMgr__vl__;
26 class DtMacAddrMsg;
27 
33 {
34 
35 protected:
36 
39  DtBoost::shared_ptr<DtRouteMap> routes,
40  const MAKRti::DtInetAddr& host,
41  int forwarderPort,
42  const MAKRti::DtInetAddr& forwarderAddrToConnectTo );
43 
44 public:
45 
46  virtual ~DtInOutForwarderPort();
47 
49  virtual bool isReady() const;
50 
52  virtual DtAddressMsgPair getNextMsg();
53 
55  virtual bool getInitializationMsgs( DtForwarderPort::DtSocketSet& socks,
56  std::list<DtAddressMsgPair>& msgs, bool printBeDestMetadata);
57 
59  virtual bool getInitializationMsg( DtMsgSocket* sock,
60  DtAddressMsgPair& msg, bool printBeDestMetadata);
61 
63  virtual void sendByTransport( const DtForwarderMsg& msg ) const;
64 
66  virtual void sendToAllReliable( const DtForwarderMsg& msg ) const;
67 
70  virtual void sendToListReliable( const DtForwarderMsg& msg,
71  const DtAddressPortList& destinations ) const;
72 
74  virtual void selectParams( MAKRti::DtSelectParamWithWrite& selectParams );
75 
77  virtual void updateRoutes();
78 
79  // Retrieve and process initialization messages if necessary.
80  virtual void processInitializationMessages();
81 
84  virtual int checkConnectionStatus( const DtInetAddrAndPort* target = 0 );
85 
87  virtual void clearNeededConnections();
88 
90  virtual unsigned int abortPendingConnections();
91 
93  virtual unsigned int pendingConnectionsAborted();
94 
96  virtual DtAddressPortList connections() const;
97 
99  virtual void listenToMulticastGroup( const MAKRti::DtInetAddr& mcastAddr ){};
100  virtual void dropMulticastGroup( const MAKRti::DtInetAddr& mcastAddr ){};
101 
103  virtual bool updateFederateConnectionId( unsigned long orig,
104  unsigned long final );
105 
107  virtual bool flush();
108 
110  virtual bool flushOnly();
111 
113  virtual MAKRti::DtString connectionListToString( const char* separator = " : " ) const;
114 
115  virtual bool populateConnectionInformation(
116  unsigned int& numForwarderToForwarderConns,
117  std::vector<MAKRti::DtString>& forwarderIdentifiers,
118  std::vector<MAKRti::DtString>& forwarderConnectionHostNames,
119  std::vector<DtInetAddrAndPort>& forwarderConnectionAddrs) const;
120 
121 public:
122 
124  static DtForwarderPort* create( const DtRIDParameters* params,
125  const DtBoost::shared_ptr<DtRouteMap> routes,
126  const MAKRti::DtInetAddr& host, int forwarderPort,
127  const MAKRti::DtInetAddr& additionalForwarderToConnectTo );
128 
132  static void setCreatorFunction( DtForwarderPortCreatorFcn creator );
133 
134 
136  static void socketAdditionCb( DtTcpMsgSocket* sock, void* usr );
137  virtual void socketAdditionCb( DtTcpMsgSocket* sock );
138 
140  virtual void sendMacAddrMsg( DtTcpMsgSocket* sock );
141 
143  virtual void sendPortMsg( DtTcpMsgSocket* sock );
144 
146  static void socketEstablishedCb( DtTcpMsgSocket* sock, void* usr );
147  virtual void socketEstablishedCb( DtTcpMsgSocket* sock );
148 
150  static void socketRemovalCb( DtTcpMsgSocket* sock, void* usr );
151  virtual void socketRemovalCb( DtTcpMsgSocket* sock );
152 
153  virtual void processForwarderNodeInfoMsg(const DtForwarderPort::DtAddressMsgPair& msg);
154  virtual void processMacAddrMsg(const DtForwarderPort::DtAddressMsgPair& msg);
155 
158  virtual void processPortMsg(const DtForwarderPort::DtAddressMsgPair& msgPair);
159 
160  void sendForwarderNodeInfoMsg( DtTcpMsgSocket* sock );
161  void sendForwarderNodeInfoMsg();
162 
163 protected:
164 
166  virtual void initializeConnections();
167 
169  virtual bool connectToPeer( const DtInetAddrAndPort& addrToConnectTo );
170 
172  virtual int processLostConnection( DtTcpMsgSocket* sock );
173 
176  void connectionCompleted( const DtInetAddrAndPort& addrAndPort,
177  DtTcpMsgSocket* sock );
178 
179 
181  void addSocketUsingRoutesFile(DtTcpMsgSocket* sock,
182  const DtInetAddrAndPort& addrAndPort);
183 
186  bool addSocketDynamically(DtTcpMsgSocket* sock);
187 
188  //Store / remove connection and update dependencies.
189  void addConnection( const DtInetAddrAndPort& newConn, DtTcpMsgSocket* sock );
190  void removeConnection( DtAddrToConnMap::iterator pos );
191 
192 protected:
193 
197  DtInOutForwarderPort& operator=( const DtInOutForwarderPort& orig );
198 
200  bool removeFromPendingList( DtTcpMsgSocket* addr );
201 
203  void becomeRootForwarderNode();
204 
205 protected:
206 
207 
208  bool myIsReady;
211  DtForwarderPort::DtAddrToConnMap::const_iterator myNextConnection;
212  DtForwarderPort::DtAddrToConnMap::const_iterator myLastConnection;
213 
214  std::map<DtInetAddrAndPort, DtTcpMsgSocket*> myAddrToSockMap;
215 
221 
223  std::map<DtInetAddrAndPort, DtString> myNeededConnections;
224 
226  std::map<DtInetAddrAndPort, DtString> myStillNeededConnections;
227 
230  std::map<DtInetAddrAndPort, DtInetAddrAndPort> myUsedToListeningMap;
231 
232 
236 
238  std::map<DtInetAddrAndPort, unsigned long long> myMacAddrsOfConnectedForwardersMap;
240 
241  MAKRti::DtClock myClock;
242  mutable std::map< DtTcpMsgSocket*, MAKRti::DtTime > mySktSendTimeMap;
243 
245  MAKRti::DtInetDevice myHostIf;
246 
248 
249 protected:
250 
251  static DtForwarderPortCreatorFcn theCreator;
252 
253 };
254 
255 inline bool DtInOutForwarderPort::updateFederateConnectionId( unsigned long orig,
256  unsigned long final )
257 {
259  return false;
260 }
261 
262 #endif
263 

Document ID: Generated on Fri Mar 14 19:08:55 EDT 2014 from SVN revision 137085
Copyright © 2005-2014 VT MÄK Inc. All Rights Reserved (www.mak.com)