diff --git a/src/core/model/make-event.h b/src/core/model/make-event.h index 1d8a61cf7..766f7d7c8 100644 --- a/src/core/model/make-event.h +++ b/src/core/model/make-event.h @@ -144,6 +144,32 @@ template EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + +/** + * \copybrief MakeEvent(MEM,OBJ) + * \tparam MEM The class method function signature. + * \tparam OBJ The class type holding the method. + * \tparam T1 Type of the first argument to the underlying function. + * \tparam T2 Type of the second argument to the underlying function. + * \tparam T3 Type of the third argument to the underlying function. + * \tparam T4 Type of the fourth argument to the underlying function. + * \tparam T5 Type of the fifth argument to the underlying function. + * \tparam T6 Type of the sixth argument to the underlying function. + * \param mem_ptr Class method member function pointer + * \param obj Class instance. + * \param a1 First argument value to be bound to the underlying function. + * \param a2 Second argument value to be bound to the underlying function. + * \param a3 Third argument value to be bound to the underlying function. + * \param a4 Fourth argument value to be bound to the underlying function. + * \param a5 Fifth argument value to be bound to the underlying function. + * \param a6 Sixth argument value to be bound to the underlying function. + * \returns The constructed EventImpl. + */ +template +EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); + /**@}*/ /** @@ -253,6 +279,33 @@ EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); template EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + +/** + * \copybrief MakeEvent(void(*f)(void)) + * \tparam U1 Formal type of the first argument to the function. + * \tparam U2 Formal type of the second argument to the function. + * \tparam U3 Formal type of the third argument to the function. + * \tparam U4 Formal type of the fourth argument to the function. + * \tparam U5 Formal type of the fifth argument to the function. + * \tparam U6 Formal type of the sixth argument to the function. + * \tparam T1 Actual type of the first argument to the function. + * \tparam T2 Actual type of the second argument to the function. + * \tparam T3 Actual type of the third argument to the function. + * \tparam T4 Actual type of the fourth argument to the function. + * \tparam T5 Actual type of the fifth argument to the function. + * \tparam T6 Actual type of the sixth argument to the function. + * \param f The function pointer. + * \param a1 First argument to be bound to the function. + * \param a2 Second argument to be bound to the function. + * \param a3 Third argument to be bound to the function. + * \param a4 Fourth argument to be bound to the function. + * \param a5 Fifth argument to be bound to the function. + * \param a6 Sixth argument to be bound to the function. + * \returns The constructed EventImpl. + */ +template +EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); /**@}*/ } // namespace ns3 @@ -500,6 +553,47 @@ private: return ev; } +template +EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +{ + // six argument version + class EventMemberImpl6 : public EventImpl + { +public: + EventMemberImpl6 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) + : m_obj (obj), + m_function (function), + m_a1 (a1), + m_a2 (a2), + m_a3 (a3), + m_a4 (a4), + m_a5 (a5), + m_a6 (a6) + { + } +protected: + virtual ~EventMemberImpl6 () + { + } +private: + virtual void Notify (void) + { + (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5, m_a6); + } + OBJ m_obj; + MEM m_function; + typename TypeTraits::ReferencedType m_a1; + typename TypeTraits::ReferencedType m_a2; + typename TypeTraits::ReferencedType m_a3; + typename TypeTraits::ReferencedType m_a4; + typename TypeTraits::ReferencedType m_a5; + typename TypeTraits::ReferencedType m_a6; + } *ev = new EventMemberImpl6 (obj, mem_ptr, a1, a2, a3, a4, a5, a6); + return ev; +} + template EventImpl * MakeEvent (void (*f)(U1), T1 a1) { @@ -668,6 +762,46 @@ private: return ev; } +template +EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +{ + // six arg version + class EventFunctionImpl6 : public EventImpl + { +public: + typedef void (*F)(U1,U2,U3,U4,U5,U6); + + EventFunctionImpl6 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) + : m_function (function), + m_a1 (a1), + m_a2 (a2), + m_a3 (a3), + m_a4 (a4), + m_a5 (a5), + m_a6 (a6) + { + } +protected: + virtual ~EventFunctionImpl6 () + { + } +private: + virtual void Notify (void) + { + (*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5, m_a6); + } + F m_function; + typename TypeTraits::ReferencedType m_a1; + typename TypeTraits::ReferencedType m_a2; + typename TypeTraits::ReferencedType m_a3; + typename TypeTraits::ReferencedType m_a4; + typename TypeTraits::ReferencedType m_a5; + typename TypeTraits::ReferencedType m_a6; + } *ev = new EventFunctionImpl6 (f, a1, a2, a3, a4, a5, a6); + return ev; +} + } // namespace ns3 #endif /* MAKE_EVENT_H */ diff --git a/src/core/model/simulator.h b/src/core/model/simulator.h index fa94cdc72..efe2cd33d 100644 --- a/src/core/model/simulator.h +++ b/src/core/model/simulator.h @@ -308,6 +308,24 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + + /** + * @param time the relative expiration time of the event. + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + * @param a5 the fifth argument to pass to the invoked method + * @param a6 the sixth argument to pass to the invoked method + * @returns an id for the scheduled event. + */ + template + static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); + /** * Schedule an event to expire after @p delay. * This can be thought of as scheduling an event @@ -416,6 +434,22 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> 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); + + /** @} */ /** @@ -533,6 +567,26 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + + /** + * This method is thread-safe: it can be called from any thread. + * + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + * @param a5 the fifth argument to pass to the invoked method + * @param a6 the sixth argument to pass to the invoked method + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); + /** * Schedule an event with the given context. * A context of 0xffffffff means no context is specified. @@ -643,6 +697,23 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> 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); + /** @} */ /** @@ -753,6 +824,23 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> 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) * @@ -853,6 +941,20 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> 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); + /** @} */ /** @@ -964,6 +1066,23 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> 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 @@ -1063,6 +1182,20 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> 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); + /** @} */ /** @@ -1277,6 +1410,14 @@ EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, 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) @@ -1312,7 +1453,12 @@ EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1 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 @@ -1358,6 +1504,14 @@ void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM me 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) @@ -1393,7 +1547,12 @@ void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void ( 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 @@ -1445,6 +1604,15 @@ Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, 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 @@ -1485,6 +1653,13 @@ Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T 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 @@ -1536,6 +1711,15 @@ Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, 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 @@ -1576,6 +1760,14 @@ Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a 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)); +} + } // namespace ns3 #endif /* SIMULATOR_H */