add Callback::Assign
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 07 May 2007 13:44:22 +0200
changeset 528 e32961ea7f21
parent 527 eda15411d38a
child 529 cbd7b6a6ca24
add Callback::Assign
src/core/callback.h
--- a/src/core/callback.h	Mon May 07 13:21:29 2007 +0200
+++ b/src/core/callback.h	Mon May 07 13:44:22 2007 +0200
@@ -23,6 +23,7 @@
 #define CALLBACK_H
 
 #include "reference-list.h"
+#include "fatal-error.h"
 
 namespace ns3 {
 
@@ -292,6 +293,16 @@
         return false;
       }
   }
+  void Assign (CallbackBase const &other) {
+    if (!CheckType (other))
+      {
+        NS_FATAL_ERROR ("Incompatible types. (feed to \"c++filt -t\")"
+                        " got=" << typeid (other).name () << 
+                        ", expected=" << typeid (*this).name ());
+      }
+    const Callback<R, T1,T2,T3,T4,T5> *goodType = static_cast<const Callback<R,T1,T2,T3,T4,T5> *> (&other);
+    *this = *goodType;
+  }
 private:
   virtual CallbackImplBase *PeekImpl (void) const {
     return m_impl.Get ();