1 // libTorrent - BitTorrent library 2 // Copyright (C) 2005-2011, Jari Sundell 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation; either version 2 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 // 18 // In addition, as a special exception, the copyright holders give 19 // permission to link the code of portions of this program with the 20 // OpenSSL library under certain conditions as described in each 21 // individual source file, and distribute linked combinations 22 // including the two. 23 // 24 // You must obey the GNU General Public License in all respects for 25 // all of the code used other than OpenSSL. If you modify file(s) 26 // with this exception, you may extend this exception to your version 27 // of the file(s), but you are not obligated to do so. If you do not 28 // wish to do so, delete this exception statement from your version. 29 // If you delete this exception statement from all source files in the 30 // program, then also delete it here. 31 // 32 // Contact: Jari Sundell <jaris@ifi.uio.no> 33 // 34 // Skomakerveien 33 35 // 3185 Skoppum, NORWAY 36 37 #ifndef LIBTORRENT_MANAGER_H 38 #define LIBTORRENT_MANAGER_H 39 40 #include <list> 41 #include <string> 42 #include <rak/priority_queue_default.h> 43 44 #include "thread_disk.h" 45 #include "thread_main.h" 46 #include "net/socket_fd.h" 47 48 namespace torrent { 49 50 class Poll; 51 52 class HashQueue; 53 class HandshakeManager; 54 class DownloadManager; 55 class DownloadWrapper; 56 class DownloadMain; 57 class FileManager; 58 class ResourceManager; 59 class PeerInfo; 60 class ChunkManager; 61 class ConnectionManager; 62 class Throttle; 63 class DhtManager; 64 65 typedef std::list<std::string> EncodingList; 66 67 class Manager { 68 public: 69 Manager(); 70 ~Manager(); 71 download_manager()72 DownloadManager* download_manager() { return m_downloadManager; } file_manager()73 FileManager* file_manager() { return m_fileManager; } handshake_manager()74 HandshakeManager* handshake_manager() { return m_handshakeManager; } hash_queue()75 HashQueue* hash_queue() { return m_hashQueue; } resource_manager()76 ResourceManager* resource_manager() { return m_resourceManager; } 77 chunk_manager()78 ChunkManager* chunk_manager() { return m_chunkManager; } client_list()79 ClientList* client_list() { return m_clientList; } connection_manager()80 ConnectionManager* connection_manager() { return m_connectionManager; } dht_manager()81 DhtManager* dht_manager() { return m_dhtManager; } 82 poll()83 Poll* poll() { return m_main_thread_main.poll(); } 84 main_thread_main()85 thread_main* main_thread_main() { return &m_main_thread_main; } main_thread_disk()86 thread_disk* main_thread_disk() { return &m_main_thread_disk; } 87 encoding_list()88 EncodingList* encoding_list() { return &m_encodingList; } 89 upload_throttle()90 Throttle* upload_throttle() { return m_uploadThrottle; } download_throttle()91 Throttle* download_throttle() { return m_downloadThrottle; } 92 93 void initialize_download(DownloadWrapper* d); 94 void cleanup_download(DownloadWrapper* d); 95 96 void receive_tick(); 97 98 private: 99 DownloadManager* m_downloadManager; 100 FileManager* m_fileManager; 101 HandshakeManager* m_handshakeManager; 102 HashQueue* m_hashQueue; 103 ResourceManager* m_resourceManager; 104 105 ChunkManager* m_chunkManager; 106 ClientList* m_clientList; 107 ConnectionManager* m_connectionManager; 108 DhtManager* m_dhtManager; 109 110 thread_main m_main_thread_main; 111 thread_disk m_main_thread_disk; 112 113 EncodingList m_encodingList; 114 115 Throttle* m_uploadThrottle; 116 Throttle* m_downloadThrottle; 117 118 unsigned int m_ticks; 119 rak::priority_item m_taskTick; 120 }; 121 122 extern Manager* manager; 123 124 } 125 126 #endif 127