From 00a349f68c18b2171626707454b7da37a4a50178 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 27 Aug 2013 23:18:31 +0900 Subject: [PATCH] Added slot_call_list. --- rak/functional.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/rak/functional.h b/rak/functional.h index cc149dbf..ac77b2da 100644 --- a/rak/functional.h +++ b/rak/functional.h @@ -627,6 +627,57 @@ make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) { return mem_fun3(o, f); } +template +inline void +slot_list_call(const Container& slot_list) { + if (slot_list.empty()) + return; + + typename Container::const_iterator first = slot_list.begin(); + typename Container::const_iterator next = slot_list.begin(); + + while (++next != slot_list.end()) { + (*first)(); + first = next; + } + + (*first)(); +} + +template +inline void +slot_list_call(const Container& slot_list, Arg1 arg1) { + if (slot_list.empty()) + return; + + typename Container::const_iterator first = slot_list.begin(); + typename Container::const_iterator next = slot_list.begin(); + + while (++next != slot_list.end()) { + (*first)(arg1); + first = next; + } + + (*first)(arg1); +} + +template +inline void +slot_list_call(const Container& slot_list, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) { + if (slot_list.empty()) + return; + + typename Container::const_iterator first = slot_list.begin(); + typename Container::const_iterator next = slot_list.begin(); + + while (++next != slot_list.end()) { + (*first)(arg1, arg2, arg3, arg4); + first = next; + } + + (*first)(arg1, arg2, arg3, arg4); +} + } #endif