MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
forwarderGroup.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2007 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: forwarderGroup.h,v $ $Revision: 1.3 $ $State: Exp $
7 *********************************************************************/
8 #ifndef DtForwarderGroup_H_
9 #define DtForwarderGroup_H_
10 
15 
16 #include "rtiMsConfig.h"
17 #include <vlutil/vlString.h>
18 #include "peerToPeerSockMgr.h"
19 #include <rtiUtil.h>
20 #include <list>
21 #include <map>
22 
24 {
25 protected:
27  DtRtiForwarderGroup( const MAKRti::DtString& name, int defaultPort );
28 
29 public:
31  virtual ~DtRtiForwarderGroup();
32 
33 public:
36  {
37  public:
38  DtRtiForwarderGroupMember( const MAKRti::DtString& name, const MAKRti::DtInetAddr& addr,
39  const MAKRti::DtString& host, unsigned int port, DtTcpMsgSocket* socket,
40  const MAKRti::DtString& url, bool isPortal ) :
41  myName( name ),
42  myAddr( addr ),
43  myHost( host ),
44  myPort( port ),
45  mySocket( socket ),
46  myUrl( url ),
47  myAcceptRemoteConnection( isPortal )
48  {}
49 
51 
52  private:
54 
55  public:
56  MAKRti::DtString myName;
57  MAKRti::DtInetAddr myAddr;
58  MAKRti::DtString myHost;
59  unsigned int myPort;
61  MAKRti::DtString myUrl;
63  };
64 
65  typedef std::map<DtTcpMsgSocket*, DtRtiForwarderGroupMember*> DtForwarderGroupConnectionList;
66  typedef std::map<MAKRti::DtString, DtRtiForwarderGroupMember*> DtForwarderGroupMemberList;
67 
68 public:
71  virtual bool addForwarderToGroup( const MAKRti::DtString& fwderName,
72  const MAKRti::DtInetAddr& addr, const MAKRti::DtString& host,
73  int connectPort = -1, const MAKRti::DtString& url = NULL,
74  bool isPortal = false);
75 
84  virtual unsigned int connectToPortal( const MAKRti::DtString& fwderName = NULL,
85  bool ignorePortalFlag = false );
86  virtual unsigned int connectToPortal( DtTcpMsgSocket* socket,
87  bool ignorePortalFlag = false );
88 
94  virtual bool connectToForwarder( const MAKRti::DtString& fwderName );
95  virtual bool connectToForwarder( DtTcpMsgSocket* socket );
96 
98  virtual bool disconnectFromForwarder( DtTcpMsgSocket* socket );
99 
101  virtual void disconnectFromGroup();
102 
105  virtual bool removeForwarder( const MAKRti::DtString& fwderName );
106  virtual bool removeForwarder( DtTcpMsgSocket* socket );
107 
109  virtual void dissolve();
110 
112  virtual const DtForwarderGroupMemberList members() const;
113 
115  virtual bool isMember( const MAKRti::DtString& fwderName );
116  virtual bool isMember( const DtInetAddrAndPort& addr );
117  virtual bool isMember( DtTcpMsgSocket* sock );
118 
121  virtual const DtForwarderGroupConnectionList& portalConnections() const;
122 
126  virtual const DtForwarderGroupConnectionList& connections() const;
127 
129  virtual void setConnectionManager( DtPeerToPeerTcpSockMgr* connMgr );
130 
132  virtual void setDefaultPort( int port );
133 
140  virtual void setForwarderInfo( const DtInetAddrAndPort& addr, const MAKRti::DtString& url = NULL,
141  bool isPortal = false);
142  virtual void setForwarderInfo( DtTcpMsgSocket* socket, const MAKRti::DtString& url = NULL,
143  bool isPortal = false);
144 
146  MAKRti::DtString getForwarderNameByAddr( const DtInetAddrAndPort& addr ) const;
147 
149  DtInetAddrAndPort getForwarderAddrByName( const MAKRti::DtString& fwderName ) const;
150 
154  virtual bool forwarderIsAPortal( const MAKRti::DtString& fwderName ) const;
155 
157  virtual unsigned int portalCount() const;
158 
160  virtual unsigned int connectionCount() const;
161 
163  virtual unsigned int memberCount() const;
164 
166  virtual const MAKRti::DtString& groupName() const;
167 
170  virtual DtRtiForwarderGroup::DtRtiForwarderGroupMember* nextAvailablePortal();
171 
177  virtual bool updateNextAvailablePortal();
178 
179 public:
181  typedef DtRtiForwarderGroup* (*DtForwarderGroupCreatorFcn)( const MAKRti::DtString&, int );
182 
184  static DtRtiForwarderGroup* create( const MAKRti::DtString& name, int defaultPort );
185 
189  static void setCreatorFunction( DtForwarderGroupCreatorFcn creator );
190 
191 protected:
192  MAKRti::DtString myName;
195 
202 
208 
212 
213 protected:
214 
215  static DtForwarderGroupCreatorFcn theCreator;
216 };
217 
218 
219 inline void DtRtiForwarderGroup::setDefaultPort( int port )
220 {
221  myDefaultPort = port;
222 }
223 
225 {
226  return myPortalForwarders;
227 }
228 
230 {
231  return myConnectedForwarders;
232 }
233 
234 inline unsigned int DtRtiForwarderGroup::portalCount() const
235 {
236  return myPortalForwarders.size();
237 }
238 
239 inline unsigned int DtRtiForwarderGroup::connectionCount() const
240 {
241  return myConnectedForwarders.size();
242 }
243 
244 inline unsigned int DtRtiForwarderGroup::memberCount() const
245 {
246  return myRoster.size();
247 }
248 
249 inline const MAKRti::DtString& DtRtiForwarderGroup::groupName() const
250 {
251  return myName;
252 }
253 
255 {
256  if ( !myNextAvailablePortal )
257  {
259  myNextAvailablePortal = members().begin()->second;
260  }
261  return myNextAvailablePortal;
262 }
263 
264 #endif
DtForwarderGroupConnectionList myPortalForwarders
Socket lists to simplify the task of determining where to transmit messages to (myPortalForwarders) a...
Definition: forwarderGroup.h:206
std::pair< MAKRti::DtInetAddr, int > DtInetAddrAndPort
Definition: rtiUtil.h:147
virtual DtRtiForwarderGroup::DtRtiForwarderGroupMember * nextAvailablePortal()
Get pointer to next portal available to accept connection from foreign forwarders in load-balance con...
Definition: forwarderGroup.h:254
static DtForwarderGroupCreatorFcn theCreator
Definition: forwarderGroup.h:215
MAKRti::DtInetAddr myAddr
Definition: forwarderGroup.h:57
bool myAcceptRemoteConnection
Definition: forwarderGroup.h:62
DtForwarderGroupConnectionList myConnectionSocketMap
Connections keyed by socket.
Definition: forwarderGroup.h:197
The DtPeerToPeerTcpSockMgr adds the ability to act as a client as well as a server to the DtTcpMsgSoc...
Definition: peerToPeerSockMgr.h:45
DtRtiForwarderGroupMember(const MAKRti::DtString &name, const MAKRti::DtInetAddr &addr, const MAKRti::DtString &host, unsigned int port, DtTcpMsgSocket *socket, const MAKRti::DtString &url, bool isPortal)
Definition: forwarderGroup.h:38
virtual void setDefaultPort(int port)
Change the group characteristics.
Definition: forwarderGroup.h:219
Data-only helper class to store information about forwarders in the group.
Definition: forwarderGroup.h:35
virtual const DtForwarderGroupConnectionList & connections() const
Return a map of all forwarders (keyed by socket) that messages may be received from (ie...
Definition: forwarderGroup.h:229
MAKRti::DtString myName
Definition: forwarderGroup.h:56
std::map< MAKRti::DtString, DtRtiForwarderGroupMember * > DtForwarderGroupMemberList
Definition: forwarderGroup.h:66
DtRtiForwarderGroup::DtRtiForwarderGroupMember * myNextAvailablePortal
Aid to keep track of which portal in group is next in line to accept connections from foreign groups ...
Definition: forwarderGroup.h:211
virtual const DtForwarderGroupConnectionList & portalConnections() const
Return the map of portals (keyed by socket) (ie.
Definition: forwarderGroup.h:224
DtPeerToPeerTcpSockMgr * myConnectionMgr
Definition: forwarderGroup.h:193
virtual unsigned int memberCount() const
Return a count of all forwarders (connected or not) in the group.
Definition: forwarderGroup.h:244
int myDefaultPort
Definition: forwarderGroup.h:194
virtual unsigned int portalCount() const
Return a count of portal connections to the group.
Definition: forwarderGroup.h:234
#define NULL
Definition: baseTypes13.h:8
virtual const DtForwarderGroupMemberList members() const
Return the map of all forwarders (keyed by name) in the group.
virtual const MAKRti::DtString & groupName() const
Return the group name.
Definition: forwarderGroup.h:249
This file contains the declaration of the DtPeerToPeerTcpSockMgr class.
DtForwarderGroupConnectionList myConnectedForwarders
Definition: forwarderGroup.h:207
~DtRtiForwarderGroupMember()
Definition: forwarderGroup.h:50
DtForwarderGroupMemberList myConnectionRoster
Connections keyed by forwarder name.
Definition: forwarderGroup.h:199
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages...
Definition: tcpMsgSocket.h:42
MAKRti::DtString myName
Definition: forwarderGroup.h:192
MAKRti::DtString myUrl
Definition: forwarderGroup.h:61
DtTcpMsgSocket * mySocket
Definition: forwarderGroup.h:60
DtForwarderGroupMemberList myRoster
Group member list keyed by forwarder name.
Definition: forwarderGroup.h:201
Definition: forwarderGroup.h:23
virtual unsigned int connectionCount() const
Return a count of all connections existing to the group.
Definition: forwarderGroup.h:239
MAKRti::DtString myHost
Definition: forwarderGroup.h:58
#define DT_DLL_FORWARDER
Definition: rtiMsConfig.h:124
std::map< DtTcpMsgSocket *, DtRtiForwarderGroupMember * > DtForwarderGroupConnectionList
Definition: forwarderGroup.h:65
unsigned int myPort
Definition: forwarderGroup.h:59

Document ID: Generated on Mon Sep 7 15:40:32 EDT 2020 from SVN revision 217499
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)