diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-04-21 14:52:04 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-04-21 14:52:04 +0000 |
| commit | afdd61f9d115b9e8e3a0078e818c9275abfc110c (patch) | |
| tree | 2e316bf17a31ba8d8794041d255bce4b0519857f /src/a2functional.h | |
| parent | 82b0d66505606e29ca949d57542b3d2260d08c96 (diff) | |
2009-04-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten event dispatch in BtMessage. Removed BtEventListener,
BtEvent.
* src/AbstractBtEventListener.h: Removed.
* src/AbstractBtMessage.cc
* src/AbstractBtMessage.h
* src/BtAbortOutstandingRequestEvent.h
* src/BtCancelSendingPieceEvent.h
* src/BtChokedEvent.h: Removed.
* src/BtChokingEvent.h
* src/BtEvent.h: Removed
* src/BtEventListener.h: Removed.
* src/BtMessage.h
* src/BtPieceMessage.cc
* src/BtPieceMessage.h
* src/BtRequestMessage.cc
* src/BtRequestMessage.h
* src/DefaultBtMessageDispatcher.cc
* src/Makefile.am
* src/a2functional.h
* test/BtPieceMessageTest.cc
* test/BtRequestMessageTest.cc
* test/DefaultBtMessageDispatcherTest.cc
* test/MockBtMessage.h
Diffstat (limited to 'src/a2functional.h')
| -rw-r--r-- | src/a2functional.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/a2functional.h b/src/a2functional.h index 447027d2..fb8c4745 100644 --- a/src/a2functional.h +++ b/src/a2functional.h @@ -88,6 +88,31 @@ mem_fun_sh(ReturnType (ClassType::*f)() const) return const_mem_fun_sh_t<ReturnType, ClassType>(f); }; +// mem_fun1_t for SharedHandle +template<typename ReturnType, typename ClassType, typename ArgType> +class mem_fun1_sh_t:public std::binary_function<SharedHandle<ClassType>, + ArgType, + ReturnType> +{ +private: + ReturnType (ClassType::*f)(ArgType); + +public: + mem_fun1_sh_t(ReturnType (ClassType::*f)(ArgType)):f(f) {} + + ReturnType operator()(const SharedHandle<ClassType>& x, ArgType a) const + { + return (x.get()->*f)(a); + } +}; + +template<typename ReturnType, typename ClassType, typename ArgType> +mem_fun1_sh_t<ReturnType, ClassType, ArgType> +mem_fun_sh(ReturnType (ClassType::*f)(ArgType)) +{ + return mem_fun1_sh_t<ReturnType, ClassType, ArgType>(f); +}; + template<class BinaryOp, class UnaryOp> class adopt2nd_t:public std::binary_function<typename BinaryOp::first_argument_type, typename UnaryOp::argument_type, |
