libktorrent  2.1.1
globals.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTGLOBALS_H
21 #define BTGLOBALS_H
22 
23 #include <util/constants.h>
24 #include <ktorrent_export.h>
25 
26 namespace utp
27 {
28  class UTPServer;
29 }
30 
31 namespace net
32 {
33  class PortList;
34 }
35 
36 namespace dht
37 {
38  class DHTBase;
39 }
40 
41 namespace bt
42 {
43  class Server;
44 
45 
46 
47  class KTORRENT_EXPORT Globals
48  {
49  public:
50  virtual ~Globals();
51 
52  bool initTCPServer(Uint16 port);
53  void shutdownTCPServer();
54 
55  bool initUTPServer(Uint16 port);
56  void shutdownUTPServer();
57 
58  bool isUTPEnabled() const {return utp_server != 0;}
59  bool isTCPEnabled() const {return tcp_server != 0;}
60 
61  Server & getTCPServer() {return *tcp_server;}
62  dht::DHTBase & getDHT() {return *dh_table;}
63  net::PortList & getPortList() {return *plist;}
64  utp::UTPServer & getUTPServer() {return *utp_server;}
65 
66  static Globals & instance();
67  static void cleanup();
68  private:
69  Globals();
70 
71  Server* tcp_server;
72  dht::DHTBase* dh_table;
73  net::PortList* plist;
74  utp::UTPServer* utp_server;
75 
76  static Globals* inst;
77  };
78 }
79 
80 #endif
bt::Server
Definition: server.h:64
net::PortList
Definition: portlist.h:94
bt::Globals
Definition: globals.h:48
utp::UTPServer
Definition: utpserver.h:56
dht::DHTBase
Definition: dhtbase.h:53