MAK RTIspy API Documentation for HLA Evolved
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

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)