--- a/src/simulator/simulator.h Thu Jul 19 13:53:14 2007 +0200
+++ b/src/simulator/simulator.h Thu Jul 19 15:10:59 2007 +0200
@@ -26,6 +26,7 @@
#include "event-id.h"
#include "event-impl.h"
#include "nstime.h"
+#include "ns3/type-traits.h"
namespace ns3 {
@@ -232,8 +233,8 @@
* @param a1 the first argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
- template <typename T1>
- static EventId Schedule (Time const &time, void (*f) (T1), T1 a1);
+ template <typename U1, typename T1>
+ static EventId Schedule (Time const &time, void (*f) (U1), T1 a1);
/**
* @param time the relative expiration time of the event.
* @param f the function to invoke
@@ -241,8 +242,8 @@
* @param a2 the second argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
- template <typename T1, typename T2>
- static EventId Schedule (Time const &time, void (*f) (T1,T2), T1 a1, T2 a2);
+ template <typename U1, typename U2, typename T1, typename T2>
+ static EventId Schedule (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2);
/**
* @param time the relative expiration time of the event.
* @param f the function to invoke
@@ -251,8 +252,8 @@
* @param a3 the third argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
- template <typename T1, typename T2, typename T3>
- static EventId Schedule (Time const &time, void (*f) (T1,T2,T3), T1 a1, T2 a2, T3 a3);
+ template <typename U1, typename U2, typename U3, typename T1, typename T2, typename T3>
+ static EventId Schedule (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3);
/**
* @param time the relative expiration time of the event.
* @param f the function to invoke
@@ -262,8 +263,9 @@
* @param a4 the fourth argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
- template <typename T1, typename T2, typename T3, typename T4>
- static EventId Schedule (Time const &time, void (*f) (T1,T2,T3,T4), T1 a1, T2 a2, T3 a3, T4 a4);
+ template <typename U1, typename U2, typename U3, typename U4,
+ typename T1, typename T2, typename T3, typename T4>
+ static EventId Schedule (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
/**
* @param time the relative expiration time of the event.
* @param f the function to invoke
@@ -274,8 +276,9 @@
* @param a5 the fifth argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
- template <typename T1, typename T2, typename T3, typename T4, typename T5>
- static EventId Schedule (Time const &time, void (*f) (T1,T2,T3,T4,T5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
+ template <typename U1, typename U2, typename U3, typename U4, typename U5,
+ typename T1, typename T2, typename T3, typename T4, typename T5>
+ static EventId Schedule (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
/**
@@ -529,6 +532,7 @@
private:
Simulator ();
~Simulator ();
+
template <typename T, typename OBJ>
static EventImpl *MakeEvent (void (T::*mem_ptr) (void), OBJ obj);
template <typename T, typename OBJ, typename T1>
@@ -543,16 +547,20 @@
static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj,
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
static EventImpl *MakeEvent (void (*f) (void));
- template <typename T1>
- static EventImpl *MakeEvent (void (*f) (T1), T1 a1);
- template <typename T1, typename T2>
- static EventImpl *MakeEvent (void (*f) (T1,T2), T1 a1, T2 a2);
- template <typename T1, typename T2, typename T3>
- static EventImpl *MakeEvent (void (*f) (T1,T2,T3), T1 a1, T2 a2, T3 a3);
- template <typename T1, typename T2, typename T3, typename T4>
- static EventImpl *MakeEvent (void (*f) (T1,T2,T3,T4), T1 a1, T2 a2, T3 a3, T4 a4);
- template <typename T1, typename T2, typename T3, typename T4, typename T5>
- static EventImpl *MakeEvent (void (*f) (T1,T2,T3,T4,T5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
+ template <typename U1, typename T1>
+ static EventImpl *MakeEvent (void (*f) (U1), T1 a1);
+ template <typename U1, typename U2,
+ typename T1, typename T2>
+ static EventImpl *MakeEvent (void (*f) (U1,U2), T1 a1, T2 a2);
+ template <typename U1, typename U2, typename U3,
+ typename T1, typename T2, typename T3>
+ static EventImpl *MakeEvent (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3);
+ template <typename U1, typename U2, typename U3, typename U4,
+ typename T1, typename T2, typename T3, typename T4>
+ static EventImpl *MakeEvent (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
+ template <typename U1, typename U2, typename U3, typename U4, typename U5,
+ typename T1, typename T2, typename T3, typename T4, typename T5>
+ static EventImpl *MakeEvent (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
static SimulatorPrivate *GetPriv (void);
static EventId Schedule (Time const &time, EventImpl *event);
@@ -767,142 +775,145 @@
return ev;
}
-template <typename T1>
-EventImpl *Simulator::MakeEvent (void (*f) (T1), T1 a1)
+template <typename U1, typename T1>
+EventImpl *Simulator::MakeEvent (void (*f) (U1), T1 a1)
{
// one arg version
class EventFunctionImpl1 : public EventImpl {
public:
- typedef void (*F)(T1);
+ typedef void (*F)(U1);
- EventFunctionImpl1 (F function, T1 a1)
- : m_function (function),
- m_a1 (a1)
- { }
+ EventFunctionImpl1 (F function, T1 a1)
+ : m_function (function),
+ m_a1 (a1)
+ { }
protected:
- virtual ~EventFunctionImpl1 () {}
+ virtual ~EventFunctionImpl1 () {}
private:
- virtual void Notify (void) {
- (*m_function) (m_a1);
- }
- F m_function;
- T1 m_a1;
+ virtual void Notify (void) {
+ (*m_function) (m_a1);
+ }
+ F m_function;
+ typename TypeTraits<T1>::ReferencedType m_a1;
} *ev = new EventFunctionImpl1(f, a1);
return ev;
}
-template <typename T1, typename T2>
-EventImpl *Simulator::MakeEvent (void (*f) (T1,T2), T1 a1, T2 a2)
+template <typename U1, typename U2, typename T1, typename T2>
+EventImpl *Simulator::MakeEvent (void (*f) (U1,U2), T1 a1, T2 a2)
{
// two arg version
class EventFunctionImpl2 : public EventImpl {
public:
- typedef void (*F)(T1, T2);
+ typedef void (*F)(U1, U2);
- EventFunctionImpl2 (F function, T1 a1, T2 a2)
- : m_function (function),
- m_a1 (a1),
- m_a2 (a2)
- { }
+ EventFunctionImpl2 (F function, T1 a1, T2 a2)
+ : m_function (function),
+ m_a1 (a1),
+ m_a2 (a2)
+ {}
protected:
- virtual ~EventFunctionImpl2 () {}
+ virtual ~EventFunctionImpl2 () {}
private:
- virtual void Notify (void) {
- (*m_function) (m_a1, m_a2);
- }
- F m_function;
- T1 m_a1;
- T2 m_a2;
+ virtual void Notify (void) {
+ (*m_function) (m_a1, m_a2);
+ }
+ F m_function;
+ typename TypeTraits<T1>::ReferencedType m_a1;
+ typename TypeTraits<T2>::ReferencedType m_a2;
} *ev = new EventFunctionImpl2 (f, a1, a2);
return ev;
}
-template <typename T1, typename T2, typename T3>
-EventImpl *Simulator::MakeEvent (void (*f) (T1,T2,T3), T1 a1, T2 a2, T3 a3)
+template <typename U1, typename U2, typename U3,
+ typename T1, typename T2, typename T3>
+EventImpl *Simulator::MakeEvent (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3)
{
// three arg version
class EventFunctionImpl3 : public EventImpl {
public:
- typedef void (*F)(T1, T2, T3);
+ typedef void (*F)(U1, U2, U3);
- EventFunctionImpl3 (F function, T1 a1, T2 a2, T3 a3)
- : m_function (function),
- m_a1 (a1),
- m_a2 (a2),
- m_a3 (a3)
- { }
+ EventFunctionImpl3 (F function, T1 a1, T2 a2, T3 a3)
+ : m_function (function),
+ m_a1 (a1),
+ m_a2 (a2),
+ m_a3 (a3)
+ { }
protected:
- virtual ~EventFunctionImpl3 () {}
+ virtual ~EventFunctionImpl3 () {}
private:
- virtual void Notify (void) {
- (*m_function) (m_a1, m_a2, m_a3);
- }
- F m_function;
- T1 m_a1;
- T2 m_a2;
- T3 m_a3;
+ virtual void Notify (void) {
+ (*m_function) (m_a1, m_a2, m_a3);
+ }
+ F m_function;
+ typename TypeTraits<T1>::ReferencedType m_a1;
+ typename TypeTraits<T2>::ReferencedType m_a2;
+ typename TypeTraits<T3>::ReferencedType m_a3;
} *ev = new EventFunctionImpl3 (f, a1, a2, a3);
return ev;
}
-template <typename T1, typename T2, typename T3, typename T4>
-EventImpl *Simulator::MakeEvent (void (*f) (T1,T2,T3,T4), T1 a1, T2 a2, T3 a3, T4 a4)
+template <typename U1, typename U2, typename U3, typename U4,
+ typename T1, typename T2, typename T3, typename T4>
+EventImpl *Simulator::MakeEvent (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
{
// four arg version
class EventFunctionImpl4 : public EventImpl {
public:
- typedef void (*F)(T1, T2, T3, T4);
+ typedef void (*F)(U1, U2, U3, U4);
- EventFunctionImpl4 (F function, T1 a1, T2 a2, T3 a3, T4 a4)
- : m_function (function),
- m_a1 (a1),
- m_a2 (a2),
- m_a3 (a3),
- m_a4 (a4)
- { }
+ EventFunctionImpl4 (F function, T1 a1, T2 a2, T3 a3, T4 a4)
+ : m_function (function),
+ m_a1 (a1),
+ m_a2 (a2),
+ m_a3 (a3),
+ m_a4 (a4)
+ { }
protected:
- virtual ~EventFunctionImpl4 () {}
+ virtual ~EventFunctionImpl4 () {}
private:
- virtual void Notify (void) {
- (*m_function) (m_a1, m_a2, m_a3, m_a4);
- }
- F m_function;
- T1 m_a1;
- T2 m_a2;
- T3 m_a3;
- T4 m_a4;
+ virtual void Notify (void) {
+ (*m_function) (m_a1, m_a2, m_a3, m_a4);
+ }
+ F m_function;
+ typename TypeTraits<T1>::ReferencedType m_a1;
+ typename TypeTraits<T2>::ReferencedType m_a2;
+ typename TypeTraits<T3>::ReferencedType m_a3;
+ typename TypeTraits<T4>::ReferencedType m_a4;
} *ev = new EventFunctionImpl4 (f, a1, a2, a3, a4);
return ev;
}
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-EventImpl *Simulator::MakeEvent (void (*f) (T1,T2,T3,T4,T5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
+template <typename U1, typename U2, typename U3, typename U4, typename U5,
+ typename T1, typename T2, typename T3, typename T4, typename T5>
+EventImpl *Simulator::MakeEvent (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
// five arg version
class EventFunctionImpl5 : public EventImpl {
public:
- typedef void (*F)(T1, T2, T3, T4, T5);
+ typedef void (*F)(U1,U2,U3,U4,U5);
- EventFunctionImpl5 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
- : m_function (function),
- m_a1 (a1),
- m_a2 (a2),
- m_a3 (a3),
- m_a4 (a4),
- m_a5 (a5)
- { }
+ EventFunctionImpl5 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
+ : m_function (function),
+ m_a1 (a1),
+ m_a2 (a2),
+ m_a3 (a3),
+ m_a4 (a4),
+ m_a5 (a5)
+ {}
protected:
- virtual ~EventFunctionImpl5 () {}
+ virtual ~EventFunctionImpl5 () {}
private:
- virtual void Notify (void) {
- (*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5);
- }
- F m_function;
- T1 m_a1;
- T2 m_a2;
- T3 m_a3;
- T4 m_a4;
- T5 m_a5;
+ virtual void Notify (void) {
+ (*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5);
+ }
+ F m_function;
+ typename TypeTraits<T1>::ReferencedType m_a1;
+ typename TypeTraits<T2>::ReferencedType m_a2;
+ typename TypeTraits<T3>::ReferencedType m_a3;
+ typename TypeTraits<T4>::ReferencedType m_a4;
+ typename TypeTraits<T5>::ReferencedType m_a5;
} *ev = new EventFunctionImpl5 (f, a1, a2, a3, a4, a5);
return ev;
}
@@ -945,32 +956,36 @@
return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
}
-template <typename T1>
-EventId Simulator::Schedule (Time const &time, void (*f) (T1), T1 a1)
+template <typename U1, typename T1>
+EventId Simulator::Schedule (Time const &time, void (*f) (U1), T1 a1)
{
return Schedule (time, MakeEvent (f, a1));
}
-template <typename T1, typename T2>
-EventId Simulator::Schedule (Time const &time, void (*f) (T1,T2), T1 a1, T2 a2)
+template <typename U1, typename U2,
+ typename T1, typename T2>
+EventId Simulator::Schedule (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2)
{
return Schedule (time, MakeEvent (f, a1, a2));
}
-template <typename T1, typename T2, typename T3>
-EventId Simulator::Schedule (Time const &time, void (*f) (T1,T2,T3), T1 a1, T2 a2, T3 a3)
+template <typename U1, typename U2, typename U3,
+ typename T1, typename T2, typename T3>
+EventId Simulator::Schedule (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3)
{
return Schedule (time, MakeEvent (f, a1, a2, a3));
}
-template <typename T1, typename T2, typename T3, typename T4>
-EventId Simulator::Schedule (Time const &time, void (*f) (T1,T2,T3,T4), T1 a1, T2 a2, T3 a3, T4 a4)
+template <typename U1, typename U2, typename U3, typename U4,
+ typename T1, typename T2, typename T3, typename T4>
+EventId Simulator::Schedule (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
{
return Schedule (time, MakeEvent (f, a1, a2, a3, a4));
}
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-EventId Simulator::Schedule (Time const &time, void (*f) (T1,T2,T3,T4,T5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
+template <typename U1, typename U2, typename U3, typename U4, typename U5,
+ typename T1, typename T2, typename T3, typename T4, typename T5>
+EventId Simulator::Schedule (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
return Schedule (time, MakeEvent (f, a1, a2, a3, a4, a5));
}