1 /***************************************************************************
3 * Copyright (C) 2006 David Brodsky *
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. *
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. *
15 ***************************************************************************/
17 #ifndef _main_trackermanager_h
18 #define _main_trackermanager_h
22 #include <tairon/core/string.h>
24 using Tairon::Core::String
;
34 class TrackerClientFactory
;
36 /** \brief TrackerManager keeps informations about trackers for various
42 /** Construct a TrackerManager object. This class is a singleton.
46 /** Destroys the object.
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
);
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
);
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
;
88 }; // namespace Tairent
92 // vim: ai sw=4 ts=4 noet fdm=marker