#pragma once #include namespace td { namespace utils { /** * \brief Wrapper class to automatically disconnect from a Signal on object destruction * \note You should inherit this class privately * \sa Signal */ class SlotGuard { private: std::vector> m_Connections; public: /** * \brief Connect a signal to a function (with the same signature) */ template void Connect(Signal a_Signal, const typename Signal::CallBack& a_Callback) { m_Connections.push_back(a_Signal.ConnectSafe(a_Callback)); } void Disconnect() { m_Connections.clear(); } }; } // namespace utils } // namespace td