Send correct informations to a http tracker.
[tairent.git] / src / main / trackermanager.h
blob0603180e13e23dc5558b787ebc2f8a07b2a69876
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation and appearing *
8 * in the file LICENSE.GPL included in the packaging of this file. *
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 GNU *
13 * General Public License for more details. *
14 * *
15 ***************************************************************************/
17 #ifndef _main_trackermanager_h
18 #define _main_trackermanager_h
20 #include <map>
22 #include <tairon/core/string.h>
24 using Tairon::Core::String;
26 namespace Tairent
29 namespace Main
32 class TorrentClient;
33 class TrackerClient;
34 class TrackerClientFactory;
36 /** \brief TrackerManager keeps informations about trackers for various
37 * protocols.
39 class TrackerManager
41 public:
42 /** Construct a TrackerManager object. This class is a singleton.
44 TrackerManager();
46 /** Destroys the object.
48 ~TrackerManager();
50 /** Returns new tracker client for a torrent.
52 TrackerClient *getTracker(TorrentClient *c);
54 /** Registers new protocol for trackers and factory that creates
55 * clients for that protocol.
57 void registerFactory(const String &protocol, TrackerClientFactory *factory);
59 /** Returns pointer to the only one instance of this class.
61 static TrackerManager *self() {
62 return trackerManager;
65 /** Unregisters a factory for specific protocol.
67 void unregisterFactory(const String &protocol);
69 private:
70 /** Creates a default tracker client. It is used when there is no
71 * tracker factory registered for torrent's tracker.
73 TrackerClient *createDefaultTracker(TorrentClient *client);
75 private:
76 /** Mapping from protocol name to a factory that creates tracker
77 * clients for such protocol.
79 std::map<String, TrackerClientFactory *> protocols;
81 /** Pointer to the only one instance of this class.
83 static TrackerManager *trackerManager;
86 }; // namespace Main
88 }; // namespace Tairent
90 #endif
92 // vim: ai sw=4 ts=4 noet fdm=marker