mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-21 00:26:16 +00:00
Seperated out my template algorithms and stuff.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@334 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -2,4 +2,6 @@ SUBDIRS = src
|
|||||||
|
|
||||||
EXTRA_DIST= \
|
EXTRA_DIST= \
|
||||||
autogen.sh \
|
autogen.sh \
|
||||||
|
rak/algorithm.h \
|
||||||
|
rak/functional.h \
|
||||||
scripts/checks.m4
|
scripts/checks.m4
|
||||||
|
|||||||
@@ -10,3 +10,5 @@ Consider basing WindowPeer* on a common base class.
|
|||||||
|
|
||||||
Some kind of indication that a tracker request was tried, but won't be
|
Some kind of indication that a tracker request was tried, but won't be
|
||||||
allowed since the tracker set a min interval.
|
allowed since the tracker set a min interval.
|
||||||
|
|
||||||
|
Make accumulate return the value, no refs please...
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace utils {
|
namespace rak {
|
||||||
|
|
||||||
template <typename _InputIter, typename _Function>
|
template <typename _InputIter, typename _Function>
|
||||||
_Function
|
_Function
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace utils {
|
namespace rak {
|
||||||
|
|
||||||
template <typename Type, typename Ftor>
|
template <typename Type, typename Ftor>
|
||||||
struct _accumulate {
|
struct _accumulate {
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <curl/multi.h>
|
#include <curl/multi.h>
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
|
|
||||||
#include "utils/functional.h"
|
#include "rak/functional.h"
|
||||||
#include "curl_get.h"
|
#include "curl_get.h"
|
||||||
#include "curl_stack.h"
|
#include "curl_stack.h"
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ CurlStack::perform() {
|
|||||||
CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &t);
|
CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &t);
|
||||||
|
|
||||||
CurlGetList::iterator itr = std::find_if(m_getList.begin(), m_getList.end(),
|
CurlGetList::iterator itr = std::find_if(m_getList.begin(), m_getList.end(),
|
||||||
utils::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
|
rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
|
||||||
|
|
||||||
if (itr == m_getList.end())
|
if (itr == m_getList.end())
|
||||||
throw torrent::client_error("Could not find CurlGet with the right easy_handle");
|
throw torrent::client_error("Could not find CurlGet with the right easy_handle");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
|
|
||||||
#include "utils/functional.h"
|
#include "rak/functional.h"
|
||||||
|
|
||||||
#include "download.h"
|
#include "download.h"
|
||||||
#include "download_list.h"
|
#include "download_list.h"
|
||||||
@@ -32,7 +32,7 @@ DownloadList::erase(iterator itr) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::clear() {
|
DownloadList::clear() {
|
||||||
std::for_each(begin(), end(), utils::call_delete<Download>());
|
std::for_each(begin(), end(), rak::call_delete<Download>());
|
||||||
|
|
||||||
Base::clear();
|
Base::clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <sigc++/bind.h>
|
#include <sigc++/bind.h>
|
||||||
|
|
||||||
#include "download.h"
|
#include "download.h"
|
||||||
#include "utils/functional.h"
|
#include "rak/functional.h"
|
||||||
#include "hash_queue.h"
|
#include "hash_queue.h"
|
||||||
|
|
||||||
namespace core {
|
namespace core {
|
||||||
@@ -15,7 +15,7 @@ HashQueue::insert(Download* d, Slot s) {
|
|||||||
if (d->get_download().is_hash_checking())
|
if (d->get_download().is_hash_checking())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (std::find_if(begin(), end(), utils::equal(d, std::mem_fun(&HashQueueNode::get_download))) != end())
|
if (std::find_if(begin(), end(), rak::equal(d, std::mem_fun(&HashQueueNode::get_download))) != end())
|
||||||
throw std::logic_error("core::HashQueue::insert(...) received a Download that is already queued");
|
throw std::logic_error("core::HashQueue::insert(...) received a Download that is already queued");
|
||||||
|
|
||||||
if (d->get_download().is_hash_checked()) {
|
if (d->get_download().is_hash_checked()) {
|
||||||
@@ -32,7 +32,7 @@ HashQueue::insert(Download* d, Slot s) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
HashQueue::remove(Download* d) {
|
HashQueue::remove(Download* d) {
|
||||||
iterator itr = std::find_if(begin(), end(), utils::equal(d, std::mem_fun(&HashQueueNode::get_download)));
|
iterator itr = std::find_if(begin(), end(), rak::equal(d, std::mem_fun(&HashQueueNode::get_download)));
|
||||||
|
|
||||||
if (itr == end())
|
if (itr == end())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <sigc++/hide.h>
|
#include <sigc++/hide.h>
|
||||||
#include <torrent/http.h>
|
#include <torrent/http.h>
|
||||||
|
|
||||||
#include "utils/functional.h"
|
#include "rak/functional.h"
|
||||||
#include "http_queue.h"
|
#include "http_queue.h"
|
||||||
#include "curl_get.h"
|
#include "curl_get.h"
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -3,7 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils/functional.h"
|
#include "rak/functional.h"
|
||||||
|
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
@@ -16,8 +16,7 @@ Log::push_front(const std::string& msg) {
|
|||||||
|
|
||||||
Log::iterator
|
Log::iterator
|
||||||
Log::find_older(utils::Timer t) {
|
Log::find_older(utils::Timer t) {
|
||||||
return std::find_if(begin(), end(),
|
return std::find_if(begin(), end(), rak::on(rak::mem_ptr_ref(&Type::first), std::bind2nd(std::less_equal<utils::Timer>(), t)));
|
||||||
utils::on(utils::mem_ptr_ref(&Type::first), std::bind2nd(std::less_equal<utils::Timer>(), t)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "utils/functional.h"
|
#include "rak/functional.h"
|
||||||
|
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
@@ -26,8 +26,8 @@ Manager::adjust_layout() {
|
|||||||
int countDynamic = 0;
|
int countDynamic = 0;
|
||||||
int staticHeight = 0;
|
int staticHeight = 0;
|
||||||
|
|
||||||
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), utils::accumulate(staticHeight, std::mem_fun(&Window::get_min_height))));
|
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), rak::accumulate(staticHeight, std::mem_fun(&Window::get_min_height))));
|
||||||
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), utils::accumulate(countDynamic, std::mem_fun(&Window::is_dynamic))));
|
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), rak::accumulate(countDynamic, std::mem_fun(&Window::is_dynamic))));
|
||||||
|
|
||||||
int dynamic = std::max(0, Canvas::get_screen_height() - staticHeight);
|
int dynamic = std::max(0, Canvas::get_screen_height() - staticHeight);
|
||||||
int height = 0, h;
|
int height = 0, h;
|
||||||
@@ -56,9 +56,9 @@ void
|
|||||||
Manager::do_update() {
|
Manager::do_update() {
|
||||||
Canvas::refresh_std();
|
Canvas::refresh_std();
|
||||||
|
|
||||||
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), utils::if_then(std::mem_fun(&Window::is_dirty),
|
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), rak::if_then(std::mem_fun(&Window::is_dirty),
|
||||||
std::mem_fun(&Window::redraw))));
|
std::mem_fun(&Window::redraw))));
|
||||||
std::for_each(begin(), end(), utils::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
|
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
|
||||||
|
|
||||||
Canvas::do_update();
|
Canvas::do_update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "core/download.h"
|
#include "core/download.h"
|
||||||
#include "utils/algorithm.h"
|
#include "rak/algorithm.h"
|
||||||
|
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@@ -26,10 +26,10 @@ WindowDownloadList::redraw() {
|
|||||||
|
|
||||||
typedef std::pair<DList::iterator, DList::iterator> Range;
|
typedef std::pair<DList::iterator, DList::iterator> Range;
|
||||||
|
|
||||||
Range range = utils::advance_bidirectional(m_list->begin(),
|
Range range = rak::advance_bidirectional(m_list->begin(),
|
||||||
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
||||||
m_list->end(),
|
m_list->end(),
|
||||||
m_canvas->get_height() / 3);
|
m_canvas->get_height() / 3);
|
||||||
|
|
||||||
// Make sure we properly fill out the last lines so it looks like
|
// Make sure we properly fill out the last lines so it looks like
|
||||||
// there are more torrents, yet don't hide it if we got the last one
|
// there are more torrents, yet don't hide it if we got the last one
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "core/download.h"
|
#include "core/download.h"
|
||||||
#include "utils/algorithm.h"
|
#include "rak/algorithm.h"
|
||||||
|
|
||||||
#include "window_file_list.h"
|
#include "window_file_list.h"
|
||||||
|
|
||||||
@@ -37,8 +37,10 @@ WindowFileList::redraw() {
|
|||||||
|
|
||||||
typedef std::pair<unsigned int, unsigned int> Range;
|
typedef std::pair<unsigned int, unsigned int> Range;
|
||||||
|
|
||||||
Range range = utils::advance_bidirectional<unsigned int>(0, *m_focus, m_download->get_download().get_entry_size(),
|
Range range = rak::advance_bidirectional<unsigned int>(0,
|
||||||
m_canvas->get_height());
|
*m_focus,
|
||||||
|
m_download->get_download().get_entry_size(),
|
||||||
|
m_canvas->get_height());
|
||||||
|
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
torrent::Entry e = m_download->get_download().get_entry(range.first);
|
torrent::Entry e = m_download->get_download().get_entry(range.first);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "core/http_queue.h"
|
#include "core/http_queue.h"
|
||||||
|
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "utils/functional.h"
|
#include "rak/functional.h"
|
||||||
#include "window_http_queue.h"
|
#include "window_http_queue.h"
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
@@ -105,7 +105,7 @@ WindowHttpQueue::receive_insert(core::CurlGet* h) {
|
|||||||
void
|
void
|
||||||
WindowHttpQueue::receive_erase(core::CurlGet* h) {
|
WindowHttpQueue::receive_erase(core::CurlGet* h) {
|
||||||
Container::iterator itr = std::find_if(m_container.begin(), m_container.end(),
|
Container::iterator itr = std::find_if(m_container.begin(), m_container.end(),
|
||||||
utils::equal(h, std::mem_fun_ref(&Node::get_http)));
|
rak::equal(h, std::mem_fun_ref(&Node::get_http)));
|
||||||
|
|
||||||
if (itr == m_container.end())
|
if (itr == m_container.end())
|
||||||
throw std::logic_error("WindowHttpQueue::receive_erase(...) tried to remove an object we don't have");
|
throw std::logic_error("WindowHttpQueue::receive_erase(...) tried to remove an object we don't have");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "core/download.h"
|
#include "core/download.h"
|
||||||
#include "utils/algorithm.h"
|
#include "rak/algorithm.h"
|
||||||
|
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "window_peer_list.h"
|
#include "window_peer_list.h"
|
||||||
@@ -42,10 +42,10 @@ WindowPeerList::redraw() {
|
|||||||
|
|
||||||
typedef std::pair<PList::iterator, PList::iterator> Range;
|
typedef std::pair<PList::iterator, PList::iterator> Range;
|
||||||
|
|
||||||
Range range = utils::advance_bidirectional(m_list->begin(),
|
Range range = rak::advance_bidirectional(m_list->begin(),
|
||||||
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
*m_focus != m_list->end() ? *m_focus : m_list->begin(),
|
||||||
m_list->end(),
|
m_list->end(),
|
||||||
m_canvas->get_height() - y);
|
m_canvas->get_height() - y);
|
||||||
|
|
||||||
if (m_download->get_download().get_chunks_total() <= 0)
|
if (m_download->get_download().get_chunks_total() <= 0)
|
||||||
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
|
throw std::logic_error("WindowPeerList::redraw() m_slotChunksTotal() returned invalid value");
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
noinst_LIBRARIES = libsub_utils.a
|
noinst_LIBRARIES = libsub_utils.a
|
||||||
|
|
||||||
libsub_utils_a_SOURCES = \
|
libsub_utils_a_SOURCES = \
|
||||||
algorithm.h \
|
|
||||||
directory.cc \
|
directory.cc \
|
||||||
directory.h \
|
directory.h \
|
||||||
functional.h \
|
|
||||||
parse.cc \
|
parse.cc \
|
||||||
parse.h \
|
parse.h \
|
||||||
task.h \
|
task.h \
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#include "functional.h"
|
|
||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|||||||
Reference in New Issue
Block a user