diff --git a/include/System/Event.h b/include/System/Event.h index 8273555..b441cb8 100644 --- a/include/System/Event.h +++ b/include/System/Event.h @@ -22,12 +22,6 @@ namespace System private: List mPtrs; - // Can't allow copying unless we modify the class to make a deep - // copy of each of the pointers it holds. Base class would need - // a virtual Clone() method to allow polymorphic copying. - Event(const Event&); - Event& operator=(const Event&); - public: template class T : public Base @@ -67,6 +61,11 @@ namespace System public: Event() {} + Event(const Event& obj) + : mPtrs(obj.mPtrs) + { + } + Event& operator+=(Base* aPtr) { mPtrs.Add(aPtr); @@ -84,9 +83,23 @@ namespace System for (int i = 0; i < mPtrs.Count(); i++) { if (mPtrs[i] != null) + { (*(mPtrs[i]))(arg1, arg2); + } } } + + Event& operator =(const Event& right) + { + if (right == *this) + { + return *this; + } + + mPtrs = right.mPtrs; + + return *this; + } }; typedef Event EventHandler;