# HG changeset patch # User Alexander Krotov # Date 1484918498 -10800 # Fri Jan 20 16:21:38 2017 +0300 # Node ID aa070d59557c57780706f64a468a760177a5cb36 # Parent 74bc73b0ea6c3f2cfe523c2a39db1c7a57cf46a5 core: Make use of variadic templates diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/callback.h --- a/src/core/model/callback.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/callback.h Fri Jan 20 16:21:38 2017 +0300 @@ -56,40 +56,6 @@ */ /** * \ingroup callback - * \defgroup makecallbackmemptr MakeCallback from member function pointer - * - * Build Callbacks for class method members which take varying numbers - * of arguments and potentially returning a value. - * - * Generally the \c MakeCallback functions are invoked with the - * method function address first, followed by the \c this pointer: - * \code - * MakeCallback ( & MyClass::Handler, this); - * \endcode - * - * There is not a version with bound arguments. You may be able to - * get the same result by using \c MakeBoundCallback with a \c static - * member function, as in: - * \code - * MakeBoundCallback ( & MyClass::StaticHandler, this); - * \endcode - * This still leaves two argument slots available for binding. - */ -/** - * \ingroup callback - * \defgroup makecallbackfnptr MakeCallback from function pointers - * - * Build Callbacks for functions which take varying numbers of arguments - * and potentially returning a value. - */ -/** - * \ingroup callback - * \defgroup makenullcallback MakeCallback with no arguments - * - * Define empty (Null) callbacks as placeholders for unset callback variables. - */ -/** - * \ingroup callback * \defgroup makeboundcallback MakeBoundCallback from functions bound with up to three arguments. * * Build bound Callbacks which take varying numbers of arguments, @@ -104,7 +70,7 @@ /** - * \ingroup makecallbackmemptr + * \ingroup callbackimpl * * Trait class to convert a pointer into a reference, * used by MemPtrCallBackImpl @@ -113,7 +79,7 @@ struct CallbackTraits; /** - * \ingroup makecallbackmemptr + * \ingroup callbackimpl * * Trait class to convert a pointer into a reference, * used by MemPtrCallBackImpl @@ -581,7 +547,7 @@ }; /** - * \ingroup makecallbackmemptr + * \ingroup callbackimpl * CallbackImpl for pointer to member functions */ template @@ -1474,204 +1440,66 @@ } /** - * \ingroup makecallbackmemptr * @{ */ /** + * Build Callbacks for class method members which take varying numbers + * of arguments and potentially returning a value. + * * \param [in] memPtr Class method member pointer * \param [in] objPtr Class instance * \return A wrapper Callback * - * Build Callbacks for class method members which take varying numbers of arguments - * and potentially returning a value. - */ -template -Callback MakeCallback (R (T::*memPtr)(void), OBJ objPtr) { - return Callback (objPtr, memPtr); + * This \c MakeCallback is invoked with the + * method function address first, followed by the \c this pointer: + * \code + * MakeCallback ( & MyClass::Handler, this); + * \endcode + * + * There is not a version with bound arguments. You may be able to + * get the same result by using \c MakeBoundCallback with a \c static + * member function, as in: + * \code + * MakeBoundCallback ( & MyClass::StaticHandler, this); + * \endcode + * This still leaves two argument slots available for binding. + */ +template +Callback MakeCallback (R (T::*memPtr)(Ts...), OBJ objPtr) { + return Callback (objPtr, memPtr); } -template -Callback MakeCallback (R (T::*memPtr)() const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9) const, OBJ objPtr) { - return Callback (objPtr, memPtr); +template +Callback MakeCallback (R (T::*memPtr)(Ts...) const, OBJ objPtr) { + return Callback (objPtr, memPtr); } /**@}*/ /** * \ingroup makecallbackfnptr - * @{ - */ -/** * \param [in] fnPtr Function pointer * \return A wrapper Callback * * Build Callbacks for functions which take varying numbers of arguments * and potentially returning a value. */ -template -Callback MakeCallback (R (*fnPtr)()) { - return Callback (fnPtr, true, true); +template +Callback MakeCallback (R (*fnPtr)(Ts...)) { + return Callback (fnPtr, true, true); } -template -Callback MakeCallback (R (*fnPtr)(T1)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7,T8)) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9)) { - return Callback (fnPtr, true, true); -} -/**@}*/ + /** - * \ingroup makenullcallback - * @{ - */ -/** + * \ingroup callback * \return A wrapper Callback * * Build null Callbacks which take no arguments, * for varying number of template arguments, * and potentially returning a value. - */ -template -Callback MakeNullCallback (void) { - return Callback (); + */ +template +Callback MakeNullCallback (void) { + return Callback (); } -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -/**@}*/ /** diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/make-event.h --- a/src/core/model/make-event.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/make-event.h Fri Jan 20 16:21:38 2017 +0300 @@ -20,786 +20,47 @@ #ifndef MAKE_EVENT_H #define MAKE_EVENT_H +#include "event-impl.h" +#include + /** * \file * \ingroup events - * ns3::MakeEvent function declarations and template implementation. + * ns3::MakeEvent function template. */ namespace ns3 { -class EventImpl; - /** * \ingroup events - * \defgroup makeeventmemptr MakeEvent from Member Function Pointer. + * Create EventImpl instance from a callable object. * - * Create EventImpl instances from class member functions which take - * varying numbers of arguments. - */ -/** - * \ingroup makeeventmemptr - * @{ - */ -/** - * Make an EventImpl from class method members which take - * varying numbers of arguments. - * - * \tparam MEM \deduced The class method function signature. - * \tparam OBJ \deduced The class type holding the method. - * \param [in] mem_ptr Class method member function pointer - * \param [in] obj Class instance. + * \tparam Ts \deduced Argument types. + * \param [in] args Callable object and bound arguments, forwarded to std::bind. * \returns The constructed EventImpl. */ -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj); - -/** - * \copybrief MakeEvent(MEM,OBJ) - * \tparam MEM \deduced The class method function signature. - * \tparam OBJ \deduced The class type holding the method. - * \tparam T1 \deduced Type of the argument to the underlying function. - * \param [in] mem_ptr Class method member function pointer - * \param [in] obj Class instance. - * \param [in] a1 Argument value to be bound to the underlying function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1); - -/** - * \copybrief MakeEvent(MEM,OBJ) - * \tparam MEM \deduced The class method function signature. - * \tparam OBJ \deduced The class type holding the method. - * \tparam T1 \deduced Type of the first argument to the underlying function. - * \tparam T2 \deduced Type of the second argument to the underlying function. - * \param [in] mem_ptr Class method member function pointer - * \param [in] obj Class instance. - * \param [in] a1 First argument value to be bound to the underlying function. - * \param [in] a2 Second argument value to be bound to the underlying function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - -/** - * \copybrief MakeEvent(MEM,OBJ) - * \tparam MEM \deduced The class method function signature. - * \tparam OBJ \deduced The class type holding the method. - * \tparam T1 \deduced Type of the first argument to the underlying function. - * \tparam T2 \deduced Type of the second argument to the underlying function. - * \tparam T3 \deduced Type of the third argument to the underlying function. - * \param [in] mem_ptr Class method member function pointer - * \param [in] obj Class instance. - * \param [in] a1 First argument value to be bound to the underlying function. - * \param [in] a2 Second argument value to be bound to the underlying function. - * \param [in] a3 Third argument value to be bound to the underlying function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - -/** - * \copybrief MakeEvent(MEM,OBJ) - * \tparam MEM \deduced The class method function signature. - * \tparam OBJ \deduced The class type holding the method. - * \tparam T1 \deduced Type of the first argument to the underlying function. - * \tparam T2 \deduced Type of the second argument to the underlying function. - * \tparam T3 \deduced Type of the third argument to the underlying function. - * \tparam T4 \deduced Type of the fourth argument to the underlying function. - * \param [in] mem_ptr Class method member function pointer - * \param [in] obj Class instance. - * \param [in] a1 First argument value to be bound to the underlying function. - * \param [in] a2 Second argument value to be bound to the underlying function. - * \param [in] a3 Third argument value to be bound to the underlying function. - * \param [in] a4 Fourth argument value to be bound to the underlying function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); - -/** - * \copybrief MakeEvent(MEM,OBJ) - * \tparam MEM \deduced The class method function signature. - * \tparam OBJ \deduced The class type holding the method. - * \tparam T1 \deduced Type of the first argument to the underlying function. - * \tparam T2 \deduced Type of the second argument to the underlying function. - * \tparam T3 \deduced Type of the third argument to the underlying function. - * \tparam T4 \deduced Type of the fourth argument to the underlying function. - * \tparam T5 \deduced Type of the fifth argument to the underlying function. - * \param [in] mem_ptr Class method member function pointer - * \param [in] obj Class instance. - * \param [in] a1 First argument value to be bound to the underlying function. - * \param [in] a2 Second argument value to be bound to the underlying function. - * \param [in] a3 Third argument value to be bound to the underlying function. - * \param [in] a4 Fourth argument value to be bound to the underlying function. - * \param [in] a5 Fifh argument value to be bound to the underlying function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - -/** - * \copybrief MakeEvent(MEM,OBJ) - * \tparam MEM The class method function signature. - * \tparam OBJ The class type holding the method. - * \tparam T1 Type of the first argument to the underlying function. - * \tparam T2 Type of the second argument to the underlying function. - * \tparam T3 Type of the third argument to the underlying function. - * \tparam T4 Type of the fourth argument to the underlying function. - * \tparam T5 Type of the fifth argument to the underlying function. - * \tparam T6 Type of the sixth argument to the underlying function. - * \param mem_ptr Class method member function pointer - * \param obj Class instance. - * \param a1 First argument value to be bound to the underlying function. - * \param a2 Second argument value to be bound to the underlying function. - * \param a3 Third argument value to be bound to the underlying function. - * \param a4 Fourth argument value to be bound to the underlying function. - * \param a5 Fifth argument value to be bound to the underlying function. - * \param a6 Sixth argument value to be bound to the underlying function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - -/**@}*/ - -/** - * \ingroup events - * \defgroup makeeventfnptr MakeEvent from Function Pointers. - * - * Create EventImpl instances from function pointers which take - * varying numbers of arguments. - * - * @{ - */ -/** - * Make an EventImpl from a function pointer taking varying numbers - * of arguments. - * - * \param [in] f The function pointer. - * \returns The constructed EventImpl. - */ -EventImpl * MakeEvent (void (*f)(void)); - -/** - * \copybrief MakeEvent(void(*f)(void)) - * \tparam U1 \deduced Formal type of the argument to the function. - * \tparam T1 \deduced Actual type of the argument to the function. - * \param [in] f The function pointer. - * \param [in] a1 Argument to be bound to the function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (void (*f)(U1), T1 a1); - -/** - * \copybrief MakeEvent(void(*f)(void)) - * \tparam U1 \deduced Formal type of the first argument to the function. - * \tparam U2 \deduced Formal type of the second argument to the function. - * \tparam T1 \deduced Actual type of the first argument to the function. - * \tparam T2 \deduced Actual type of the second argument to the function. - * \param [in] f The function pointer. - * \param [in] a1 First argument to be bound to the function. - * \param [in] a2 Second argument to be bound to the function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (void (*f)(U1,U2), T1 a1, T2 a2); - -/** - * \copybrief MakeEvent(void(*f)(void)) - * \tparam U1 \deduced Formal type of the first argument to the function. - * \tparam U2 \deduced Formal type of the second argument to the function. - * \tparam U3 \deduced Formal type of the third argument to the function. - * \tparam T1 \deduced Actual type of the first argument to the function. - * \tparam T2 \deduced Actual type of the second argument to the function. - * \tparam T3 \deduced Actual type of the third argument to the function. - * \param [in] f The function pointer. - * \param [in] a1 First argument to be bound to the function. - * \param [in] a2 Second argument to be bound to the function. - * \param [in] a3 Third argument to be bound to the function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - -/** - * \copybrief MakeEvent(void(*f)(void)) - * \tparam U1 \deduced Formal type of the first argument to the function. - * \tparam U2 \deduced Formal type of the second argument to the function. - * \tparam U3 \deduced Formal type of the third argument to the function. - * \tparam U4 \deduced Formal type of the fourth argument to the function. - * \tparam T1 \deduced Actual type of the first argument to the function. - * \tparam T2 \deduced Actual type of the second argument to the function. - * \tparam T3 \deduced Actual type of the third argument to the function. - * \tparam T4 \deduced Actual type of the fourth argument to the function. - * \param [in] f The function pointer. - * \param [in] a1 First argument to be bound to the function. - * \param [in] a2 Second argument to be bound to the function. - * \param [in] a3 Third argument to be bound to the function. - * \param [in] a4 Fourth argument to be bound to the function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - -/** - * \copybrief MakeEvent(void(*f)(void)) - * \tparam U1 \deduced Formal type of the first argument to the function. - * \tparam U2 \deduced Formal type of the second argument to the function. - * \tparam U3 \deduced Formal type of the third argument to the function. - * \tparam U4 \deduced Formal type of the fourth argument to the function. - * \tparam U5 \deduced Formal type of the fifth argument to the function. - * \tparam T1 \deduced Actual type of the first argument to the function. - * \tparam T2 \deduced Actual type of the second argument to the function. - * \tparam T3 \deduced Actual type of the third argument to the function. - * \tparam T4 \deduced Actual type of the fourth argument to the function. - * \tparam T5 \deduced Actual type of the fifth argument to the function. - * \param [in] f The function pointer. - * \param [in] a1 First argument to be bound to the function. - * \param [in] a2 Second argument to be bound to the function. - * \param [in] a3 Third argument to be bound to the function. - * \param [in] a4 Fourth argument to be bound to the function. - * \param [in] a5 Fifth argument to be bound to the function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - -/** - * \copybrief MakeEvent(void(*f)(void)) - * \tparam U1 Formal type of the first argument to the function. - * \tparam U2 Formal type of the second argument to the function. - * \tparam U3 Formal type of the third argument to the function. - * \tparam U4 Formal type of the fourth argument to the function. - * \tparam U5 Formal type of the fifth argument to the function. - * \tparam U6 Formal type of the sixth argument to the function. - * \tparam T1 Actual type of the first argument to the function. - * \tparam T2 Actual type of the second argument to the function. - * \tparam T3 Actual type of the third argument to the function. - * \tparam T4 Actual type of the fourth argument to the function. - * \tparam T5 Actual type of the fifth argument to the function. - * \tparam T6 Actual type of the sixth argument to the function. - * \param f The function pointer. - * \param a1 First argument to be bound to the function. - * \param a2 Second argument to be bound to the function. - * \param a3 Third argument to be bound to the function. - * \param a4 Fourth argument to be bound to the function. - * \param a5 Fifth argument to be bound to the function. - * \param a6 Sixth argument to be bound to the function. - * \returns The constructed EventImpl. - */ -template -EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); -/**@}*/ - -} // namespace ns3 - -/******************************************************************** - * Implementation of the templates declared above. - ********************************************************************/ - -#include "event-impl.h" -#include "type-traits.h" - -namespace ns3 { - -/** - * \ingroup makeeventmemptr - * Helper for the MakeEvent functions which take a class method. - * - * This helper converts a pointer to a reference. - * - * This is the generic template declaration (with empty body). - * - * \tparam T \explicit The class type. - */ -template -struct EventMemberImplObjTraits; - -/** - * \ingroup makeeventmemptr - * Helper for the MakeEvent functions which take a class method. - * - * This helper converts a pointer to a reference. - * - * This is the specialization for pointer types. - * - * \tparam T \explicit The class type. - */ -template -struct EventMemberImplObjTraits +template +EventImpl * MakeEvent (Ts&&... args) { - /** - * \param [in] p Object pointer. - * \return A reference to the object pointed to by p. - */ - static T &GetReference (T *p) - { - return *p; - } -}; - -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj) -{ - // zero argument version - class EventMemberImpl0 : public EventImpl + class EventMemberImpl : public EventImpl { public: - EventMemberImpl0 (OBJ obj, MEM function) - : m_obj (obj), - m_function (function) + EventMemberImpl (Ts&&... args) + : m_function (std::bind (std::forward (args)...)) { } - virtual ~EventMemberImpl0 () +protected: + virtual ~EventMemberImpl () { } private: - virtual void Notify (void) + virtual void Notify () { - (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(); + m_function (); } - OBJ m_obj; - MEM m_function; - } *ev = new EventMemberImpl0 (obj, mem_ptr); - return ev; -} - - -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1) -{ - // one argument version - class EventMemberImpl1 : public EventImpl - { -public: - EventMemberImpl1 (OBJ obj, MEM function, T1 a1) - : m_obj (obj), - m_function (function), - m_a1 (a1) - { - } -protected: - virtual ~EventMemberImpl1 () - { - } -private: - virtual void Notify (void) - { - (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1); - } - OBJ m_obj; - MEM m_function; - typename TypeTraits::ReferencedType m_a1; - } *ev = new EventMemberImpl1 (obj, mem_ptr, a1); - return ev; -} - -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) -{ - // two argument version - class EventMemberImpl2 : public EventImpl - { -public: - EventMemberImpl2 (OBJ obj, MEM function, T1 a1, T2 a2) - : m_obj (obj), - m_function (function), - m_a1 (a1), - m_a2 (a2) - { - } -protected: - virtual ~EventMemberImpl2 () - { - } -private: - virtual void Notify (void) - { - (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2); - } - OBJ m_obj; - MEM m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - } *ev = new EventMemberImpl2 (obj, mem_ptr, a1, a2); - return ev; -} - -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) -{ - // three argument version - class EventMemberImpl3 : public EventImpl - { -public: - EventMemberImpl3 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3) - : m_obj (obj), - m_function (function), - m_a1 (a1), - m_a2 (a2), - m_a3 (a3) - { - } -protected: - virtual ~EventMemberImpl3 () - { - } -private: - virtual void Notify (void) - { - (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3); - } - OBJ m_obj; - MEM m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - } *ev = new EventMemberImpl3 (obj, mem_ptr, a1, a2, a3); - return ev; -} - -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) -{ - // four argument version - class EventMemberImpl4 : public EventImpl - { -public: - EventMemberImpl4 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3, T4 a4) - : m_obj (obj), - m_function (function), - m_a1 (a1), - m_a2 (a2), - m_a3 (a3), - m_a4 (a4) - { - } -protected: - virtual ~EventMemberImpl4 () - { - } -private: - virtual void Notify (void) - { - (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3, m_a4); - } - OBJ m_obj; - MEM m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - typename TypeTraits::ReferencedType m_a4; - } *ev = new EventMemberImpl4 (obj, mem_ptr, a1, a2, a3, a4); - return ev; -} - -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - // five argument version - class EventMemberImpl5 : public EventImpl - { -public: - EventMemberImpl5 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) - : m_obj (obj), - m_function (function), - m_a1 (a1), - m_a2 (a2), - m_a3 (a3), - m_a4 (a4), - m_a5 (a5) - { - } -protected: - virtual ~EventMemberImpl5 () - { - } -private: - virtual void Notify (void) - { - (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5); - } - OBJ m_obj; - MEM m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - typename TypeTraits::ReferencedType m_a4; - typename TypeTraits::ReferencedType m_a5; - } *ev = new EventMemberImpl5 (obj, mem_ptr, a1, a2, a3, a4, a5); - return ev; -} - -template -EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - // six argument version - class EventMemberImpl6 : public EventImpl - { -public: - EventMemberImpl6 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) - : m_obj (obj), - m_function (function), - m_a1 (a1), - m_a2 (a2), - m_a3 (a3), - m_a4 (a4), - m_a5 (a5), - m_a6 (a6) - { - } -protected: - virtual ~EventMemberImpl6 () - { - } -private: - virtual void Notify (void) - { - (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5, m_a6); - } - OBJ m_obj; - MEM m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - typename TypeTraits::ReferencedType m_a4; - typename TypeTraits::ReferencedType m_a5; - typename TypeTraits::ReferencedType m_a6; - } *ev = new EventMemberImpl6 (obj, mem_ptr, a1, a2, a3, a4, a5, a6); - return ev; -} - -template -EventImpl * MakeEvent (void (*f)(U1), T1 a1) -{ - // one arg version - class EventFunctionImpl1 : public EventImpl - { -public: - typedef void (*F)(U1); - - EventFunctionImpl1 (F function, T1 a1) - : m_function (function), - m_a1 (a1) - { - } -protected: - virtual ~EventFunctionImpl1 () - { - } -private: - virtual void Notify (void) - { - (*m_function)(m_a1); - } - F m_function; - typename TypeTraits::ReferencedType m_a1; - } *ev = new EventFunctionImpl1 (f, a1); - return ev; -} - -template -EventImpl * MakeEvent (void (*f)(U1,U2), T1 a1, T2 a2) -{ - // two arg version - class EventFunctionImpl2 : public EventImpl - { -public: - typedef void (*F)(U1, U2); - - EventFunctionImpl2 (F function, T1 a1, T2 a2) - : m_function (function), - m_a1 (a1), - m_a2 (a2) - { - } -protected: - virtual ~EventFunctionImpl2 () - { - } -private: - virtual void Notify (void) - { - (*m_function)(m_a1, m_a2); - } - F m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - } *ev = new EventFunctionImpl2 (f, a1, a2); - return ev; -} - -template -EventImpl * MakeEvent (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3) -{ - // three arg version - class EventFunctionImpl3 : public EventImpl - { -public: - 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) - { - } -protected: - virtual ~EventFunctionImpl3 () - { - } -private: - virtual void Notify (void) - { - (*m_function)(m_a1, m_a2, m_a3); - } - F m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - } *ev = new EventFunctionImpl3 (f, a1, a2, a3); - return ev; -} - -template -EventImpl * 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)(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) - { - } -protected: - virtual ~EventFunctionImpl4 () - { - } -private: - virtual void Notify (void) - { - (*m_function)(m_a1, m_a2, m_a3, m_a4); - } - F m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - typename TypeTraits::ReferencedType m_a4; - } *ev = new EventFunctionImpl4 (f, a1, a2, a3, a4); - return ev; -} - -template -EventImpl * 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)(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) - { - } -protected: - virtual ~EventFunctionImpl5 () - { - } -private: - virtual void Notify (void) - { - (*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5); - } - F m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - typename TypeTraits::ReferencedType m_a4; - typename TypeTraits::ReferencedType m_a5; - } *ev = new EventFunctionImpl5 (f, a1, a2, a3, a4, a5); - return ev; -} - -template -EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - // six arg version - class EventFunctionImpl6 : public EventImpl - { -public: - typedef void (*F)(U1,U2,U3,U4,U5,U6); - - EventFunctionImpl6 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) - : m_function (function), - m_a1 (a1), - m_a2 (a2), - m_a3 (a3), - m_a4 (a4), - m_a5 (a5), - m_a6 (a6) - { - } -protected: - virtual ~EventFunctionImpl6 () - { - } -private: - virtual void Notify (void) - { - (*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5, m_a6); - } - F m_function; - typename TypeTraits::ReferencedType m_a1; - typename TypeTraits::ReferencedType m_a2; - typename TypeTraits::ReferencedType m_a3; - typename TypeTraits::ReferencedType m_a4; - typename TypeTraits::ReferencedType m_a5; - typename TypeTraits::ReferencedType m_a6; - } *ev = new EventFunctionImpl6 (f, a1, a2, a3, a4, a5, a6); - return ev; + std::function m_function; + }; + return new EventMemberImpl (std::forward (args)...); } } // namespace ns3 diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/object.h --- a/src/core/model/object.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/object.h Fri Jan 20 16:21:38 2017 +0300 @@ -222,7 +222,8 @@ /** * Check if the object has been initialized. * - * \brief returns true if the object has been initialized. + * \brief Check if the object has been initialized. + * \returns \c true if the object has been initialized. */ bool IsInitialized (void) const; @@ -525,144 +526,14 @@ * Create an object by type, with varying number of constructor parameters. * * \tparam T \explicit The type of the derived object to construct. + * \tparam Ts \deduced Constructor argument types. + * \param [in] args The arguments to use in creating the object. * \return The derived object. */ -template -Ptr CreateObject (void) +template +Ptr CreateObject (Ts... args) { - return CompleteConstruct (new T ()); -} -/** - * \copybrief CreateObject() - * \tparam T \explicit The type of the derived object to construct. - * \tparam T1 \deduced The type of the constructor argument. - * \param [in] a1 The constructor argument - * \return The derived object. - */ -template -Ptr CreateObject (T1 a1) -{ - return CompleteConstruct (new T (a1)); -} - -/** - * \copybrief CreateObject() - * \tparam T \explicit The type of the derived object to construct. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \param [in] a1 The constructor first argument - * \param [in] a2 The constructor second argument - * \return The derived object. - */ -template -Ptr CreateObject (T1 a1, T2 a2) -{ - return CompleteConstruct (new T (a1,a2)); -} - -/** - * \copybrief CreateObject() - * \tparam T \explicit The type of the derived object to construct. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \param [in] a1 The constructor first argument - * \param [in] a2 The constructor second argument - * \param [in] a3 The constructor third argument - * \return The derived object. - */ -template -Ptr CreateObject (T1 a1, T2 a2, T3 a3) -{ - return CompleteConstruct (new T (a1,a2,a3)); -} - -/** - * \copybrief CreateObject() - * \tparam T \explicit The type of the derived object to construct. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \param [in] a1 The constructor first argument - * \param [in] a2 The constructor second argument - * \param [in] a3 The constructor third argument - * \param [in] a4 The constructor fourth argument - * \return The derived object. - */ -template -Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4) -{ - return CompleteConstruct (new T (a1,a2,a3,a4)); -} - -/** - * \copybrief CreateObject() - * \tparam T \explicit The type of the derived object to construct. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \param [in] a1 The constructor first argument - * \param [in] a2 The constructor second argument - * \param [in] a3 The constructor third argument - * \param [in] a4 The constructor fourth argument - * \param [in] a5 The constructor fifth argument - * \return The derived object. - */ -template -Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return CompleteConstruct (new T (a1,a2,a3,a4,a5)); -} - -/** - * \copybrief CreateObject() - * \tparam T \explicit The type of the derived object to construct. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \param [in] a1 The constructor first argument - * \param [in] a2 The constructor second argument - * \param [in] a3 The constructor third argument - * \param [in] a4 The constructor fourth argument - * \param [in] a5 The constructor fifth argument - * \param [in] a6 The constructor sixth argument - * \return The derived object. - */ -template -Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return CompleteConstruct (new T (a1,a2,a3,a4,a5,a6)); -} - -/** - * \copybrief CreateObject() - * \tparam T \explicit The type of the derived object to construct. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \tparam T7 \deduced The type of the seventh constructor argument. - * \param [in] a1 The constructor first argument - * \param [in] a2 The constructor second argument - * \param [in] a3 The constructor third argument - * \param [in] a4 The constructor fourth argument - * \param [in] a5 The constructor fifth argument - * \param [in] a6 The constructor sixth argument - * \param [in] a7 The constructor seventh argument - * \return The derived object. - */ -template -Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) -{ - return CompleteConstruct (new T (a1,a2,a3,a4,a5,a6,a7)); + return CompleteConstruct (new T (args...)); } /**@}*/ diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/ptr.h --- a/src/core/model/ptr.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/ptr.h Fri Jan 20 16:21:38 2017 +0300 @@ -210,138 +210,20 @@ * Create class instances by constructors with varying numbers * of arguments and return them by Ptr. * - * These methods work for any class \c T. + * This template work for any class \c T derived from ns3::SimpleRefCount * * \see CreateObject for methods to create derivatives of ns3::Object */ /** @{ */ /** - * \tparam T \explicit The type of class object to create. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (void); - -/** * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \param [in] a1 The first constructor argument. + * \tparam Ts \deduced Types of the constructor arguments. + * \param [in] args Constructor arguments. * \return A Ptr to the newly created \c T. */ template -Ptr Create (T1 a1); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \param [in] a6 The sixth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \tparam T7 \deduced The type of the seventh constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \param [in] a6 The sixth constructor argument. - * \param [in] a7 The seventh constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7); + typename... Ts> +Ptr Create (Ts... args); /** @}*/ /** @@ -510,52 +392,10 @@ * friend non-member function implementations ************************************************/ -template -Ptr Create (void) +template +Ptr Create (Ts... args) { - return Ptr (new T (), false); -} - -template -Ptr Create (T1 a1) -{ - return Ptr (new T (a1), false); -} - -template -Ptr Create (T1 a1, T2 a2) -{ - return Ptr (new T (a1, a2), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3) -{ - return Ptr (new T (a1, a2, a3), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4) -{ - return Ptr (new T (a1, a2, a3, a4), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return Ptr (new T (a1, a2, a3, a4, a5), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return Ptr (new T (a1, a2, a3, a4, a5, a6), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) -{ - return Ptr (new T (a1, a2, a3, a4, a5, a6, a7), false); + return Ptr (new T (args...), false); } template diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/realtime-simulator-impl.cc --- a/src/core/model/realtime-simulator-impl.cc Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/realtime-simulator-impl.cc Fri Jan 20 16:21:38 2017 +0300 @@ -502,7 +502,7 @@ RealtimeSimulatorImpl::Stop (Time const &delay) { NS_LOG_FUNCTION (this << delay); - Simulator::Schedule (delay, &Simulator::Stop); + Simulator::Schedule (delay, &Simulator::Stop); } // diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/simulator.cc --- a/src/core/model/simulator.cc Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/simulator.cc Fri Jan 20 16:21:38 2017 +0300 @@ -283,30 +283,6 @@ } -EventId -Simulator::Schedule (Time const &delay, void (*f)(void)) -{ - return DoSchedule (delay, MakeEvent (f)); -} - -void -Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void)) -{ - return ScheduleWithContext (context, delay, MakeEvent (f)); -} - -EventId -Simulator::ScheduleNow (void (*f)(void)) -{ - return DoScheduleNow (MakeEvent (f)); -} - -EventId -Simulator::ScheduleDestroy (void (*f)(void)) -{ - return DoScheduleDestroy (MakeEvent (f)); -} - void Simulator::Remove (const EventId &id) { diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/simulator.h --- a/src/core/model/simulator.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/simulator.h Fri Jan 20 16:21:38 2017 +0300 @@ -191,7 +191,7 @@ */ NO_CONTEXT = 0xffffffff }; - + /** * @name Schedule events (in the same context) to run at a future time. */ @@ -202,131 +202,16 @@ * for the current simulation time plus the @p delay passed as a * parameter. * - * When the event expires (when it becomes due to be run), the - * input method will be invoked on the input object. - * - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. + * @tparam Ts @deduced Argument types. * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @param [in] args Arguments to pass to MakeEvent. * @returns The id for the scheduled event. */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj); + template + static EventId Schedule (Time const &delay, Ts&&... args); /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @tparam T5 @deduced Type of fifth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @param [in] a5 The fifth argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * @param time the relative expiration time of the event. - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - * @param a5 the fifth argument to pass to the invoked method - * @param a6 the sixth argument to pass to the invoked method - * @returns an id for the scheduled event. - */ - template - static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - - /** + * * Schedule an event to expire after @p delay. * This can be thought of as scheduling an event * for the current simulation time plus the @p delay passed as a @@ -334,122 +219,16 @@ * * When the event expires (when it becomes due to be run), the * function will be invoked with any supplied arguments. + * + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke + * @param [in] f The function to invoke. + * @param [in] args Arguments to pass to the invoked function. * @returns The id for the scheduled event. */ - static EventId Schedule (Time const &delay, void (*f)(void)); - - /** - * @see Schedule(const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke. - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1); - - /** - * @see Schedule(const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2); - - /** - * @see Schedule(const Time&,void(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @see Schedule(const Time&,(*)(void)) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see Schedule(const Time&,void(*)(void)) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam U5 @deduced Formal type of the fifth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @tparam T5 @deduced Actual type of the fifth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @param [in] a5 The fifth argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * @param time the relative expiration time of the event. - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - * @param a5 the fifth argument to pass to the function to invoke - * @param a6 the sixth argument to pass to the function to invoke - * @returns an id for the scheduled event. - */ - template - static EventId Schedule (Time const &time, void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - - + template + static EventId Schedule (Time const &delay, void (*f)(Us...), Ts&&... args); /** @} */ /** @@ -463,498 +242,59 @@ * A context of 0xffffffff means no context is specified. * This method is thread-safe: it can be called from any thread. * - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. + * @tparam Ts @deduced Argument types. * @param [in] context User-specified context parameter * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @param [in] args Arguments to pass to MakeEvent. */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj); + template + static void ScheduleWithContext (uint32_t context, Time const &delay, Ts&&... args); /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @tparam T5 @deduced Type of fifth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @param [in] a5 The fifth argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * This method is thread-safe: it can be called from any thread. - * - * @param time the relative expiration time of the event. - * @param context user-specified context parameter - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - * @param a5 the fifth argument to pass to the invoked method - * @param a6 the sixth argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - - /** * Schedule an event with the given context. * A context of 0xffffffff means no context is specified. * This method is thread-safe: it can be called from any thread. * - * When the event expires (when it becomes due to be run), the - * function will be invoked with any supplied arguments. - * - * This method is thread-safe: it can be called from any thread. + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. * @param [in] context User-specified context parameter * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke + * @param [in] f The function to invoke. + * @param [in] args Arguments to pass to the invoked function. */ - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void)); + template + static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(Us...), Ts&&... args); + /** @} */ /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam U5 @deduced Formal type of the fifth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @tparam T5 @deduced Actual type of the fifth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @param [in] a5 The fifth argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * This method is thread-safe: it can be called from any thread. - * - * @param time the relative expiration time of the event. - * @param context user-specified context parameter - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - * @param a5 the fifth argument to pass to the function to invoke - * @param a6 the sixth argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - - /** @} */ - - /** * @name Schedule events (in the same context) to run now. */ /** @{ */ /** * Schedule an event to expire Now. All events scheduled to * to expire "Now" are scheduled FIFO, after all normal events - * have expired. + * have expired. * - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @tparam Ts @deduced Actual function argument types. + * @param [in] args Arguments to pass to the invoked function. * @return The EventId of the scheduled event. */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj); + template + static EventId ScheduleNow (Ts&&... args); /** - * @see ScheduleNow(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method + * Schedule an event to expire Now. All events scheduled to + * to expire "Now" are scheduled FIFO, after all normal events + * have expired. + * + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. + * @param [in] f The function to invoke. + * @param [in] args Arguments to pass to MakeEvent. * @return The EventId of the scheduled event. */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @see ScheduleNow(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @see ScheduleNow(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleNow(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4); - /** - * @see ScheduleNow(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @tparam T5 @deduced Type of fifth argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @param [in] a5 The fifth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - * @param a5 the fifth argument to pass to the invoked method - * @param a6 the sixth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - - /** - * @copybrief ScheduleNow(MEM,OBJ) - * - * When the event expires (when it becomes due to be run), the - * function will be invoked with any supplied arguments. - * @param [in] f The function to invoke - * @return The EventId of the scheduled event. - */ - static EventId ScheduleNow (void (*f)(void)); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1), T1 a1); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam U5 @deduced Formal type of the fifth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @tparam T5 @deduced Actual type of the fifth argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @param [in] a5 The fifth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - * @param a5 the fifth argument to pass to the function to invoke - * @param a6 the sixth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - + template + static EventId ScheduleNow (void (*f)(Us...), Ts&&... args); /** @} */ /** @@ -962,240 +302,33 @@ */ /** @{ */ /** - * Schedule an event to expire when Simulator::Destroy is called. - * All events scheduled to expire at "Destroy" time are scheduled FIFO, - * after all normal events have expired and only when + * Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called. + * All events scheduled to expire at "Destroy" time are scheduled FIFO, + * after all normal events have expired and only when * Simulator::Destroy is invoked. * - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. + * @param [in] args Arguments to pass to MakeEvent. * @return The EventId of the scheduled event. */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj); + template + static EventId ScheduleDestroy (Ts&&... args); /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method + * Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called. + * All events scheduled to expire at "Destroy" time are scheduled FIFO, + * after all normal events have expired and only when + * Simulator::Destroy is invoked. + * + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. + * @param [in] f The function to invoke. + * @param [in] args Arguments to pass to MakeEvent. * @return The EventId of the scheduled event. */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4); - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @tparam T5 @deduced Type of fifth argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @param [in] a5 The fifth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - * @param a5 the fifth argument to pass to the invoked method - * @param a6 the sixth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - - /** - * @copybrief ScheduleDestroy(MEM,OBJ) - * When Simulator::Destroy() is called, the - * function will be invoked with any supplied arguments. - * @param [in] f The function to invoke - * @return The EventId of the scheduled event. - */ - static EventId ScheduleDestroy (void (*f)(void)); - - /** - * @see ScheduleDestory((*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (void (*f)(U1), T1 a1); - - /** - * @see ScheduleDestory((*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2); - - /** - * @see ScheduleDestory((*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleDestory((*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see ScheduleDestory((*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam U5 @deduced Formal type of the fifth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @tparam T5 @deduced Actual type of the fifth argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @param [in] a5 The fifth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - * @param a5 the fifth argument to pass to the function to invoke - * @param a6 the sixth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - + template + static EventId ScheduleDestroy (void (*f)(Us...), Ts&&... args); /** @} */ /** @@ -1367,405 +500,56 @@ namespace ns3 { -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj) +template +EventId Simulator::Schedule (Time const &delay, Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj)); + return DoSchedule (delay, MakeEvent (std::forward (args)...)); } - -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1) +template +EventId Simulator::Schedule (Time const &delay, void (*f)(Us...), Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1)); + return DoSchedule (delay, MakeEvent (f, std::forward (args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2)); + return ScheduleWithContext (context, delay, MakeEvent (std::forward (args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(Us...), Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3)); + return ScheduleWithContext (context, delay, MakeEvent (f, std::forward (args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +template +EventId +Simulator::ScheduleNow (Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); + return DoScheduleNow (MakeEvent (std::forward (args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +template +EventId +Simulator::ScheduleNow (void (*f)(Us...), Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); + return DoScheduleNow (MakeEvent (f, std::forward (args)...)); } -template -EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +template +EventId +Simulator::ScheduleDestroy (Ts&&... args) { - return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); + return DoScheduleDestroy (MakeEvent (std::forward (args)...)); } -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1) +template +EventId +Simulator::ScheduleDestroy (void (*f)(Us...), Ts&&... args) { - return DoSchedule (delay, MakeEvent (f, a1)); -} - -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2) -{ - return DoSchedule (delay, MakeEvent (f, a1, a2)); -} - -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3) -{ - return DoSchedule (delay, MakeEvent (f, a1, a2, a3)); -} - -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) -{ - return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4)); -} - -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4, a5)); -} - -template -EventId Simulator::Schedule (Time const &time, void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return DoSchedule (time, MakeEvent (f, a1, a2, a3, a4, a5, a6)); -} - - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj) -{ - ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj)); -} - - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1) -{ - return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) -{ - return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) -{ - return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) -{ - return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1) -{ - return ScheduleWithContext (context, delay, MakeEvent (f, a1)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2) -{ - return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3) -{ - return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) -{ - return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4, a5)); -} - -template -void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return ScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4, a5, a6)); -} - - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj)); -} - - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); -} - -template -EventId -Simulator::ScheduleNow (void (*f)(U1), T1 a1) -{ - return DoScheduleNow (MakeEvent (f, a1)); -} - -template -EventId -Simulator::ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2) -{ - return DoScheduleNow (MakeEvent (f, a1, a2)); -} - -template -EventId -Simulator::ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3) -{ - return DoScheduleNow (MakeEvent (f, a1, a2, a3)); -} - -template -EventId -Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) -{ - return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4)); -} - -template -EventId -Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5)); -} - -template -EventId -Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5, a6)); -} - - -template -EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj) -{ - return DoScheduleDestroy (MakeEvent (mem_ptr, obj)); -} - - -template -EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1) -{ - return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1)); -} - -template -EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) -{ - return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2)); -} - -template -EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) -{ - return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3)); -} - -template -EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) -{ - return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); -} - -template -EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); -} - -template -EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); -} - -template -EventId -Simulator::ScheduleDestroy (void (*f)(U1), T1 a1) -{ - return DoScheduleDestroy (MakeEvent (f, a1)); -} - -template -EventId -Simulator::ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2) -{ - return DoScheduleDestroy (MakeEvent (f, a1, a2)); -} - -template -EventId -Simulator::ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3) -{ - return DoScheduleDestroy (MakeEvent (f, a1, a2, a3)); -} - -template -EventId -Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) -{ - return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4)); -} - -template -EventId -Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5)); -} - -template -EventId -Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5, a6)); + return DoScheduleDestroy (MakeEvent (f, std::forward (args)...)); } } // namespace ns3 diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/timer-impl.h --- a/src/core/model/timer-impl.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/timer-impl.h Fri Jan 20 16:21:38 2017 +0300 @@ -28,7 +28,7 @@ /** * \file - * \ingroup timer + * \ingroup vttimer * \ingroup timerimpl * ns3::TimerImpl declaration and implementation. */ @@ -36,7 +36,7 @@ namespace ns3 { /** - * \ingroup timer + * \ingroup vttimer * The timer implementation underlying Timer and Watchdog. */ class TimerImpl @@ -143,7 +143,7 @@ namespace ns3 { /** - * \ingroup timer + * \ingroup vttimer * \defgroup timerimpl TimerImpl Implementation * @{ */ @@ -962,7 +962,7 @@ return function; } -/**@}*/ // \ingroup timer +/**@}*/ // \ingroup vttimer /******************************************************************** diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/timer.cc --- a/src/core/model/timer.cc Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/timer.cc Fri Jan 20 16:21:38 2017 +0300 @@ -24,7 +24,7 @@ /** * \file - * \ingroup timer + * \ingroup vttimer * ns3::Timer implementation. */ diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/timer.h --- a/src/core/model/timer.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/timer.h Fri Jan 20 16:21:38 2017 +0300 @@ -27,7 +27,7 @@ /** * \file - * \ingroup timer + * \ingroup vttimer * ns3::Timer class declaration. */ @@ -35,7 +35,7 @@ /** * \ingroup core - * \defgroup timer Virtual Time Timer and Watchdog + * \defgroup vttimer Virtual Time Timer and Watchdog * * The Timer and Watchdog objects both facilitate scheduling functions * to execute a specified virtual time in the future. @@ -53,16 +53,16 @@ class TimerImpl; /** - * \ingroup timer - * \brief A simple Timer class + * \ingroup vttimer + * \brief A simple virtual Timer class * - * A timer is used to hold together a delay, a function to invoke + * A (virtual time) timer is used to hold together a delay, a function to invoke * when the delay expires, and a set of arguments to pass to the function * when the delay expires. * * A Timer can be suspended, resumed, cancelled and queried for the * time left, but it can't be extended (except by suspending and - * resuming.) + * resuming). * * A timer can also be used to enforce a set of predefined event lifetime * management policies. These policies are specified at construction time @@ -134,62 +134,13 @@ /** - * \param [in] a1 the first argument - * - * Store this argument in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument + * \tparam Ts \deduced Argument types. + * \param [in] args arguments * * Store these arguments in this Timer for later use by Timer::Schedule. */ - template - void SetArguments (T1 a1, T2 a2); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - * \param [in] a6 the sixth argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); + template + void SetArguments (Ts... args); /** * \param [in] delay The delay @@ -319,75 +270,16 @@ m_impl = MakeTimerImpl (memPtr, objPtr); } -template +template void -Timer::SetArguments (T1 a1) +Timer::SetArguments (Ts... args) { if (m_impl == 0) { NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); return; } - m_impl->SetArgs (a1); -} -template -void -Timer::SetArguments (T1 a1, T2 a2) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5, a6); + m_impl->SetArgs (args...); } } // namespace ns3 diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/traced-callback.h --- a/src/core/model/traced-callback.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/traced-callback.h Fri Jan 20 16:21:38 2017 +0300 @@ -36,29 +36,19 @@ * \ingroup tracing * \brief Forward calls to a chain of Callback * - * An TracedCallback has almost exactly the same API as a normal + * A TracedCallback has almost exactly the same API as a normal * Callback but instead of forwarding calls to a single function * (as a Callback normally does), it forwards calls to a chain * of Callback. Connect adds a Callback at the end of the chain * of callbacks. Disconnect removes a Callback from the chain of callbacks. * * This is a functor: the chain of Callbacks is invoked by - * calling one of the \c operator() forms with the appropriate + * calling the \c operator() form with the appropriate * number of arguments. * - * \tparam T1 \explicit Type of the first argument to the functor. - * \tparam T2 \explicit Type of the second argument to the functor. - * \tparam T3 \explicit Type of the third argument to the functor. - * \tparam T4 \explicit Type of the fourth argument to the functor. - * \tparam T5 \explicit Type of the fifth argument to the functor. - * \tparam T6 \explicit Type of the sixth argument to the functor. - * \tparam T7 \explicit Type of the seventh argument to the functor. - * \tparam T8 \explicit Type of the eighth argument to the functor. + * \tparam Ts \explicit Types of the functor arguments. */ -template +template class TracedCallback { public: @@ -94,120 +84,11 @@ */ void Disconnect (const CallbackBase & callback, std::string path); /** - * \name Functors taking various numbers of arguments. - * - * The version selected is determined by the number of arguments - * at the point where the Callback is invoked in the class - * which fires the Callback. + * \brief Functor which invokes the chain of Callbacks. + * \tparam Ts \deduced Types of the functor arguments. + * \param [in] args The arguments to the functor. */ - /**@{*/ - /** Functor which invokes the chain of Callbacks. */ - void operator() (void) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \param [in] a1 The first argument to the functor. - */ - void operator() (T1 a1) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - */ - void operator() (T1 a1, T2 a2) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - * \param [in] a6 The sixth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \tparam T7 \deduced Type of the seventh argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - * \param [in] a6 The sixth argument to the functor. - * \param [in] a7 The seventh argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \tparam T7 \deduced Type of the seventh argument to the functor. - * \tparam T8 \deduced Type of the eighth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - * \param [in] a6 The sixth argument to the functor. - * \param [in] a7 The seventh argument to the functor. - * \param [in] a8 The eighth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8) const; - /**@}*/ + void operator() (Ts... args) const; /** * TracedCallback signature for POD. @@ -225,16 +106,9 @@ /** * Container type for holding the chain of Callbacks. * - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \tparam T7 \deduced Type of the seventh argument to the functor. - * \tparam T8 \deduced Type of the eighth argument to the functor. + * \tparam Ts \deduced Types of the functor arguments. */ - typedef std::list > CallbackList; + typedef std::list > CallbackList; /** The chain of Callbacks. */ CallbackList m_callbackList; }; @@ -248,45 +122,33 @@ namespace ns3 { -template -TracedCallback::TracedCallback () +template +TracedCallback::TracedCallback () : m_callbackList () { } -template +template void -TracedCallback::ConnectWithoutContext (const CallbackBase & callback) +TracedCallback::ConnectWithoutContext (const CallbackBase & callback) { - Callback cb; + Callback cb; if (!cb.Assign (callback)) NS_FATAL_ERROR_NO_MSG(); m_callbackList.push_back (cb); } -template +template void -TracedCallback::Connect (const CallbackBase & callback, std::string path) +TracedCallback::Connect (const CallbackBase & callback, std::string path) { - Callback cb; + Callback cb; if (!cb.Assign (callback)) NS_FATAL_ERROR ("when connecting to " << path); - Callback realCb = cb.Bind (path); + Callback realCb = cb.Bind (path); m_callbackList.push_back (realCb); } -template +template void -TracedCallback::DisconnectWithoutContext (const CallbackBase & callback) +TracedCallback::DisconnectWithoutContext (const CallbackBase & callback) { for (typename CallbackList::iterator i = m_callbackList.begin (); i != m_callbackList.end (); /* empty */) @@ -301,134 +163,24 @@ } } } -template +template void -TracedCallback::Disconnect (const CallbackBase & callback, std::string path) +TracedCallback::Disconnect (const CallbackBase & callback, std::string path) { - Callback cb; + Callback cb; if (!cb.Assign (callback)) NS_FATAL_ERROR ("when disconnecting from " << path); - Callback realCb = cb.Bind (path); + Callback realCb = cb.Bind (path); DisconnectWithoutContext (realCb); } -template +template void -TracedCallback::operator() (void) const +TracedCallback::operator() (Ts... args) const { for (typename CallbackList::const_iterator i = m_callbackList.begin (); i != m_callbackList.end (); i++) { - (*i)(); - } -} -template -void -TracedCallback::operator() (T1 a1) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5, a6); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5, a6, a7); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5, a6, a7, a8); + (*i)(args...); } } diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/watchdog.cc --- a/src/core/model/watchdog.cc Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/watchdog.cc Fri Jan 20 16:21:38 2017 +0300 @@ -23,7 +23,7 @@ /** * \file - * \ingroup timer + * \ingroup vttimer * ns3::Watchdog timer class implementation. */ diff -r 74bc73b0ea6c -r aa070d59557c src/core/model/watchdog.h --- a/src/core/model/watchdog.h Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/model/watchdog.h Fri Jan 20 16:21:38 2017 +0300 @@ -25,7 +25,7 @@ /** * \file - * \ingroup timer + * \ingroup vttimer * ns3::Watchdog timer class declaration. */ @@ -34,7 +34,7 @@ class TimerImpl; /** - * \ingroup timer + * \ingroup vttimer * \brief A very simple watchdog operating in virtual time. * * The watchdog timer is started by calling Ping with a delay value. @@ -101,71 +101,11 @@ */ /**@{*/ /** - * \tparam T1 \deduced Type of the first argument. - * \param [in] a1 The first argument + * \tparam Ts \deduced Argument types. + * \param [in] args arguments */ - template - void SetArguments (T1 a1); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - */ - template - void SetArguments (T1 a1, T2 a2); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \tparam T4 \deduced Type of the fourth argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \tparam T4 \deduced Type of the fourth argument. - * \tparam T5 \deduced Type of the fifth argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \tparam T4 \deduced Type of the fourth argument. - * \tparam T5 \deduced Type of the fifth argument. - * \tparam T6 \deduced Type of the sixth argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - * \param [in] a6 the sixth argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); + template + void SetArguments (Ts&&... args); /**@}*/ private: @@ -209,75 +149,16 @@ m_impl = MakeTimerImpl (memPtr, objPtr); } -template +template void -Watchdog::SetArguments (T1 a1) +Watchdog::SetArguments (Ts&&... args) { if (m_impl == 0) { NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); return; } - m_impl->SetArgs (a1); -} -template -void -Watchdog::SetArguments (T1 a1, T2 a2) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5, a6); + m_impl->SetArgs (std::forward(args)...); } } // namespace ns3 diff -r 74bc73b0ea6c -r aa070d59557c src/core/wscript --- a/src/core/wscript Fri Jan 20 13:50:17 2017 +0100 +++ b/src/core/wscript Fri Jan 20 16:21:38 2017 +0300 @@ -148,7 +148,6 @@ 'model/timer.cc', 'model/watchdog.cc', 'model/synchronizer.cc', - 'model/make-event.cc', 'model/log.cc', 'model/breakpoint.cc', 'model/type-id.cc',