1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #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 <BASE_TA>::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 <BASE_TA> ::tKey key, const void * pThis) override
- {
- auto rc = inherited::DoPop (mmElapse, key, pThis);
- m_Notify.Invoke (this, NULL);
- return rc;
- }
- public:
- UnsafeDelegate m_Notify;
- };
|