* Replaced some sigc++ slots with lightweight callback classes.

* Almost done with global choke management, only need to sort and
debug. The API to change the setting will be added after the next
release.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@569 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-09-22 12:09:55 +00:00
parent 108ad78d30
commit 88b8afe025
+27
View File
@@ -338,6 +338,33 @@ bind2nd(const Operation& op, const Type& val) {
return bind2nd_t<Operation>(op, val); return bind2nd_t<Operation>(op, val);
} }
// Lightweight callback function including pointer to object. Should
// 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_fn {
public:
typedef Ret (Object::*Function)();
mem_fn() : m_object(NULL) {}
mem_fn(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>
inline mem_fn<Object, Ret>
make_mem_fn(Object* o, Ret (Object::*f)()) {
return mem_fn<Object, Ret>(o, f);
}
} }
#endif #endif