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