UnsafeNotifyDelegate.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #pragma once
  2. #include "MultiNotifyDelegate.hpp"
  3. //
  4. // a Notify delegate, send notification when insert, remove, clear
  5. //
  6. class UnsafeNotifyDelegate : public UnsafeDelegate
  7. {
  8. public:
  9. inline UnsafeNotifyDelegate ()
  10. {
  11. }
  12. inline UnsafeNotifyDelegate (const char * DelegateID) : UnsafeDelegate (DelegateID)
  13. {
  14. }
  15. inline virtual ~UnsafeNotifyDelegate ()
  16. {
  17. }
  18. inline virtual void AddDelegateHandler (DelegateHandler * handler)
  19. {
  20. UnsafeDelegate::AddDelegateHandler (handler);
  21. DelegateArgsNotifyDelegate e;
  22. m_Notify.Invoke (this, &e);
  23. }
  24. inline virtual void RemoveDelegateHandler (DelegateHandler * handler)
  25. {
  26. UnsafeDelegate::RemoveDelegateHandler (handler);
  27. DelegateArgsNotifyDelegate e;
  28. m_Notify.Invoke (this, &e);
  29. }
  30. inline void RemoveAll ()
  31. {
  32. UnsafeDelegate::RemoveAll ();
  33. DelegateArgsNotifyDelegate e;
  34. m_Notify.Invoke (this, &e);
  35. }
  36. inline virtual void AddFirst (DelegateHandler * handler)
  37. {
  38. UnsafeDelegate::AddFirst (handler);
  39. DelegateArgsNotifyDelegate e;
  40. m_Notify.Invoke (this, &e);
  41. }
  42. inline virtual void AddLast (DelegateHandler * handler)
  43. {
  44. UnsafeDelegate::AddLast (handler);
  45. DelegateArgsNotifyDelegate e;
  46. m_Notify.Invoke (this, &e);
  47. }
  48. inline int TransferTo (UnsafeDelegate & toDelegate)
  49. {
  50. int rc = UnsafeDelegate::TransferTo (toDelegate);
  51. DelegateArgsNotifyDelegate e;
  52. m_Notify.Invoke (this, &e);
  53. return rc;
  54. }
  55. inline int TransferFrom (UnsafeDelegate & fromDelegate)
  56. {
  57. int rc = UnsafeDelegate::TransferFrom (fromDelegate);
  58. DelegateArgsNotifyDelegate e;
  59. m_Notify.Invoke (this, &e);
  60. return rc;
  61. }
  62. inline int TransferTo (Array <DelegateHandler *> & toArray)
  63. {
  64. int rc = UnsafeDelegate::TransferTo (toArray);
  65. DelegateArgsNotifyDelegate e;
  66. m_Notify.Invoke (this, &e);
  67. return rc;
  68. }
  69. inline int TransferFrom (Array <DelegateHandler *> & fromArray)
  70. {
  71. int rc = UnsafeDelegate::TransferFrom (fromArray);
  72. DelegateArgsNotifyDelegate e;
  73. m_Notify.Invoke (this, &e);
  74. return rc;
  75. }
  76. virtual void SetTrace (bool bEnable)
  77. {
  78. UnsafeDelegate::SetTrace (bEnable);
  79. m_Notify.SetTrace (bEnable);
  80. }
  81. public:
  82. UnsafeDelegate m_Notify;
  83. };