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/signal.h | 451 ------------------------------------ 1 file changed, 451 deletions(-) delete mode 100644 Runtime/Lua/LuaBind/signal/signal.h (limited to 'Runtime/Lua/LuaBind/signal/signal.h') 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 -- cgit v1.1-26-g67d0