Преглед изворни кода

Add Clone() function to EventHandler.

Lasse Öörni пре 11 година
родитељ
комит
141c3f2491
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      Source/Engine/Core/Object.h

+ 8 - 0
Source/Engine/Core/Object.h

@@ -211,6 +211,8 @@ public:
     
     /// Invoke event handler function.
     virtual void Invoke(VariantMap& eventData) = 0;
+    /// Return a unique copy of the event handler.
+    virtual EventHandler* Clone() const = 0;
     
     /// Return event receiver.
     Object* GetReceiver() const { return receiver_; }
@@ -261,6 +263,12 @@ public:
         (receiver->*function_)(eventType_, eventData);
     }
     
+    /// Return a unique copy of the event handler.
+    virtual EventHandler* Clone() const
+    {
+        return new EventHandlerImpl(static_cast<T*>(receiver_), function_, userData_);
+    }
+    
 private:
     /// Class-specific pointer to handler function.
     HandlerFunctionPtr function_;