From 138d3f4d3d6e2aaf5ba34f89af15ef85ea074357 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 8 Nov 2021 09:23:38 +0800 Subject: *misc --- Runtime/Lua/LuaBind/signal/bind.h | 510 --------------------- Runtime/Lua/LuaBind/signal/remove_from_container.h | 32 -- Runtime/Lua/LuaBind/signal/signal.h | 451 ------------------ Runtime/Lua/LuaBind/signal/slot.h | 203 -------- 4 files changed, 1196 deletions(-) delete mode 100644 Runtime/Lua/LuaBind/signal/bind.h delete mode 100644 Runtime/Lua/LuaBind/signal/remove_from_container.h delete mode 100644 Runtime/Lua/LuaBind/signal/signal.h delete mode 100644 Runtime/Lua/LuaBind/signal/slot.h (limited to 'Runtime/Lua/LuaBind/signal') diff --git a/Runtime/Lua/LuaBind/signal/bind.h b/Runtime/Lua/LuaBind/signal/bind.h deleted file mode 100644 index e29896b..0000000 --- a/Runtime/Lua/LuaBind/signal/bind.h +++ /dev/null @@ -1,510 +0,0 @@ -// Aseprite Base Library -// Copyright (c) 2001-2013 David Capello -// -// This file is released under the terms of the MIT license. -// Read LICENSE.txt for more information. - -#ifndef BASE_BIND_H_INCLUDED -#define BASE_BIND_H_INCLUDED -#pragma once - -// BindAdapter0_fun -template -class BindAdapter0_fun -{ - F f; -public: - BindAdapter0_fun(const F& f) : f(f) { } - - R operator()() { return f(); } - - template - R operator()(const A1& a1) { return f(); } - - template - R operator()(const A1& a1, const A2& a2) { return f(); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return f(); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return f(); } -}; - -template -class BindAdapter0_fun -{ - F f; -public: - BindAdapter0_fun(const F& f) : f(f) { } - - void operator()() { f(); } - - template - void operator()(const A1& a1) { f(); } - - template - void operator()(const A1& a1, const A2& a2) { f(); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { f(); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { f(); } -}; - -template -BindAdapter0_fun -Bind(const F& f) -{ - return BindAdapter0_fun(f); -} - -// BindAdapter0_mem -template -class BindAdapter0_mem -{ - R (T::*m)(); - T* t; -public: - template - BindAdapter0_mem(R (T::*m)(), T2* t) : m(m), t(t) { } - - R operator()() { return (t->*m)(); } - - template - R operator()(const A1& a1) { return (t->*m)(); } - - template - R operator()(const A1& a1, const A2& a2) { return (t->*m)(); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return (t->*m)(); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return (t->*m)(); } -}; - -template -class BindAdapter0_mem -{ - void (T::*m)(); - T* t; -public: - template - BindAdapter0_mem(void (T::*m)(), T2* t) : m(m), t(t) { } - - void operator()() { (t->*m)(); } - - template - void operator()(const A1& a1) { (t->*m)(); } - - template - void operator()(const A1& a1, const A2& a2) { (t->*m)(); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { (t->*m)(); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { (t->*m)(); } -}; - -template -BindAdapter0_mem -Bind(R (T::*m)(), T2* t) -{ - return BindAdapter0_mem(m, t); -} - -// BindAdapter1_fun -template -class BindAdapter1_fun -{ - F f; - X1 x1; -public: - BindAdapter1_fun(const F& f, X1 x1) : f(f), x1(x1) { } - - R operator()() { return f(x1); } - - template - R operator()(const A1& a1) { return f(x1); } - - template - R operator()(const A1& a1, const A2& a2) { return f(x1); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return f(x1); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return f(x1); } -}; - -template -class BindAdapter1_fun -{ - F f; - X1 x1; -public: - BindAdapter1_fun(const F& f, X1 x1) : f(f), x1(x1) { } - - void operator()() { f(x1); } - - template - void operator()(const A1& a1) { f(x1); } - - template - void operator()(const A1& a1, const A2& a2) { f(x1); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { f(x1); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { f(x1); } -}; - -template -BindAdapter1_fun -Bind(const F& f, X1 x1) -{ - return BindAdapter1_fun(f, x1); -} - -// BindAdapter1_mem -template -class BindAdapter1_mem -{ - R (T::*m)(B1); - T* t; - X1 x1; -public: - template - BindAdapter1_mem(R (T::*m)(B1), T2* t, X1 x1) : m(m), t(t), x1(x1) { } - - R operator()() { return (t->*m)(x1); } - - template - R operator()(const A1& a1) { return (t->*m)(x1); } - - template - R operator()(const A1& a1, const A2& a2) { return (t->*m)(x1); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return (t->*m)(x1); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return (t->*m)(x1); } -}; - -template -class BindAdapter1_mem -{ - void (T::*m)(B1); - T* t; - X1 x1; -public: - template - BindAdapter1_mem(void (T::*m)(B1), T2* t, X1 x1) : m(m), t(t), x1(x1) { } - - void operator()() { (t->*m)(x1); } - - template - void operator()(const A1& a1) { (t->*m)(x1); } - - template - void operator()(const A1& a1, const A2& a2) { (t->*m)(x1); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { (t->*m)(x1); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { (t->*m)(x1); } -}; - -template -BindAdapter1_mem -Bind(R (T::*m)(B1), T2* t, X1 x1) -{ - return BindAdapter1_mem(m, t, x1); -} - -// BindAdapter2_fun -template -class BindAdapter2_fun -{ - F f; - X1 x1; - X2 x2; -public: - BindAdapter2_fun(const F& f, X1 x1, X2 x2) : f(f), x1(x1), x2(x2) { } - - R operator()() { return f(x1, x2); } - - template - R operator()(const A1& a1) { return f(x1, x2); } - - template - R operator()(const A1& a1, const A2& a2) { return f(x1, x2); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return f(x1, x2); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return f(x1, x2); } -}; - -template -class BindAdapter2_fun -{ - F f; - X1 x1; - X2 x2; -public: - BindAdapter2_fun(const F& f, X1 x1, X2 x2) : f(f), x1(x1), x2(x2) { } - - void operator()() { f(x1, x2); } - - template - void operator()(const A1& a1) { f(x1, x2); } - - template - void operator()(const A1& a1, const A2& a2) { f(x1, x2); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { f(x1, x2); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { f(x1, x2); } -}; - -template -BindAdapter2_fun -Bind(const F& f, X1 x1, X2 x2) -{ - return BindAdapter2_fun(f, x1, x2); -} - -// BindAdapter2_mem -template -class BindAdapter2_mem -{ - R (T::*m)(B1, B2); - T* t; - X1 x1; - X2 x2; -public: - template - BindAdapter2_mem(R (T::*m)(B1, B2), T2* t, X1 x1, X2 x2) : m(m), t(t), x1(x1), x2(x2) { } - - R operator()() { return (t->*m)(x1, x2); } - - template - R operator()(const A1& a1) { return (t->*m)(x1, x2); } - - template - R operator()(const A1& a1, const A2& a2) { return (t->*m)(x1, x2); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return (t->*m)(x1, x2); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return (t->*m)(x1, x2); } -}; - -template -class BindAdapter2_mem -{ - void (T::*m)(B1, B2); - T* t; - X1 x1; - X2 x2; -public: - template - BindAdapter2_mem(void (T::*m)(B1, B2), T2* t, X1 x1, X2 x2) : m(m), t(t), x1(x1), x2(x2) { } - - void operator()() { (t->*m)(x1, x2); } - - template - void operator()(const A1& a1) { (t->*m)(x1, x2); } - - template - void operator()(const A1& a1, const A2& a2) { (t->*m)(x1, x2); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { (t->*m)(x1, x2); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { (t->*m)(x1, x2); } -}; - -template -BindAdapter2_mem -Bind(R (T::*m)(B1, B2), T2* t, X1 x1, X2 x2) -{ - return BindAdapter2_mem(m, t, x1, x2); -} - -// BindAdapter3_fun -template -class BindAdapter3_fun -{ - F f; - X1 x1; - X2 x2; - X3 x3; -public: - BindAdapter3_fun(const F& f, X1 x1, X2 x2, X3 x3) : f(f), x1(x1), x2(x2), x3(x3) { } - - R operator()() { return f(x1, x2, x3); } - - template - R operator()(const A1& a1) { return f(x1, x2, x3); } - - template - R operator()(const A1& a1, const A2& a2) { return f(x1, x2, x3); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return f(x1, x2, x3); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return f(x1, x2, x3); } -}; - -template -class BindAdapter3_fun -{ - F f; - X1 x1; - X2 x2; - X3 x3; -public: - BindAdapter3_fun(const F& f, X1 x1, X2 x2, X3 x3) : f(f), x1(x1), x2(x2), x3(x3) { } - - void operator()() { f(x1, x2, x3); } - - template - void operator()(const A1& a1) { f(x1, x2, x3); } - - template - void operator()(const A1& a1, const A2& a2) { f(x1, x2, x3); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { f(x1, x2, x3); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { f(x1, x2, x3); } -}; - -template -BindAdapter3_fun -Bind(const F& f, X1 x1, X2 x2, X3 x3) -{ - return BindAdapter3_fun(f, x1, x2, x3); -} - -// BindAdapter3_mem -template -class BindAdapter3_mem -{ - R (T::*m)(B1, B2, B3); - T* t; - X1 x1; - X2 x2; - X3 x3; -public: - template - BindAdapter3_mem(R (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2, X3 x3) : m(m), t(t), x1(x1), x2(x2), x3(x3) { } - - R operator()() { return (t->*m)(x1, x2, x3); } - - template - R operator()(const A1& a1) { return (t->*m)(x1, x2, x3); } - - template - R operator()(const A1& a1, const A2& a2) { return (t->*m)(x1, x2, x3); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3) { return (t->*m)(x1, x2, x3); } - - template - R operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { return (t->*m)(x1, x2, x3); } -}; - -template -class BindAdapter3_mem -{ - void (T::*m)(B1, B2, B3); - T* t; - X1 x1; - X2 x2; - X3 x3; -public: - template - BindAdapter3_mem(void (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2) : m(m), t(t), x1(x1), x2(x2) { } - - void operator()() { (t->*m)(x1, x2, x3); } - - template - void operator()(const A1& a1) { (t->*m)(x1, x2, x3); } - - template - void operator()(const A1& a1, const A2& a2) { (t->*m)(x1, x2, x3); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3) { (t->*m)(x1, x2, x3); } - - template - void operator()(const A1& a1, const A2& a2, const A3& a3, const A4& a4) { (t->*m)(x1, x2, x3); } -}; - -template -BindAdapter3_mem -Bind(R (T::*m)(B1, B2, B3), T2* t, X1 x1, X2 x2) -{ - return BindAdapter3_mem(m, t, x1, x2); -} - -// Helper class to holds references as pointers (to avoid copying the -// original object). -template -class RefWrapper -{ - T* ptr; -public: - RefWrapper(T& ref) : ptr(&ref) { } - operator T&() const { return *ptr; } -}; - -// Creates RefWrappers, useful to wrap arguments that have to be -// passed as a reference when you use Bind. -template -RefWrapper Ref(T& ref) -{ - return RefWrapper(ref); -} - -#endif diff --git a/Runtime/Lua/LuaBind/signal/remove_from_container.h b/Runtime/Lua/LuaBind/signal/remove_from_container.h deleted file mode 100644 index 9fdc442..0000000 --- a/Runtime/Lua/LuaBind/signal/remove_from_container.h +++ /dev/null @@ -1,32 +0,0 @@ -// Aseprite Base Library -// Copyright (c) 2001-2013 David Capello -// -// This file is released under the terms of the MIT license. -// Read LICENSE.txt for more information. - -#ifndef BASE_REMOVE_FROM_CONTAINER_H_INCLUDED -#define BASE_REMOVE_FROM_CONTAINER_H_INCLUDED -#pragma once - -namespace base { - -// Removes all ocurrences of the specified element from the STL container. -template -void remove_from_container(ContainerType& container, - typename ContainerType::const_reference element) -{ - for (typename ContainerType::iterator - it = container.begin(), - end = container.end(); it != end; ) { - if (*it == element) { - it = container.erase(it); - end = container.end(); - } - else - ++it; - } -} - -} - -#endif diff --git a/Runtime/Lua/LuaBind/signal/signal.h b/Runtime/Lua/LuaBind/signal/signal.h deleted file mode 100644 index 97882c6..0000000 --- a/Runtime/Lua/LuaBind/signal/signal.h +++ /dev/null @@ -1,451 +0,0 @@ -// Aseprite Base Library -// Copyright (c) 2001-2013 David Capello -// -// This file is released under the terms of the MIT license. -// Read LICENSE.txt for more information. - -#ifndef BASE_SIGNAL_H_INCLUDED -#define BASE_SIGNAL_H_INCLUDED -#pragma once - -//#include "base/slot.h" -//#include "base/remove_from_container.h" - -#include "./slot.h" -#include "./remove_from_container.h" - -#include - -// Signal0_base - Base class to delegate responsibility to -// functions of zero arguments. -template -class Signal0_base -{ -public: - typedef R ReturnType; - typedef Slot0 SlotType; - typedef std::vector SlotList; - -protected: - SlotList m_slots; - -public: - Signal0_base() { } - Signal0_base(const Signal0_base& s) - { - copy(s); - } - ~Signal0_base() - { - disconnectAll(); - } - - SlotType* addSlot(SlotType* slot) - { - m_slots.push_back(slot); - return slot; - } - - template - SlotType* connect(const F& f) - { - return addSlot(new Slot0_fun(f)); - } - - template - SlotType* connect(R (T::*m)(), T* t) - { - return addSlot(new Slot0_mem(m, t)); - } - - const SlotList& getSlots() const - { - return m_slots; - } - - void disconnect(SlotType* slot) - { - base::remove_from_container(m_slots, slot); - } - - void disconnectAll() - { - typename SlotList::iterator end = m_slots.end(); - for (typename SlotList::iterator - it = m_slots.begin(); it != end; ++it) - delete *it; - m_slots.clear(); - } - - bool empty() const - { - return m_slots.empty(); - } - - Signal0_base& operator=(const Signal0_base& s) { - copy(s); - return *this; - } - -private: - - void copy(const Signal0_base& s) - { - typename SlotList::const_iterator end = s.m_slots.end(); - for (typename SlotList::const_iterator - it = s.m_slots.begin(); it != end; ++it) { - m_slots.push_back((*it)->clone()); - } - } - -}; - -// Signal0 -template -class Signal0 : public Signal0_base -{ -public: - Signal0() { } - - Signal0(const Signal0& s) - : Signal0_base(s) { } - - R operator()(R default_result = R()) - { - R result(default_result); - typename Signal0_base::SlotList::iterator end = Signal0_base::m_slots.end(); - for (typename Signal0_base::SlotList::iterator - it = Signal0_base::m_slots.begin(); it != end; ++it) { - typename Signal0_base::SlotType* slot = *it; - result = (*slot)(); - } - return result; - } - - template - R operator()(R default_result, const Merger& m) - { - R result(default_result); - Merger merger(m); - typename Signal0_base::SlotList::iterator end = Signal0_base::m_slots.end(); - for (typename Signal0_base::SlotList::iterator - it = Signal0_base::m_slots.begin(); it != end; ++it) { - typename Signal0_base::SlotType* slot = *it; - result = merger(result, (*slot)()); - } - return result; - } - -}; - -// Signal0 -template<> -class Signal0 : public Signal0_base -{ -public: - Signal0() { } - - Signal0(const Signal0& s) - : Signal0_base(s) { } - - void operator()() - { - SlotList::iterator end = m_slots.end(); - for (SlotList::iterator - it = m_slots.begin(); it != end; ++it) { - SlotType* slot = *it; - (*slot)(); - } - } - -}; - -// Signal1_base - Base class to delegate responsibility to -// functions of one argument. -template -class Signal1_base -{ -public: - typedef R ReturnType; - typedef Slot1 SlotType; - typedef std::vector SlotList; - -protected: - SlotList m_slots; - -public: - Signal1_base() { } - Signal1_base(const Signal1_base& s) - { - copy(s); - } - ~Signal1_base() - { - disconnectAll(); - } - - SlotType* addSlot(SlotType* slot) - { - m_slots.push_back(slot); - return slot; - } - - template - SlotType* connect(const F& f) - { - return addSlot(new Slot1_fun(f)); - } - - template - SlotType* connect(R (T::*m)(A1), T* t) - { - return addSlot(new Slot1_mem(m, t)); - } - - const SlotList& getSlots() const - { - return m_slots; - } - - void disconnect(SlotType* slot) - { - base::remove_from_container(m_slots, slot); - } - - void disconnectAll() - { - typename SlotList::iterator end = m_slots.end(); - for (typename SlotList::iterator - it = m_slots.begin(); it != end; ++it) - delete *it; - m_slots.clear(); - } - - bool empty() const - { - return m_slots.empty(); - } - - Signal1_base& operator=(const Signal1_base& s) { - copy(s); - return *this; - } - -private: - - void copy(const Signal1_base& s) - { - typename SlotList::const_iterator end = s.m_slots.end(); - for (typename SlotList::const_iterator - it = s.m_slots.begin(); it != end; ++it) { - m_slots.push_back((*it)->clone()); - } - } - -}; - -// Signal1 -template -class Signal1 : public Signal1_base -{ -public: - Signal1() { } - - Signal1(const Signal1& s) - : Signal1_base(s) { } - - R operator()(A1 a1, R default_result = R()) - { - R result(default_result); - typename Signal1_base::SlotList::iterator end = Signal1_base::m_slots.end(); - for (typename Signal1_base::SlotList::iterator - it = Signal1_base::m_slots.begin(); it != end; ++it) { - typename Signal1_base::SlotType* slot = *it; - result = (*slot)(a1); - } - return result; - } - - template - R operator()(A1 a1, R default_result, const Merger& m) - { - R result(default_result); - Merger merger(m); - typename Signal1_base::SlotList::iterator end = Signal1_base::m_slots.end(); - for (typename Signal1_base::SlotList::iterator - it = Signal1_base::m_slots.begin(); it != end; ++it) { - typename Signal1_base::SlotType* slot = *it; - result = merger(result, (*slot)(a1)); - } - return result; - } - -}; - -// Signal1 -template -class Signal1 : public Signal1_base -{ -public: - Signal1() { } - - Signal1(const Signal1& s) - : Signal1_base(s) { } - - void operator()(A1 a1) - { - typename Signal1_base::SlotList::iterator end = Signal1_base::m_slots.end(); - for (typename Signal1_base::SlotList::iterator - it = Signal1_base::m_slots.begin(); it != end; ++it) { - typename Signal1_base::SlotType* slot = *it; - (*slot)(a1); - } - } - -}; - -// Signal2_base - Base class to delegate responsibility to -// functions of two arguments. -template -class Signal2_base -{ -public: - typedef R ReturnType; - typedef Slot2 SlotType; - typedef std::vector SlotList; - -protected: - SlotList m_slots; - -public: - Signal2_base() { } - Signal2_base(const Signal2_base& s) - { - copy(s); - } - ~Signal2_base() - { - disconnectAll(); - } - - SlotType* addSlot(SlotType* slot) - { - m_slots.push_back(slot); - return slot; - } - - template - SlotType* connect(const F& f) - { - return addSlot(new Slot2_fun(f)); - } - - template - SlotType* connect(R (T::*m)(A1, A2), T* t) - { - return addSlot(new Slot2_mem(m, t)); - } - - const SlotList& getSlots() const - { - return m_slots; - } - - void disconnect(SlotType* slot) - { - base::remove_from_container(m_slots, slot); - } - - void disconnectAll() - { - typename SlotList::iterator end = m_slots.end(); - for (typename SlotList::iterator - it = m_slots.begin(); it != end; ++it) - delete *it; - m_slots.clear(); - } - - bool empty() const - { - return m_slots.empty(); - } - - Signal2_base& operator=(const Signal2_base& s) { - copy(s); - return *this; - } - -private: - - void copy(const Signal2_base& s) - { - typename SlotList::const_iterator end = s.m_slots.end(); - for (typename SlotList::const_iterator - it = s.m_slots.begin(); it != end; ++it) { - m_slots.push_back((*it)->clone()); - } - } - -}; - -// Signal2 -template -class Signal2 : public Signal2_base -{ -public: - Signal2() { } - - Signal2(const Signal2& s) - : Signal2_base(s) { } - - R operator()(A1 a1, A2 a2, R default_result = R()) - { - R result(default_result); - typename Signal2_base::SlotList::iterator end = Signal2_base::m_slots.end(); - for (typename Signal2_base::SlotList::iterator - it = Signal2_base::m_slots.begin(); it != end; ++it) { - typename Signal2_base::SlotType* slot = *it; - result = (*slot)(a1, a2); - } - return result; - } - - template - R operator()(A1 a1, A2 a2, R default_result, const Merger& m) - { - R result(default_result); - Merger merger(m); - typename Signal2_base::SlotList::iterator end = Signal2_base::m_slots.end(); - for (typename Signal2_base::SlotList::iterator - it = Signal2_base::m_slots.begin(); it != end; ++it) { - typename Signal2_base::SlotType* slot = *it; - result = merger(result, (*slot)(a1, a2)); - } - return result; - } - -}; - -// Signal2 -template -class Signal2 : public Signal2_base -{ -public: - Signal2() { } - - Signal2(const Signal2& s) - : Signal2_base(s) { } - - void operator()(A1 a1, A2 a2) - { - typename Signal2_base::SlotList::iterator end = Signal2_base::m_slots.end(); - for (typename Signal2_base::SlotList::iterator - it = Signal2_base::m_slots.begin(); it != end; ++it) { - typename Signal2_base::SlotType* slot = *it; - (*slot)(a1, a2); - } - } - -}; - -#endif diff --git a/Runtime/Lua/LuaBind/signal/slot.h b/Runtime/Lua/LuaBind/signal/slot.h deleted file mode 100644 index 226d382..0000000 --- a/Runtime/Lua/LuaBind/signal/slot.h +++ /dev/null @@ -1,203 +0,0 @@ -// Aseprite Base Library -// Copyright (c) 2001-2013 David Capello -// -// This file is released under the terms of the MIT license. -// Read LICENSE.txt for more information. - -#ifndef BASE_SLOT_H_INCLUDED -#define BASE_SLOT_H_INCLUDED -#pragma once - -// Slot0 - Base class for delegates of zero arguments. -template -class Slot0 -{ -public: - Slot0() { } - Slot0(const Slot0& s) { (void)s; } - virtual ~Slot0() { } - virtual R operator()() = 0; - virtual Slot0* clone() const = 0; -}; - -// Slot0_fun - hold a F instance and use the function call operator -template -class Slot0_fun : public Slot0 -{ - F f; -public: - Slot0_fun(const F& f) : f(f) { } - Slot0_fun(const Slot0_fun& s) : Slot0(s), f(s.f) { } - ~Slot0_fun() { } - R operator()() { return f(); } - Slot0_fun* clone() const { return new Slot0_fun(*this); } -}; - -template -class Slot0_fun : public Slot0 -{ - F f; -public: - Slot0_fun(const F& f) : f(f) { } - Slot0_fun(const Slot0_fun& s) : Slot0(s), f(s.f) { } - ~Slot0_fun() { } - void operator()() { f(); } - Slot0_fun* clone() const { return new Slot0_fun(*this); } -}; - -// Slot0_mem - pointer to a member function of the T class -template -class Slot0_mem : public Slot0 -{ - R (T::*m)(); - T* t; -public: - Slot0_mem(R (T::*m)(), T* t) : m(m), t(t) { } - Slot0_mem(const Slot0_mem& s) : Slot0(s), m(s.m), t(s.t) { } - ~Slot0_mem() { } - R operator()() { return (t->*m)(); } - Slot0_mem* clone() const { return new Slot0_mem(*this); } -}; - -template -class Slot0_mem : public Slot0 -{ - void (T::*m)(); - T* t; -public: - Slot0_mem(void (T::*m)(), T* t) : m(m), t(t) { } - Slot0_mem(const Slot0_mem& s) : Slot0(s), m(s.m), t(s.t) { } - ~Slot0_mem() { } - void operator()() { (t->*m)(); } - Slot0_mem* clone() const { return new Slot0_mem(*this); } -}; - -// Slot1 - Base class for delegates of one argument. -template -class Slot1 -{ -public: - Slot1() { } - Slot1(const Slot1& s) { (void)s; } - virtual ~Slot1() { } - virtual R operator()(A1 a1) = 0; - virtual Slot1* clone() const = 0; -}; - -// Slot1_fun - hold a F instance and use the function call operator -template -class Slot1_fun : public Slot1 -{ - F f; -public: - Slot1_fun(const F& f) : f(f) { } - Slot1_fun(const Slot1_fun& s) : Slot1(s), f(s.f) { } - ~Slot1_fun() { } - R operator()(A1 a1) { return f(a1); } - Slot1_fun* clone() const { return new Slot1_fun(*this); } -}; - -template -class Slot1_fun : public Slot1 -{ - F f; -public: - Slot1_fun(const F& f) : f(f) { } - Slot1_fun(const Slot1_fun& s) : Slot1(s), f(s.f) { } - ~Slot1_fun() { } - void operator()(A1 a1) { f(a1); } - Slot1_fun* clone() const { return new Slot1_fun(*this); } -}; - -// Slot1_mem - pointer to a member function of the T class -template -class Slot1_mem : public Slot1 -{ - R (T::*m)(A1); - T* t; -public: - Slot1_mem(R (T::*m)(A1), T* t) : m(m), t(t) { } - Slot1_mem(const Slot1_mem& s) : Slot1(s), m(s.m), t(s.t) { } - ~Slot1_mem() { } - R operator()(A1 a1) { return (t->*m)(a1); } - Slot1_mem* clone() const { return new Slot1_mem(*this); } -}; - -template -class Slot1_mem : public Slot1 -{ - void (T::*m)(A1); - T* t; -public: - Slot1_mem(void (T::*m)(A1), T* t) : m(m), t(t) { } - Slot1_mem(const Slot1_mem& s) : Slot1(s), m(s.m), t(s.t) { } - ~Slot1_mem() { } - void operator()(A1 a1) { (t->*m)(a1); } - Slot1_mem* clone() const { return new Slot1_mem(*this); } -}; - -// Slot2 - Base class for delegates of two arguments. -template -class Slot2 -{ -public: - Slot2() { } - Slot2(const Slot2& s) { (void)s; } - virtual ~Slot2() { } - virtual R operator()(A1 a1, A2 a2) = 0; - virtual Slot2* clone() const = 0; -}; - -// Slot2_fun - hold a F instance and use the function call operator -template -class Slot2_fun : public Slot2 -{ - F f; -public: - Slot2_fun(const F& f) : f(f) { } - Slot2_fun(const Slot2_fun& s) : Slot2(s), f(s.f) { } - ~Slot2_fun() { } - R operator()(A1 a1, A2 a2) { return f(a1, a2); } - Slot2_fun* clone() const { return new Slot2_fun(*this); } -}; - -template -class Slot2_fun : public Slot2 -{ - F f; -public: - Slot2_fun(const F& f) : f(f) { } - Slot2_fun(const Slot2_fun& s) : Slot2(s), f(s.f) { } - ~Slot2_fun() { } - void operator()(A1 a1, A2 a2) { f(a1, a2); } - Slot2_fun* clone() const { return new Slot2_fun(*this); } -}; - -// Slot2_mem - pointer to a member function of the T class -template -class Slot2_mem : public Slot2 -{ - R (T::*m)(A1, A2); - T* t; -public: - Slot2_mem(R (T::*m)(A1, A2), T* t) : m(m), t(t) { } - Slot2_mem(const Slot2_mem& s) : Slot2(s), m(s.m), t(s.t) { } - ~Slot2_mem() { } - R operator()(A1 a1, A2 a2) { return (t->*m)(a1, a2); } - Slot2_mem* clone() const { return new Slot2_mem(*this); } -}; - -template -class Slot2_mem : public Slot2 -{ - void (T::*m)(A1, A2); - T* t; -public: - Slot2_mem(void (T::*m)(A1, A2), T* t) : m(m), t(t) { } - Slot2_mem(const Slot2_mem& s) : Slot2(s), m(s.m), t(s.t) { } - ~Slot2_mem() { } - void operator()(A1 a1, A2 a2) { return (t->*m)(a1, a2); } - Slot2_mem* clone() const { return new Slot2_mem(*this); } -}; - -#endif -- cgit v1.1-26-g67d0