mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-13 04:36:16 +00:00
* Replaced most of the internal sigc++ slots and signals with a
lightweight version. This cut the size of the library w/debug by more than 300kb. All (almost) the signals the client connects to are now in DownloadWrapper. * Fixed off-by-one error in the month displayed. * Moved tracker url cleanup to src/parse and improved it. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@580 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+72
-9
@@ -339,17 +339,11 @@ bind2nd(const Operation& op, const Type& val) {
|
||||
}
|
||||
|
||||
// Lightweight callback function including pointer to object. Should
|
||||
// be replaced by TR1 stuff later.
|
||||
|
||||
template <typename Ret>
|
||||
class function0 {
|
||||
public:
|
||||
virtual bool is_valid() const = 0;
|
||||
virtual Ret operator () () = 0;
|
||||
};
|
||||
// be replaced by TR1 stuff later. Requires an object to bind, instead
|
||||
// of using a seperate functor for that.
|
||||
|
||||
template <typename Object, typename Ret>
|
||||
class mem_fn0 : public function0<Ret> {
|
||||
class mem_fn0 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)();
|
||||
|
||||
@@ -365,6 +359,23 @@ private:
|
||||
Function m_function;
|
||||
};
|
||||
|
||||
template <typename Object, typename Ret>
|
||||
class const_mem_fn0 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)() const;
|
||||
|
||||
const_mem_fn0() : m_object(NULL) {}
|
||||
const_mem_fn0(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, typename Arg1>
|
||||
class mem_fn1 {
|
||||
public:
|
||||
@@ -382,18 +393,70 @@ private:
|
||||
Function m_function;
|
||||
};
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1, typename Arg2>
|
||||
class mem_fn2 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)(Arg1, Arg2);
|
||||
|
||||
mem_fn2() : m_object(NULL) {}
|
||||
mem_fn2(Object* o, Function f) : m_object(o), m_function(f) {}
|
||||
|
||||
bool is_valid() 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_fn3 {
|
||||
public:
|
||||
typedef Ret (Object::*Function)(Arg1, Arg2, Arg3);
|
||||
|
||||
mem_fn3() : m_object(NULL) {}
|
||||
mem_fn3(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 Object, typename Ret>
|
||||
inline mem_fn0<Object, Ret>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)()) {
|
||||
return mem_fn0<Object, Ret>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret>
|
||||
inline const_mem_fn0<Object, Ret>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)() const) {
|
||||
return const_mem_fn0<Object, Ret>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1>
|
||||
inline mem_fn1<Object, Ret, Arg1>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)(Arg1)) {
|
||||
return mem_fn1<Object, Ret, Arg1>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1, typename Arg2>
|
||||
inline mem_fn2<Object, Ret, Arg1, Arg2>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)(Arg1, Arg2)) {
|
||||
return mem_fn2<Object, Ret, Arg1, Arg2>(o, f);
|
||||
}
|
||||
|
||||
template <typename Object, typename Ret, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline mem_fn3<Object, Ret, Arg1, Arg2, Arg3>
|
||||
make_mem_fn(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) {
|
||||
return mem_fn3<Object, Ret, Arg1, Arg2, Arg3>(o, f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user