From 97dd10ea5939ad8fca2d990297fa5c24cb8024b1 Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Thu, 28 May 2020 22:18:55 +0000 Subject: [PATCH] core: use variadic template for CreateObject --- src/core/model/callback.h | 361 +++----- src/core/model/object.h | 151 +--- src/core/model/ptr.h | 188 +--- src/core/model/simulator.cc | 24 - src/core/model/simulator.h | 1370 ++---------------------------- src/core/model/timer.h | 131 +-- src/core/model/traced-callback.h | 304 +------ src/core/model/watchdog.h | 134 +-- 8 files changed, 272 insertions(+), 2391 deletions(-) diff --git a/src/core/model/callback.h b/src/core/model/callback.h index e901edc2e..3dcc1dceb 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -55,41 +55,7 @@ namespace ns3 { * Callback implementation classes */ /** - * \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 + * \ingroup callbackimpl * \defgroup makeboundcallback MakeBoundCallback from functions bound with up to three arguments. * * Build bound Callbacks which take varying numbers of arguments, @@ -104,19 +70,21 @@ namespace ns3 { /** - * \ingroup makecallbackmemptr + * \ingroup callbackimpl * * Trait class to convert a pointer into a reference, * used by MemPtrCallBackImpl + * \tparam T \deduced The type being converted. */ template struct CallbackTraits; /** - * \ingroup makecallbackmemptr + * \ingroup callbackimpl * * Trait class to convert a pointer into a reference, * used by MemPtrCallBackImpl + * \tparam T \deduced The type being converted. */ template struct CallbackTraits @@ -164,7 +132,7 @@ protected: /** * Helper to get the C++ typeid as a string. * - * \tparam T The type of the argument. + * \tparam T \explicit The type of the argument. * \returns The result of applying typeid to the template type \pname{T}. */ template @@ -187,6 +155,9 @@ protected: /** * \ingroup callbackimpl * The unqualified CallbackImpl class + * \tparam R \explicit The return type of the Callback. + * The remaining template arguments are the types of any arguments + * to the Callback. */ template class CallbackImpl; @@ -458,6 +429,7 @@ public: /** * \ingroup callbackimpl * CallbackImpl with functors + * \tparam T \deduced Function pointer type. */ template class FunctorCallbackImpl : public CallbackImpl @@ -617,8 +589,10 @@ private: }; /** - * \ingroup makecallbackmemptr + * \ingroup callbackimpl * CallbackImpl for pointer to member functions + * \tparam OBJ_PTR \deduced Type of the target object, as a pointer. + * \tparam MEM_PTR \deduced Type of the class member function. */ template class MemPtrCallbackImpl : public CallbackImpl @@ -783,6 +757,8 @@ private: /** * \ingroup callbackimpl * CallbackImpl for functors with first argument bound at construction + * \tparam T \explicit Type of the functor. + * \tparam TX \explicit Type of the bound argument. */ template class BoundFunctorCallbackImpl : public CallbackImpl @@ -790,6 +766,10 @@ class BoundFunctorCallbackImpl : public CallbackImpl class TwoBoundFunctorCallbackImpl : public CallbackImpl @@ -938,6 +921,12 @@ class TwoBoundFunctorCallbackImpl : public CallbackImpl class ThreeBoundFunctorCallbackImpl : public CallbackImpl @@ -1073,6 +1066,14 @@ class ThreeBoundFunctorCallbackImpl : public CallbackImpl Callback (FUNCTOR const &functor, bool, bool) @@ -1293,6 +1299,8 @@ public: /** * Construct a member function pointer call back. * + * \tparam OBJ_PTR \deduced Type of the target object, as a pointer. + * \tparam MEM_PTR \deduced Type of the class member function. * \param [in] objPtr Pointer to the object * \param [in] memPtr Pointer to the member function */ @@ -1313,6 +1321,7 @@ public: /** * Bind the first arguments * + * \tparam T \deduced The type of the bound argument. * \param [in] a Argument to bind * \return The bound callback */ @@ -1330,6 +1339,8 @@ public: /** * Bind the first two arguments * + * \tparam TX1 \deduced Type of the first bound argument. + * \tparam TX2 \deduced Type of the second bound argument. * \param [in] a1 First argument to bind * \param [in] a2 Second argument to bind * \return The bound callback @@ -1348,6 +1359,9 @@ public: /** * Bind the first three arguments * + * \tparam TX1 \deduced The actual type of the first bound argument. + * \tparam TX2 \deduced The actual type of the second bound argument. + * \tparam TX3 \deduced The actual type of the third bound argument. * \param [in] a1 First argument to bind * \param [in] a2 Second argument to bind * \param [in] a3 Third argument to bind @@ -1595,250 +1609,92 @@ bool operator != (Callback a, Callback -Callback MakeCallback (R (T::*memPtr)(void), OBJ objPtr) +template +Callback MakeCallback (R (T::*memPtr)(Ts...), OBJ objPtr) { - return Callback (objPtr, memPtr); + return Callback (objPtr, memPtr); } -template -Callback MakeCallback (R (T::*memPtr)() const, OBJ objPtr) +template +Callback MakeCallback (R (T::*memPtr)(Ts...) 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); + return Callback (objPtr, memPtr); } /**@}*/ /** - * \ingroup makecallbackfnptr - * @{ - */ -/** + * \ingroup callback * \param [in] fnPtr Function pointer * \return A wrapper Callback * * Build Callbacks for functions which take varying numbers of arguments * and potentially returning a value. + * + * \tparam R \deduced Return type of the callback function.. + * \tparam Ts \deduced Type list of any arguments to the member function. */ -template -Callback MakeCallback (R (*fnPtr)()) +template +Callback MakeCallback (R (*fnPtr)(Ts...)) { - return Callback (fnPtr, true, true); + 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. + * + * \tparam R \deduced Return type of the callback function.. + * \tparam Ts \deduced Type list of any arguments to the member function. */ -template -Callback MakeNullCallback (void) +template +Callback MakeNullCallback (void) { - return Callback (); + 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 (); -} -/**@}*/ /** * \ingroup makeboundcallback * @{ * Make Callbacks with one bound argument. + * + * \tparam R \deduced Return type of the callback + * \tparam TX \deduced Formal type of the first argument to the callback. + * \tparam ARG \deduced Actual type of the bound argument. + * Remaining template parameters are the types of remaining arguments + * to the callback. * \param [in] fnPtr Function pointer * \param [in] a1 First bound argument * \return A bound Callback @@ -1920,6 +1776,13 @@ Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4 * \ingroup makeboundcallback * @{ * Make Callbacks with two bound arguments. + * \tparam R \deduced Return type of the callback + * \tparam TX1 \deduced Formal type of the first argument to the callback. + * \tparam TX2 \deduced Formal type of the second argument to the callback. + * \tparam ARG1 \deduced Actual type of the first bound argument. + * \tparam ARG2 \deduced Actual type of the second bound argument. + * Remaining template parameters are the types of remaining arguments + * to the callback. * \param [in] fnPtr Function pointer * \param [in] a1 First bound argument * \param [in] a2 Second bound argument @@ -1994,6 +1857,15 @@ Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3, * \ingroup makeboundcallback * @{ * Make Callbacks with three bound arguments. + * \tparam R \deduced Return type of the callback + * \tparam TX1 \deduced Formal type of the first argument to the callback. + * \tparam TX2 \deduced Formal type of the second argument to the callback. + * \tparam TX3 \deduced Formal type of the third argument to the callback. + * \tparam ARG1 \deduced Actual type of the first bound argument. + * \tparam ARG2 \deduced Actual type of the second bound argument. + * \tparam ARG3 \deduced Actual type of the third bound argument. + * Remaining template parameters are the types of remaining arguments + * to the callback. * \param [in] a1 First bound argument * \param [in] a2 Second bound argument * \param [in] a3 Third bound argument @@ -2079,6 +1951,7 @@ public: /** * Give value my callback, if type compatible * + * \tparam T \deduced The type in which to retrieve the value. * \param [out] value Destination callback * \returns \c true if successful */ diff --git a/src/core/model/object.h b/src/core/model/object.h index bb161e7e6..bd093c1cd 100644 --- a/src/core/model/object.h +++ b/src/core/model/object.h @@ -149,8 +149,9 @@ public: * Get a pointer to the requested aggregated Object. If the type of object * requested is ns3::Object, a Ptr to the calling object is returned. * - * \returns A pointer to the requested aggregated Object matching the - * type requested, or zero if it could not be found. + * \tparam T \explicit The type of the aggregated Object to retrieve. + * \returns A pointer to the requested Object, or zero + * if it could not be found. */ template inline Ptr GetObject (void) const; @@ -158,6 +159,7 @@ public: * Get a pointer to the requested aggregated Object by TypeId. If the * TypeId argument is ns3::Object, a Ptr to the calling object is returned. * + * \tparam T \explicit The type of the aggregated Object to retrieve. * \param [in] tid The TypeId of the requested Object. * \returns A pointer to the requested Object with the specified TypeId, * or zero if it could not be found. @@ -223,7 +225,8 @@ public: /** * Check if the object has been initialized. * - * \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; @@ -297,6 +300,7 @@ private: /** * Copy an Object. * + * \tparam T \deduced The type of the Object being copied. * \param [in] object A pointer to the object to copy. * \returns A copy of the input object. * @@ -313,7 +317,7 @@ private: /** * Set the TypeId and construct all Attributes of an Object. * - * \tparam T \explicit The type of the derived object we are constructing. + * \tparam T \deduced The type of the Object to complete. * \param [in] object The uninitialized object pointer. * \return The derived object. */ @@ -552,144 +556,13 @@ Ptr CompleteConstruct (T *object) * Create an object by type, with varying number of constructor parameters. * * \tparam T \explicit The type of the derived object to construct. + * \param [in] args Arguments to pass to the constructor. * \return The derived object. */ -template -Ptr CreateObject (void) +template +Ptr CreateObject (Args&&... 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 (std::forward (args)...)); } /**@}*/ diff --git a/src/core/model/ptr.h b/src/core/model/ptr.h index 158cac175..d0b7ab8f4 100644 --- a/src/core/model/ptr.h +++ b/src/core/model/ptr.h @@ -67,7 +67,7 @@ namespace ns3 { * functions and their goal is just is save you a small * bit of typing. * - * \tparam T \explicit The underlying type. + * \tparam T \explicit The type of the underlying object. */ template class Ptr @@ -95,6 +95,7 @@ private: * to returning to the caller so the caller is * responsible for calling Unref himself. * + * \tparam U \deduced The actual type of the argument and return pointer. * \param [in] p Smart pointer * \return The pointer managed by this smart pointer. */ @@ -107,6 +108,7 @@ private: * to returning to the caller so the caller is not * responsible for calling Unref himself. * + * \tparam U \deduced The actual type of the argument and return pointer. * \param [in] p Smart pointer * \return The pointer managed by this smart pointer. */ @@ -148,7 +150,7 @@ public: /** * Copy, removing \c const qualifier. * - * \tparam U \deduced The underlying type of the \c const object. + * \tparam U \deduced The type underlying the Ptr being copied. * \param [in] o The Ptr to copy. */ template @@ -211,143 +213,27 @@ public: * 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); + typename... Ts> +Ptr Create (Ts... args); -/** - * \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); /** @}*/ /** * \ingroup ptr * Output streamer. + * \tparam T \deduced The type of the underlying Object. * \param [in,out] os The output stream. * \param [in] p The Ptr. * \returns The stream. @@ -422,6 +308,7 @@ bool operator != (Ptr const &lhs, Ptr const &rhs); * \ingroup ptr * Comparison operator applied to the underlying pointers. * + * \tparam T \deduced The type of the operands. * \param [in] lhs The left operand. * \param [in] rhs The right operand. * \return The comparison on the underlying pointers. @@ -461,7 +348,7 @@ struct CallbackTraits; * * This is the specialization for Ptr types. * - * \tparam T \deduced The base object type. + * \tparam T \deduced The type of the underlying object. */ template struct CallbackTraits > @@ -488,7 +375,7 @@ struct EventMemberImplObjTraits; * * This is the specialization for Ptr types. * - * \tparam T \explicit The class type. + * \tparam T \deduced The type of the underlying object. */ template struct EventMemberImplObjTraits > @@ -514,52 +401,10 @@ namespace ns3 { * 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 @@ -682,6 +527,7 @@ StaticCast (Ptr const&p) /** * Return a deep copy of a Ptr. * + * \tparam T \deduced The type of the underlying object. * \param [in] object The object Ptr to copy. * \returns The copy. */ diff --git a/src/core/model/simulator.cc b/src/core/model/simulator.cc index bac4c2100..b915a9a4b 100644 --- a/src/core/model/simulator.cc +++ b/src/core/model/simulator.cc @@ -254,30 +254,6 @@ Simulator::DoScheduleDestroy (EventImpl *impl) } -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 --git a/src/core/model/simulator.h b/src/core/model/simulator.h index 672afc1f0..f77822207 100644 --- a/src/core/model/simulator.h +++ b/src/core/model/simulator.h @@ -216,129 +216,13 @@ public: * 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); - - /** - * @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); + template + static EventId Schedule (Time const &delay, Ts&&... args); /** * Schedule an event to expire after @p delay. @@ -346,124 +230,17 @@ public: * for the current simulation time plus the @p delay passed as a * parameter. * + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. * When the event expires (when it becomes due to be run), the * function will be invoked with any supplied arguments. * @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); /** @} */ // Schedule events (in the same context) to run at a future time. /** @@ -477,257 +254,28 @@ public: * 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); - - /** - * @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); + template + static void ScheduleWithContext (uint32_t context, Time const &delay, Ts&&... args); /** * 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)); - - /** - * @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); - + template + static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(Us...), Ts&&... args); /** @} */ // Schedule events (in a different context) to run now or at a future time. /** @@ -739,235 +287,26 @@ public: * to expire "Now" are scheduled FIFO, after all normal events * 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 - * @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) + * Schedule an event to expire Now. All events scheduled to + * to expire "Now" are scheduled FIFO, after all normal events + * have expired. * - * 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 + * @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. */ - 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); /** @} */ // Schedule events (in the same context) to run now. @@ -976,239 +315,32 @@ public: */ /** @{ */ /** - * Schedule an event to expire when Simulator::Destroy is called. + * 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 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); /** @} */ // Schedule events to run when Simulator:Destroy() is called. @@ -1386,405 +518,57 @@ namespace ns3 { // it treats the in-class declaration as different from the // out of class definition, so makes two entries in the member list. Ugh -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) -{ - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); -} - -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); -} - -template -EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); -} - -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1) -{ - 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 +template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj) +Simulator::ScheduleNow (Ts&&... args) { - return DoScheduleNow (MakeEvent (mem_ptr, obj)); + return DoScheduleNow (MakeEvent (std::forward (args)...)); +} + +template +EventId +Simulator::ScheduleNow (void (*f)(Us...), Ts&&... args) +{ + return DoScheduleNow (MakeEvent (f, std::forward (args)...)); } -template +template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1) +Simulator::ScheduleDestroy (Ts&&... args) { - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1)); + return DoScheduleDestroy (MakeEvent (std::forward (args)...)); } -template +template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +Simulator::ScheduleDestroy (void (*f)(Us...), Ts&&... args) { - 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 --git a/src/core/model/timer.h b/src/core/model/timer.h index 4707e28ce..4371aad72 100644 --- a/src/core/model/timer.h +++ b/src/core/model/timer.h @@ -54,15 +54,15 @@ class TimerImpl; /** * \ingroup timer - * \brief A simple Timer class + * \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 @@ -123,6 +123,7 @@ public: ~Timer (); /** + * \tparam FN \deduced The type of the function. * \param [in] fn the function * * Store this function in this Timer for later use by Timer::Schedule. @@ -131,6 +132,8 @@ public: void SetFunction (FN fn); /** + * \tparam MEM_PTR \deduced The type of the class member function. + * \tparam OBJ_PTR \deduced The type of the class instance pointer. * \param [in] memPtr the member function pointer * \param [in] objPtr the pointer to object * @@ -142,62 +145,13 @@ public: /** - * \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 @@ -334,75 +288,16 @@ Timer::SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr) 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 --git a/src/core/model/traced-callback.h b/src/core/model/traced-callback.h index 787576fb4..b264953cc 100644 --- a/src/core/model/traced-callback.h +++ b/src/core/model/traced-callback.h @@ -36,29 +36,19 @@ namespace ns3 { * \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 @@ public: */ 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. @@ -224,16 +105,9 @@ private: /** * 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; }; @@ -247,48 +121,36 @@ private: 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 */) @@ -303,136 +165,26 @@ TracedCallback::DisconnectWithoutContext (const Callbac } } } -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 --git a/src/core/model/watchdog.h b/src/core/model/watchdog.h index 1f43d7934..09c36a8ea 100644 --- a/src/core/model/watchdog.h +++ b/src/core/model/watchdog.h @@ -75,6 +75,7 @@ public: /** * Set the function to execute when the timer expires. * + * \tparam FN \deduced The type of the function. * \param [in] fn The function * * Store this function in this Timer for later use by Timer::Schedule. @@ -101,71 +102,11 @@ public: */ /**@{*/ /** - * \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 +150,16 @@ Watchdog::SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr) 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