mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 15:19:20 +00:00
Adding framework for an option parser.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@448 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -9,6 +9,7 @@ libsub_core_a_SOURCES = \
|
||||
download.h \
|
||||
download_list.cc \
|
||||
download_list.h \
|
||||
download_slot_map.h \
|
||||
download_store.cc \
|
||||
download_store.h \
|
||||
hash_queue.cc \
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_CORE_DOWNLOAD_SLOT_MAP_H
|
||||
#define RTORRENT_CORE_DOWNLOAD_SLOT_MAP_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <sigc++/slot.h>
|
||||
|
||||
#include "download.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
class DownloadSlotMap : public std::map<std::string, sigc::slot1<void, Download*> > {
|
||||
public:
|
||||
typedef sigc::slot1<void, Download*> SlotDownload;
|
||||
typedef std::map<std::string, SlotDownload> Base;
|
||||
|
||||
void insert(const std::string& key, SlotDownload s) { Base::operator[](key) = s; }
|
||||
|
||||
void for_each(Download* d);
|
||||
};
|
||||
|
||||
inline void
|
||||
DownloadSlotMap::for_each(Download* d) {
|
||||
for (iterator itr = begin(), last = end(); itr != last; ++itr)
|
||||
itr->second(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -180,6 +180,7 @@ Manager::create_final(std::istream* s) {
|
||||
|
||||
void
|
||||
Manager::setup_download(Download* d) {
|
||||
// These should be in m_defaultSettings.
|
||||
d->get_download().set_ip(m_dns);
|
||||
|
||||
if (!m_defaultRoot.empty())
|
||||
@@ -188,6 +189,8 @@ Manager::setup_download(Download* d) {
|
||||
d->get_download().get_name() :
|
||||
""));
|
||||
|
||||
m_defaultSettings.for_each(d);
|
||||
|
||||
if (m_debugTracker >= 0)
|
||||
d->get_download().signal_tracker_dump(sigc::mem_fun(*this, &Manager::receive_debug_tracker));
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <iosfwd>
|
||||
|
||||
#include "download_list.h"
|
||||
#include "download_slot_map.h"
|
||||
#include "download_store.h"
|
||||
#include "hash_queue.h"
|
||||
#include "http_queue.h"
|
||||
@@ -51,6 +52,8 @@ public:
|
||||
HashQueue& get_hash_queue() { return m_hashQueue; }
|
||||
HttpQueue& get_http_queue() { return m_httpQueue; }
|
||||
|
||||
DownloadSlotMap& get_default_settings() { return m_defaultSettings; }
|
||||
|
||||
Poll& get_poll() { return m_poll; }
|
||||
Log& get_log_important() { return m_logImportant; }
|
||||
Log& get_log_complete() { return m_logComplete; }
|
||||
@@ -91,6 +94,8 @@ private:
|
||||
HashQueue m_hashQueue;
|
||||
HttpQueue m_httpQueue;
|
||||
|
||||
DownloadSlotMap m_defaultSettings;
|
||||
|
||||
Poll m_poll;
|
||||
Log m_logImportant;
|
||||
Log m_logComplete;
|
||||
|
||||
Reference in New Issue
Block a user