Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Remove rak mem_fun #1372

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 0 additions & 169 deletions rak/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,175 +445,6 @@ bind2nd(const Operation& op, const Type& val) {
// be replaced by TR1 stuff later. Requires an object to bind, instead
// of using a seperate functor for that.

template <typename Ret>
class ptr_fun0 {
public:
typedef Ret result_type;
typedef Ret (*Function)();

ptr_fun0() {}
ptr_fun0(Function f) : m_function(f) {}

bool is_valid() const { return m_function; }

Ret operator () () { return m_function(); }

private:
Function m_function;
};

template <typename Object, typename Ret>
class mem_fun0 {
public:
typedef Ret result_type;
typedef Ret (Object::*Function)();

mem_fun0() : m_object(NULL) {}
mem_fun0(Object* o, Function f) : m_object(o), m_function(f) {}

bool is_valid() const { return m_object; }

Ret operator () () { return (m_object->*m_function)(); }

private:
Object* m_object;
Function m_function;
};

template <typename Object, typename Ret>
class const_mem_fun0 {
public:
typedef Ret result_type;
typedef Ret (Object::*Function)() const;

const_mem_fun0() : m_object(NULL) {}
const_mem_fun0(const Object* o, Function f) : m_object(o), m_function(f) {}

bool is_valid() const { return m_object; }

Ret operator () () const { return (m_object->*m_function)(); }

private:
const Object* m_object;
Function m_function;
};

template <typename Object, typename Ret, typename Arg1>
class mem_fun1 {
public:
typedef Ret result_type;
typedef Ret (Object::*Function)(Arg1);

mem_fun1() : m_object(NULL) {}
mem_fun1(Object* o, Function f) : m_object(o), m_function(f) {}

bool is_valid() const { return m_object; }

Ret operator () (Arg1 a1) { return (m_object->*m_function)(a1); }

private:
Object* m_object;
Function m_function;
};

template <typename Object, typename Ret, typename Arg1>
class const_mem_fun1 {
public:
typedef Ret result_type;
typedef Ret (Object::*Function)(Arg1) const;

const_mem_fun1() : m_object(NULL) {}
const_mem_fun1(const Object* o, Function f) : m_object(o), m_function(f) {}

bool is_valid() const { return m_object; }

Ret operator () (Arg1 a1) const { return (m_object->*m_function)(a1); }

private:
const Object* m_object;
Function m_function;
};

template <typename Object, typename Ret, typename Arg1, typename Arg2>
class mem_fun2 : public std::binary_function<Arg1, Arg2, Ret> {
public:
typedef Ret result_type;
typedef Ret (Object::*Function)(Arg1, Arg2);
typedef Object object_type;

mem_fun2() : m_object(NULL) {}
mem_fun2(Object* o, Function f) : m_object(o), m_function(f) {}

bool is_valid() const { return m_object; }

object_type* object() { return m_object; }
const object_type* object() const { return m_object; }

Ret operator () (Arg1 a1, Arg2 a2) { return (m_object->*m_function)(a1, a2); }

private:
Object* m_object;
Function m_function;
};

template <typename Object, typename Ret, typename Arg1, typename Arg2, typename Arg3>
class mem_fun3 {
public:
typedef Ret result_type;
typedef Ret (Object::*Function)(Arg1, Arg2, Arg3);

mem_fun3() : m_object(NULL) {}
mem_fun3(Object* o, Function f) : m_object(o), m_function(f) {}

bool is_valid() const { return m_object; }

Ret operator () (Arg1 a1, Arg2 a2, Arg3 a3) { return (m_object->*m_function)(a1, a2, a3); }

private:
Object* m_object;
Function m_function;
};

template <typename Ret>
inline ptr_fun0<Ret>
ptr_fun(Ret (*f)()) { return ptr_fun0<Ret>(f); }

template <typename Object, typename Ret>
inline mem_fun0<Object, Ret>
make_mem_fun(Object* o, Ret (Object::*f)()) {
return mem_fun0<Object, Ret>(o, f);
}

template <typename Object, typename Ret>
inline const_mem_fun0<Object, Ret>
make_mem_fun(const Object* o, Ret (Object::*f)() const) {
return const_mem_fun0<Object, Ret>(o, f);
}

template <typename Object, typename Ret, typename Arg1>
inline mem_fun1<Object, Ret, Arg1>
make_mem_fun(Object* o, Ret (Object::*f)(Arg1)) {
return mem_fun1<Object, Ret, Arg1>(o, f);
}

template <typename Object, typename Ret, typename Arg1>
inline const_mem_fun1<Object, Ret, Arg1>
make_mem_fun(const Object* o, Ret (Object::*f)(Arg1) const) {
return const_mem_fun1<Object, Ret, Arg1>(o, f);
}

template <typename Object, typename Ret, typename Arg1, typename Arg2>
inline mem_fun2<Object, Ret, Arg1, Arg2>
make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2)) {
return mem_fun2<Object, Ret, Arg1, Arg2>(o, f);
}

template <typename Object, typename Ret, typename Arg1, typename Arg2, typename Arg3>
inline mem_fun3<Object, Ret, Arg1, Arg2, Arg3>
make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) {
return mem_fun3<Object, Ret, Arg1, Arg2, Arg3>(o, f);
}

template <typename Container>
inline void
slot_list_call(const Container& slot_list) {
Expand Down
6 changes: 3 additions & 3 deletions src/control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ Control::~Control() {
void
Control::initialize() {
display::Canvas::initialize();
display::Window::slot_schedule(rak::make_mem_fun(m_display, &display::Manager::schedule));
display::Window::slot_unschedule(rak::make_mem_fun(m_display, &display::Manager::unschedule));
display::Window::slot_adjust(rak::make_mem_fun(m_display, &display::Manager::adjust_layout));
display::Window::slot_schedule([this](display::Window* w, rak::timer t) { m_display->schedule(w, t); });
display::Window::slot_unschedule([this](display::Window* w) { m_display->unschedule(w); });
display::Window::slot_adjust([this]() { m_display->adjust_layout(); });

m_core->http_stack()->set_user_agent(USER_AGENT);

Expand Down
9 changes: 4 additions & 5 deletions src/display/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,22 @@
#define RTORRENT_WINDOW_BASE_H

#include <rak/timer.h>
#include <rak/functional.h>
#include <functional>

#include "canvas.h"
#include "globals.h"

namespace display {

class Canvas;
class Manager;

class Window {
public:
typedef uint32_t extent_type;

typedef rak::mem_fun0<Manager, void> Slot;
typedef rak::mem_fun1<Manager, void, Window*> SlotWindow;
typedef rak::mem_fun2<Manager, void, Window*, rak::timer> SlotTimer;
typedef std::function<void()> Slot;
typedef std::function<void(Window*)> SlotWindow;
typedef std::function<void(Window*, rak::timer)> SlotTimer;

static const int flag_active = (1 << 0);
static const int flag_offscreen = (1 << 1);
Expand Down
2 changes: 2 additions & 0 deletions src/ui/element_peer_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#include "config.h"

#include <rak/functional.h>

#include <torrent/exceptions.h>
#include <torrent/rate.h>
#include <torrent/hash_string.h>
Expand Down