From 182c8f8357739f905bbd721006480502435b6b43 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 27 Nov 2022 12:04:31 -0800 Subject: Update brace style to match rest of my projects --- app/source/Cplt/Utils/Sigslot.hpp | 45 +++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'app/source/Cplt/Utils/Sigslot.hpp') diff --git a/app/source/Cplt/Utils/Sigslot.hpp b/app/source/Cplt/Utils/Sigslot.hpp index a4ab94e..92c8bcc 100644 --- a/app/source/Cplt/Utils/Sigslot.hpp +++ b/app/source/Cplt/Utils/Sigslot.hpp @@ -8,25 +8,21 @@ #include #include -class SignalStub -{ +class SignalStub { public: /// Non-template interface for Signal to implement (a barrier to stop template /// arguments propagation). - class IWrapper - { + class IWrapper { public: virtual ~IWrapper() = default; virtual void RemoveFunction(int id) = 0; }; - enum - { + enum { InvalidId = -1, }; - struct Connection - { + struct Connection { SlotGuard* guard; int slotId; int id = InvalidId; // If `InvalidId`, then this "spot" is unused @@ -59,8 +55,7 @@ private: }; template -class Signal : public SignalStub::IWrapper -{ +class Signal : public SignalStub::IWrapper { private: // Must be in this order so that mFunctions is still intact when mStub's destructor runs std::vector> mFunctions; @@ -68,8 +63,7 @@ private: public: Signal() - : mStub(*this) - { + : mStub(*this) { } virtual ~Signal() = default; @@ -79,8 +73,7 @@ public: Signal(Signal&&) = default; Signal& operator=(Signal&&) = default; - void operator()(TArgs... args) - { + void operator()(TArgs... args) { for (auto& conn : mStub.GetConnections()) { if (conn.IsOccupied()) { mFunctions[conn.id](std::forward(args)...); @@ -89,8 +82,7 @@ public: } template - int Connect(TFunction slot) - { + int Connect(TFunction slot) { auto& conn = mStub.InsertConnection(); mFunctions.resize(std::max(mFunctions.size(), (size_t)conn.id + 1)); mFunctions[conn.id] = std::move(slot); @@ -98,31 +90,26 @@ public: } template - int Connect(SlotGuard& guard, TFunction slot) - { + int Connect(SlotGuard& guard, TFunction slot) { auto& conn = mStub.InsertConnection(&guard); mFunctions.resize(std::max(mFunctions.size(), (size_t)conn.id + 1)); mFunctions[conn.id] = std::move(slot); return conn.id; } - void Disconnect(int id) - { + void Disconnect(int id) { mStub.RemoveConnection(id); } - void DisconnectFor(SlotGuard& guard) - { + void DisconnectFor(SlotGuard& guard) { mStub.RemoveConnectionFor(guard); } - void DisconnectAll() - { + void DisconnectAll() { mStub.RemoveAllConnections(); } - virtual void RemoveFunction(int id) - { + virtual void RemoveFunction(int id) { mFunctions[id] = {}; } }; @@ -130,11 +117,9 @@ public: /// Automatic disconnection mechanism for Signal<>. /// Bind connection to this guard by using the Connect(SlotGuard&, TFunction) overload. /// Either DisconnectAll() or the destructor disconnects all connections bound to this guard. -class SlotGuard -{ +class SlotGuard { private: - struct Connection - { + struct Connection { SignalStub* stub = nullptr; int stubId = SignalStub::InvalidId; }; -- cgit v1.2.3-70-g09d2