#pragma once #include "C11UnsafeDelegate.hpp" // // a Notify delegate, send notification when insert, remove, clear // template class _tNotifyUnsafeDelegate : public _tUnsafeDelegate { typedef _tUnsafeDelegate inherited; public: _tNotifyUnsafeDelegate () = default; _tNotifyUnsafeDelegate (_tNotifyUnsafeDelegate && from) { m_handlers.swap (from.m_handlers); m_Notify.swap (from.m_Notify); } _tNotifyUnsafeDelegate (const _tNotifyUnsafeDelegate &) = delete; _tNotifyUnsafeDelegate & operator == (const _tNotifyUnsafeDelegate &) = delete; _tNotifyUnsafeDelegate & operator == (_tNotifyUnsafeDelegate &&) = delete; inline virtual ~_tNotifyUnsafeDelegate () { } public: inline virtual void RemoveAll () override { inherited::RemoveAll (); m_Notify.Invoke (this, NULL); } protected: inline virtual void ForcePush (C11EventHandler && handler) override { inherited::ForcePush (std::move (handler)); m_Notify.Invoke (this, NULL); } protected: // 按 Key 来删除 inline virtual bool DoPop (const typename C11EventHandler::tKey key) override { auto rc = inherited::DoPop (key); m_Notify.Invoke (this, NULL); return rc; } // 按 Key + 类实例指针 来删除 inline virtual bool DoPop (const typename C11EventHandler::tKey key, const void * pThis) override { auto rc = inherited::DoPop (key, pThis); m_Notify.Invoke (this, NULL); return rc; } public: UnsafeDelegate m_Notify; }; using NotifyUnsafeDelegate = _tNotifyUnsafeDelegate ;