MAK RTIspy API Documentation for HLA 1.3
forwarderGroup.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2007 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: forwarderGroup.h,v $ $Revision: 1.3 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef DtForwarderGroup_H_
00009 #define DtForwarderGroup_H_
00010 
00015 
00016 #include "rtiMsConfig.h"
00017 #include <vlutil/vlString.h>
00018 #include "peerToPeerSockMgr.h"
00019 #include <rtiUtil.h>
00020 #include <list>
00021 #include <map>
00022 
00023 class DT_DLL_FORWARDER DtRtiForwarderGroup
00024 {
00025 protected:
00027    DtRtiForwarderGroup( const MAKRti::DtString& name, int defaultPort );
00028 
00029 public:
00031    virtual ~DtRtiForwarderGroup();
00032 
00033 public: 
00035    class DtRtiForwarderGroupMember
00036    {
00037    public:
00038       DtRtiForwarderGroupMember( const MAKRti::DtString& name, const MAKRti::DtInetAddr& addr,
00039          const MAKRti::DtString& host, unsigned int port, DtTcpMsgSocket* socket,
00040          const MAKRti::DtString& url, bool isPortal ) :
00041          myName( name ),
00042          myAddr( addr ),
00043          myHost( host ),
00044          myPort( port ),
00045          mySocket( socket ),
00046          myUrl( url ),
00047          myAcceptRemoteConnection( isPortal )
00048       {}
00049 
00050       ~DtRtiForwarderGroupMember(){}
00051 
00052    private:
00053       DtRtiForwarderGroupMember( );
00054 
00055    public:
00056       MAKRti::DtString     myName;
00057       MAKRti::DtInetAddr   myAddr;
00058       MAKRti::DtString     myHost;
00059       unsigned int myPort;
00060       DtTcpMsgSocket* mySocket;
00061       MAKRti::DtString     myUrl;
00062       bool         myAcceptRemoteConnection;
00063    };
00064 
00065    typedef std::map<DtTcpMsgSocket*, DtRtiForwarderGroupMember*> DtForwarderGroupConnectionList;
00066    typedef std::map<MAKRti::DtString, DtRtiForwarderGroupMember*> DtForwarderGroupMemberList;
00067 
00068 public:
00071    virtual bool addForwarderToGroup( const MAKRti::DtString& fwderName,
00072       const MAKRti::DtInetAddr& addr, const MAKRti::DtString& host,
00073       int connectPort = -1, const MAKRti::DtString& url = NULL,
00074       bool isPortal = false);
00075 
00084    virtual unsigned int connectToPortal( const MAKRti::DtString& fwderName = NULL, 
00085                                          bool ignorePortalFlag = false );
00086    virtual unsigned int connectToPortal( DtTcpMsgSocket* socket, 
00087                                          bool ignorePortalFlag = false );
00088 
00094    virtual bool connectToForwarder( const MAKRti::DtString& fwderName ); 
00095    virtual bool connectToForwarder( DtTcpMsgSocket* socket );
00096 
00098    virtual bool disconnectFromForwarder( DtTcpMsgSocket* socket );
00099 
00101    virtual void disconnectFromGroup();
00102 
00105    virtual bool removeForwarder( const MAKRti::DtString& fwderName );
00106    virtual bool removeForwarder( DtTcpMsgSocket* socket );
00107 
00109    virtual void dissolve();
00110 
00112    virtual const DtForwarderGroupMemberList members() const;
00113 
00115    virtual bool isMember( const MAKRti::DtString& fwderName );
00116    virtual bool isMember( const DtInetAddrAndPort& addr );
00117    virtual bool isMember( DtTcpMsgSocket* sock );
00118 
00121    virtual const DtForwarderGroupConnectionList& portalConnections() const;
00122 
00126    virtual const DtForwarderGroupConnectionList& connections() const;
00127 
00129    virtual void setConnectionManager( DtPeerToPeerTcpSockMgr* connMgr );
00130 
00132    virtual void setDefaultPort( int port );
00133 
00140    virtual void setForwarderInfo( const DtInetAddrAndPort& addr, const MAKRti::DtString& url = NULL, 
00141                                   bool isPortal = false);
00142    virtual void setForwarderInfo( DtTcpMsgSocket* socket, const MAKRti::DtString& url = NULL, 
00143                                   bool isPortal = false);
00144 
00146    MAKRti::DtString getForwarderNameByAddr( const DtInetAddrAndPort& addr ) const;
00147 
00149    DtInetAddrAndPort getForwarderAddrByName( const MAKRti::DtString& fwderName ) const;
00150 
00154    virtual bool forwarderIsAPortal( const MAKRti::DtString& fwderName ) const;
00155 
00157    virtual unsigned int portalCount() const;
00158 
00160    virtual unsigned int connectionCount() const;
00161 
00163    virtual unsigned int memberCount() const;
00164 
00166    virtual const MAKRti::DtString& groupName() const;
00167 
00170    virtual DtRtiForwarderGroup::DtRtiForwarderGroupMember* nextAvailablePortal();
00171 
00177    virtual bool updateNextAvailablePortal();
00178 
00179 public:
00181    typedef DtRtiForwarderGroup* (*DtForwarderGroupCreatorFcn)( const MAKRti::DtString&, int );
00182    
00184    static DtRtiForwarderGroup* create( const MAKRti::DtString& name, int defaultPort );
00185    
00189    static void setCreatorFunction( DtForwarderGroupCreatorFcn creator );
00190 
00191 protected:
00192    MAKRti::DtString                myName;
00193    DtPeerToPeerTcpSockMgr* myConnectionMgr;
00194    int                     myDefaultPort;
00195 
00197    DtForwarderGroupConnectionList myConnectionSocketMap;
00199    DtForwarderGroupMemberList     myConnectionRoster;    
00201    DtForwarderGroupMemberList     myRoster;              
00202 
00206    DtForwarderGroupConnectionList myPortalForwarders;
00207    DtForwarderGroupConnectionList myConnectedForwarders;
00208 
00211    DtRtiForwarderGroup::DtRtiForwarderGroupMember* myNextAvailablePortal;
00212 
00213 protected:
00214    
00215    static DtForwarderGroupCreatorFcn theCreator;
00216 };
00217 
00218 
00219 inline void DtRtiForwarderGroup::setDefaultPort( int port )
00220 {
00221    myDefaultPort = port;
00222 }
00223 
00224 inline const DtRtiForwarderGroup::DtForwarderGroupConnectionList& DtRtiForwarderGroup::portalConnections() const
00225 {
00226    return myPortalForwarders;
00227 }
00228 
00229 inline const DtRtiForwarderGroup::DtForwarderGroupConnectionList& DtRtiForwarderGroup::connections() const
00230 {
00231    return myConnectedForwarders;
00232 }
00233 
00234 inline unsigned int DtRtiForwarderGroup::portalCount() const
00235 {
00236    return myPortalForwarders.size();
00237 }
00238 
00239 inline unsigned int DtRtiForwarderGroup::connectionCount() const
00240 {
00241    return myConnectedForwarders.size();
00242 }
00243 
00244 inline unsigned int DtRtiForwarderGroup::memberCount() const
00245 {
00246    return myRoster.size();
00247 }
00248 
00249 inline const MAKRti::DtString& DtRtiForwarderGroup::groupName() const
00250 {
00251    return myName;
00252 }
00253 
00254 inline DtRtiForwarderGroup::DtRtiForwarderGroupMember* DtRtiForwarderGroup::nextAvailablePortal()
00255 {
00256    if ( !myNextAvailablePortal )
00257    {
00259       myNextAvailablePortal = members().begin()->second;
00260    }
00261    return myNextAvailablePortal;
00262 }
00263 
00264 #endif //! DtForwarderGroup_H_

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)