# HG changeset patch # User Alexander Krotov # Date 1477051693 -10800 # Fri Oct 21 15:08:13 2016 +0300 # Node ID c181e508f9203989ba374165ebf7796294062412 # Parent 29bd2301b7983b359a5041d0823911e57761298e core: Make use of variadic templates diff -r 29bd2301b798 -r c181e508f920 src/core/model/callback.h --- a/src/core/model/callback.h Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/callback.h Fri Oct 21 15:08:13 2016 +0300 @@ -1485,85 +1485,13 @@ * Build Callbacks for class method members which take varying numbers of arguments * and potentially returning a value. */ -template -Callback MakeCallback (R (T::*memPtr)(void), OBJ objPtr) { - return Callback (objPtr, memPtr); +template +Callback MakeCallback (R (T::*memPtr)(Ts...), OBJ objPtr) { + return Callback (objPtr, memPtr); } -template -Callback MakeCallback (R (T::*memPtr)() const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8) const, OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9), OBJ objPtr) { - return Callback (objPtr, memPtr); -} -template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9) const, OBJ objPtr) { - return Callback (objPtr, memPtr); +template +Callback MakeCallback (R (T::*memPtr)(Ts...) const, OBJ objPtr) { + return Callback (objPtr, memPtr); } /**@}*/ @@ -1578,45 +1506,9 @@ * Build Callbacks for functions which take varying numbers of arguments * and potentially returning a value. */ -template -Callback MakeCallback (R (*fnPtr)()) { - return Callback (fnPtr, true, true); -} -template -Callback MakeCallback (R (*fnPtr)(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); +template +Callback MakeCallback (R (*fnPtr)(Ts...)) { + return Callback (fnPtr, true, true); } /**@}*/ @@ -1631,45 +1523,9 @@ * for varying number of template arguments, * and potentially returning a value. */ -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); -} -template -Callback MakeNullCallback (void) { - return Callback (); +template +Callback MakeNullCallback (void) { + return Callback (); } /**@}*/ diff -r 29bd2301b798 -r c181e508f920 src/core/model/object.h --- a/src/core/model/object.h Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/object.h Fri Oct 21 15:08:13 2016 +0300 @@ -527,142 +527,10 @@ * \tparam T \explicit The type of the derived object to construct. * \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 (args...)); } /**@}*/ diff -r 29bd2301b798 -r c181e508f920 src/core/model/ptr.h --- a/src/core/model/ptr.h Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/ptr.h Fri Oct 21 15:08:13 2016 +0300 @@ -216,132 +216,14 @@ */ /** @{ */ /** - * \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 argument. * \return A Ptr to the newly created \c T. */ template -Ptr Create (T1 a1); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \param [in] a6 The sixth constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - -/** - * \tparam T \explicit The type of class object to create. - * \tparam T1 \deduced The type of the first constructor argument. - * \tparam T2 \deduced The type of the second constructor argument. - * \tparam T3 \deduced The type of the third constructor argument. - * \tparam T4 \deduced The type of the fourth constructor argument. - * \tparam T5 \deduced The type of the fifth constructor argument. - * \tparam T6 \deduced The type of the sixth constructor argument. - * \tparam T7 \deduced The type of the seventh constructor argument. - * \param [in] a1 The first constructor argument. - * \param [in] a2 The second constructor argument. - * \param [in] a3 The third constructor argument. - * \param [in] a4 The fourth constructor argument. - * \param [in] a5 The fifth constructor argument. - * \param [in] a6 The sixth constructor argument. - * \param [in] a7 The seventh constructor argument. - * \return A Ptr to the newly created \c T. - */ -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7); + typename... Ts> +Ptr Create (Ts... args); /** @}*/ /** @@ -510,52 +392,10 @@ * friend non-member function implementations ************************************************/ -template -Ptr Create (void) +template +Ptr Create (Ts... args) { - return Ptr (new T (), false); -} - -template -Ptr Create (T1 a1) -{ - return Ptr (new T (a1), false); -} - -template -Ptr Create (T1 a1, T2 a2) -{ - return Ptr (new T (a1, a2), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3) -{ - return Ptr (new T (a1, a2, a3), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4) -{ - return Ptr (new T (a1, a2, a3, a4), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return Ptr (new T (a1, a2, a3, a4, a5), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - return Ptr (new T (a1, a2, a3, a4, a5, a6), false); -} - -template -Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) -{ - return Ptr (new T (a1, a2, a3, a4, a5, a6, a7), false); + return Ptr (new T (args...), false); } template diff -r 29bd2301b798 -r c181e508f920 src/core/model/simulator.cc --- a/src/core/model/simulator.cc Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/simulator.cc Fri Oct 21 15:08:13 2016 +0300 @@ -283,30 +283,6 @@ } -EventId -Simulator::Schedule (Time const &delay, void (*f)(void)) -{ - return DoSchedule (delay, MakeEvent (f)); -} - -void -Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void)) -{ - return ScheduleWithContext (context, delay, MakeEvent (f)); -} - -EventId -Simulator::ScheduleNow (void (*f)(void)) -{ - return DoScheduleNow (MakeEvent (f)); -} - -EventId -Simulator::ScheduleDestroy (void (*f)(void)) -{ - return DoScheduleDestroy (MakeEvent (f)); -} - void Simulator::Remove (const EventId &id) { diff -r 29bd2301b798 -r c181e508f920 src/core/model/simulator.h --- a/src/core/model/simulator.h Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/simulator.h Fri Oct 21 15:08:13 2016 +0300 @@ -191,7 +191,7 @@ */ NO_CONTEXT = 0xffffffff }; - + /** * @name Schedule events (in the same context) to run at a future time. */ @@ -202,113 +202,16 @@ * for the current simulation time plus the @p delay passed as a * parameter. * - * When the event expires (when it becomes due to be run), the - * input method will be invoked on the input object. - * - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. + * @tparam Ts @deduced Argument types. * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @param [in] args Arguments to pass to MakeEvent. * @returns The id for the scheduled event. */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj); + template + static EventId Schedule (Time const &delay, Ts&&... args); /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @tparam T5 @deduced Type of fifth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @param [in] a5 The fifth argument to pass to the invoked method - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** + * * Schedule an event to expire after @p delay. * This can be thought of as scheduling an event * for the current simulation time plus the @p delay passed as a @@ -316,106 +219,16 @@ * * When the event expires (when it becomes due to be run), the * function will be invoked with any supplied arguments. + * + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke + * @param [in] f The function to invoke. + * @param [in] args Arguments to pass to the invoked function. * @returns The id for the scheduled event. */ - static EventId Schedule (Time const &delay, void (*f)(void)); - - /** - * @see Schedule(const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke. - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1); - - /** - * @see Schedule(const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2); - - /** - * @see Schedule(const Time&,void(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @see Schedule(const Time&,(*)(void)) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see Schedule(const Time&,void(*)(void)) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam U5 @deduced Formal type of the fifth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @tparam T5 @deduced Actual type of the fifth argument. - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @param [in] a5 The fifth argument to pass to the function to invoke - * @returns The id for the scheduled event. - */ - template - static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - + template + static EventId Schedule (Time const &delay, void (*f)(Us...), Ts&&... args); /** @} */ /** @@ -429,430 +242,58 @@ * A context of 0xffffffff means no context is specified. * This method is thread-safe: it can be called from any thread. * - * @see Schedule(const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. + * @tparam Ts @deduced Argument types. * @param [in] context User-specified context parameter * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @param [in] args Arguments to pass to MakeEvent. */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj); + template + static void ScheduleWithContext (uint32_t context, Time const &delay, Ts&&... args); /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @tparam T5 @deduced Type of fifth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @param [in] a5 The fifth argument to pass to the invoked method - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** * Schedule an event with the given context. * A context of 0xffffffff means no context is specified. * This method is thread-safe: it can be called from any thread. * - * When the event expires (when it becomes due to be run), the - * function will be invoked with any supplied arguments. - * - * This method is thread-safe: it can be called from any thread. + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. * @param [in] context User-specified context parameter * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke + * @param [in] f The function to invoke. + * @param [in] args Arguments to pass to the invoked function. */ - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void)); + template + static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(Us...), Ts&&... args); + /** @} */ /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see ScheduleWithContext(uint32_t,const Time&,(*)()) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam U5 @deduced Formal type of the fifth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @tparam T5 @deduced Actual type of the fifth argument. - * @param [in] context User-specified context parameter - * @param [in] delay The relative expiration time of the event. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @param [in] a5 The fifth argument to pass to the function to invoke - */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** @} */ - - /** * @name Schedule events (in the same context) to run now. */ /** @{ */ /** * Schedule an event to expire Now. All events scheduled to * to expire "Now" are scheduled FIFO, after all normal events - * have expired. + * have expired. * - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @tparam 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 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 + * @copybrief ScheduleNow(Ts) + * + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. + * @param [in] args Arguments to pass to MakeEvent. * @return The EventId of the scheduled event. */ - template - static EventId 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); - /** - * @copybrief ScheduleNow(MEM,OBJ) - * - * When the event expires (when it becomes due to be run), the - * function will be invoked with any supplied arguments. - * @param [in] f The function to invoke - * @return The EventId of the scheduled event. - */ - static EventId ScheduleNow (void (*f)(void)); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1), T1 a1); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @see ScheduleNow(*) - * @tparam U1 @deduced Formal type of the first argument to the function. - * @tparam U2 @deduced Formal type of the second argument to the function. - * @tparam U3 @deduced Formal type of the third argument to the function. - * @tparam U4 @deduced Formal type of the fourth argument to the function. - * @tparam U5 @deduced Formal type of the fifth argument to the function. - * @tparam T1 @deduced Actual type of the first argument. - * @tparam T2 @deduced Actual type of the second argument. - * @tparam T3 @deduced Actual type of the third argument. - * @tparam T4 @deduced Actual type of the fourth argument. - * @tparam T5 @deduced Actual type of the fifth argument. - * @param [in] f The function to invoke - * @param [in] a1 The first argument to pass to the function to invoke - * @param [in] a2 The second argument to pass to the function to invoke - * @param [in] a3 The third argument to pass to the function to invoke - * @param [in] a4 The fourth argument to pass to the function to invoke - * @param [in] a5 The fifth argument to pass to the function to invoke - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - + template + static EventId ScheduleNow (void (*f)(Us...), Ts&&... args); /** @} */ /** @@ -860,209 +301,33 @@ */ /** @{ */ /** - * Schedule an event to expire when Simulator::Destroy is called. - * All events scheduled to expire at "Destroy" time are scheduled FIFO, - * after all normal events have expired and only when + * Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called. + * All events scheduled to expire at "Destroy" time are scheduled FIFO, + * after all normal events have expired and only when * Simulator::Destroy is invoked. * - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. + * @param [in] args Arguments to pass to MakeEvent. * @return The EventId of the scheduled event. */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj); + template + static EventId ScheduleDestroy (Ts&&... args); /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method + * Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called. + * All events scheduled to expire at "Destroy" time are scheduled FIFO, + * after all normal events have expired and only when + * Simulator::Destroy is invoked. + * + * @tparam Us @deduced Formal function argument types. + * @tparam Ts @deduced Actual function argument types. + * @param [in] f The function to invoke. + * @param [in] args Arguments to pass to MakeEvent. * @return The EventId of the scheduled event. */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4); - /** - * @see ScheduleDestroy(MEM,OBJ) - * @tparam MEM @deduced Class method function signature type. - * @tparam OBJ @deduced Class type of the object. - * @tparam T1 @deduced Type of first argument. - * @tparam T2 @deduced Type of second argument. - * @tparam T3 @deduced Type of third argument. - * @tparam T4 @deduced Type of fourth argument. - * @tparam T5 @deduced Type of fifth argument. - * @param [in] mem_ptr Member method pointer to invoke - * @param [in] obj The object on which to invoke the member method - * @param [in] a1 The first argument to pass to the invoked method - * @param [in] a2 The second argument to pass to the invoked method - * @param [in] a3 The third argument to pass to the invoked method - * @param [in] a4 The fourth argument to pass to the invoked method - * @param [in] a5 The fifth argument to pass to the invoked method - * @return The EventId of the scheduled event. - */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** - * @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); - + template + static EventId ScheduleDestroy (void (*f)(Us...), Ts&&... args); /** @} */ /** @@ -1234,346 +499,56 @@ namespace ns3 { -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj) +template +EventId Simulator::Schedule (Time const &delay, Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj)); + return DoSchedule (delay, MakeEvent (std::forward(args)...)); } - -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1) +template +EventId Simulator::Schedule (Time const &delay, void (*f)(Us...), Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1)); + return DoSchedule (delay, MakeEvent (f, std::forward(args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2)); + return ScheduleWithContext (context, delay, MakeEvent (std::forward(args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(Us...), Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3)); + return ScheduleWithContext (context, delay, MakeEvent (f, std::forward(args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +template +EventId +Simulator::ScheduleNow (Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); + return DoScheduleNow (MakeEvent (std::forward(args)...)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +template +EventId +Simulator::ScheduleNow (void (*f)(Us...), Ts&&... args) { - return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); + return DoScheduleNow (MakeEvent (f, std::forward(args)...)); } -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1) +template +EventId +Simulator::ScheduleDestroy (Ts&&... args) { - return DoSchedule (delay, MakeEvent (f, a1)); + return DoScheduleDestroy (MakeEvent (std::forward(args)...)); } -template -EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2) +template +EventId +Simulator::ScheduleDestroy (void (*f)(Us...), Ts&&... args) { - 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 -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 &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 -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj)); -} - - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); -} - -template -EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); -} - -template -EventId -Simulator::ScheduleNow (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::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 (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)); + return DoScheduleDestroy (MakeEvent (f, std::forward(args)...)); } } // namespace ns3 diff -r 29bd2301b798 -r c181e508f920 src/core/model/timer.h --- a/src/core/model/timer.h Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/timer.h Fri Oct 21 15:08:13 2016 +0300 @@ -134,62 +134,12 @@ /** - * \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 + * \param [in] args arguments * * Store these arguments in this Timer for later use by Timer::Schedule. */ - template - void SetArguments (T1 a1, T2 a2); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - * \param [in] a6 the sixth argument - * - * Store these arguments in this Timer for later use by Timer::Schedule. - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); + template + void SetArguments (Ts... args); /** * \param [in] delay The delay @@ -319,75 +269,16 @@ m_impl = MakeTimerImpl (memPtr, objPtr); } -template +template void -Timer::SetArguments (T1 a1) +Timer::SetArguments (Ts... args) { if (m_impl == 0) { NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); return; } - m_impl->SetArgs (a1); -} -template -void -Timer::SetArguments (T1 a1, T2 a2) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5); -} - -template -void -Timer::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5, a6); + m_impl->SetArgs (args...); } } // namespace ns3 diff -r 29bd2301b798 -r c181e508f920 src/core/model/traced-callback.h --- a/src/core/model/traced-callback.h Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/traced-callback.h Fri Oct 21 15:08:13 2016 +0300 @@ -43,22 +43,12 @@ * 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 Type of the fuctor arguments. */ -template +template class TracedCallback { public: @@ -94,120 +84,12 @@ */ 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. - */ - /**@{*/ - /** 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. + * \brief Functor which invokes the chain of Callbacks. + * \tparam Ts \deduced Type of the functor arguments. * \param [in] a1 The first argument to the functor. * \param [in] a2 The second argument to the functor. */ - void operator() (T1 a1, T2 a2) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - * \param [in] a6 The sixth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \tparam T7 \deduced Type of the seventh argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - * \param [in] a6 The sixth argument to the functor. - * \param [in] a7 The seventh argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) const; - /** - * \copybrief operator()() - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \tparam T7 \deduced Type of the seventh argument to the functor. - * \tparam T8 \deduced Type of the eighth argument to the functor. - * \param [in] a1 The first argument to the functor. - * \param [in] a2 The second argument to the functor. - * \param [in] a3 The third argument to the functor. - * \param [in] a4 The fourth argument to the functor. - * \param [in] a5 The fifth argument to the functor. - * \param [in] a6 The sixth argument to the functor. - * \param [in] a7 The seventh argument to the functor. - * \param [in] a8 The eighth argument to the functor. - */ - void operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8) const; - /**@}*/ + void operator() (Ts... args) const; /** * TracedCallback signature for POD. @@ -225,16 +107,9 @@ /** * Container type for holding the chain of Callbacks. * - * \tparam T1 \deduced Type of the first argument to the functor. - * \tparam T2 \deduced Type of the second argument to the functor. - * \tparam T3 \deduced Type of the third argument to the functor. - * \tparam T4 \deduced Type of the fourth argument to the functor. - * \tparam T5 \deduced Type of the fifth argument to the functor. - * \tparam T6 \deduced Type of the sixth argument to the functor. - * \tparam T7 \deduced Type of the seventh argument to the functor. - * \tparam T8 \deduced Type of the eighth argument to the functor. + * \tparam Ts \deduced Types of the functor arguments. */ - typedef std::list > CallbackList; + typedef std::list > CallbackList; /** The chain of Callbacks. */ CallbackList m_callbackList; }; @@ -248,45 +123,33 @@ namespace ns3 { -template -TracedCallback::TracedCallback () +template +TracedCallback::TracedCallback () : m_callbackList () { } -template +template void -TracedCallback::ConnectWithoutContext (const CallbackBase & callback) +TracedCallback::ConnectWithoutContext (const CallbackBase & callback) { - Callback cb; + Callback cb; if (!cb.Assign (callback)) NS_FATAL_ERROR_NO_MSG(); m_callbackList.push_back (cb); } -template +template void -TracedCallback::Connect (const CallbackBase & callback, std::string path) +TracedCallback::Connect (const CallbackBase & callback, std::string path) { - Callback cb; + Callback cb; if (!cb.Assign (callback)) NS_FATAL_ERROR ("when connecting to " << path); - Callback realCb = cb.Bind (path); + Callback realCb = cb.Bind (path); m_callbackList.push_back (realCb); } -template +template void -TracedCallback::DisconnectWithoutContext (const CallbackBase & callback) +TracedCallback::DisconnectWithoutContext (const CallbackBase & callback) { for (typename CallbackList::iterator i = m_callbackList.begin (); i != m_callbackList.end (); /* empty */) @@ -301,134 +164,24 @@ } } } -template +template void -TracedCallback::Disconnect (const CallbackBase & callback, std::string path) +TracedCallback::Disconnect (const CallbackBase & callback, std::string path) { - Callback cb; + Callback cb; if (!cb.Assign (callback)) NS_FATAL_ERROR ("when disconnecting from " << path); - Callback realCb = cb.Bind (path); + Callback realCb = cb.Bind (path); DisconnectWithoutContext (realCb); } -template +template void -TracedCallback::operator() (void) const +TracedCallback::operator() (Ts... args) const { for (typename CallbackList::const_iterator i = m_callbackList.begin (); i != m_callbackList.end (); i++) { - (*i)(); - } -} -template -void -TracedCallback::operator() (T1 a1) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5, a6); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5, a6, a7); - } -} -template -void -TracedCallback::operator() (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8) const -{ - for (typename CallbackList::const_iterator i = m_callbackList.begin (); - i != m_callbackList.end (); i++) - { - (*i)(a1, a2, a3, a4, a5, a6, a7, a8); + (*i)(args...); } } diff -r 29bd2301b798 -r c181e508f920 src/core/model/watchdog.h --- a/src/core/model/watchdog.h Thu Oct 20 12:06:45 2016 +0300 +++ b/src/core/model/watchdog.h Fri Oct 21 15:08:13 2016 +0300 @@ -101,71 +101,11 @@ */ /**@{*/ /** - * \tparam T1 \deduced Type of the first argument. - * \param [in] a1 The first argument + * \tparam Ts \deduced Argument types + * \param [in] args arguments */ - template - void SetArguments (T1 a1); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - */ - template - void SetArguments (T1 a1, T2 a2); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \tparam T4 \deduced Type of the fourth argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \tparam T4 \deduced Type of the fourth argument. - * \tparam T5 \deduced Type of the fifth argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** - * \tparam T1 \deduced Type of the first argument. - * \tparam T2 \deduced Type of the second argument. - * \tparam T3 \deduced Type of the third argument. - * \tparam T4 \deduced Type of the fourth argument. - * \tparam T5 \deduced Type of the fifth argument. - * \tparam T6 \deduced Type of the sixth argument. - * \param [in] a1 the first argument - * \param [in] a2 the second argument - * \param [in] a3 the third argument - * \param [in] a4 the fourth argument - * \param [in] a5 the fifth argument - * \param [in] a6 the sixth argument - */ - template - void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); + template + void SetArguments (Ts&&... args); /**@}*/ private: @@ -209,75 +149,16 @@ m_impl = MakeTimerImpl (memPtr, objPtr); } -template +template void -Watchdog::SetArguments (T1 a1) +Watchdog::SetArguments (Ts&&... args) { if (m_impl == 0) { NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); return; } - m_impl->SetArgs (a1); -} -template -void -Watchdog::SetArguments (T1 a1, T2 a2) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5); -} - -template -void -Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function."); - return; - } - m_impl->SetArgs (a1, a2, a3, a4, a5, a6); + m_impl->SetArgs (std::forward(args)...); } } // namespace ns3