diff --git a/src/simulator/timer.h b/src/simulator/timer.h index 6c97ca5c0..d282d8bd2 100644 --- a/src/simulator/timer.h +++ b/src/simulator/timer.h @@ -128,6 +128,39 @@ public: */ template void SetArguments (T1 a1, T2 a2, T3 a3); + /** + * \param a1 the first argument + * \param a2 the second argument + * \param a3 the third argument + * \param 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 a1 the first argument + * \param a2 the second argument + * \param a3 the third argument + * \param a4 the fourth argument + * \param 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 a1 the first argument + * \param a2 the second argument + * \param a3 the third argument + * \param a4 the fourth argument + * \param a5 the fifth argument + * \param 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); /** * \param delay the delay @@ -169,10 +202,27 @@ private: void DoSetFunction (IntToType<0>, FN fn); template void DoSetFunction (IntToType<1>, FN fn); + template + void DoSetFunction (IntToType<2>, FN fn); + template + void DoSetFunction (IntToType<3>, FN fn); + template + void DoSetFunction (IntToType<4>, FN fn); + template + void DoSetFunction (IntToType<5>, FN fn); + template void DoSetFunction (IntToType<0>, MEM_PTR memPtr, OBJ_PTR objPtr); template void DoSetFunction (IntToType<1>, MEM_PTR memPtr, OBJ_PTR objPtr); + template + void DoSetFunction (IntToType<2>, MEM_PTR memPtr, OBJ_PTR objPtr); + template + void DoSetFunction (IntToType<3>, MEM_PTR memPtr, OBJ_PTR objPtr); + template + void DoSetFunction (IntToType<4>, MEM_PTR memPtr, OBJ_PTR objPtr); + template + void DoSetFunction (IntToType<5>, MEM_PTR memPtr, OBJ_PTR objPtr); int m_flags; Time m_delay; @@ -212,6 +262,31 @@ struct TimerImplOne : public TimerImpl { virtual void SetArguments (T1 a1) = 0; }; +template +struct TimerImplTwo : public TimerImpl +{ + virtual void SetArguments (T1 a1,T2 a2) = 0; +}; +template +struct TimerImplThree : public TimerImpl +{ + virtual void SetArguments (T1 a1,T2 a2,T3 a3) = 0; +}; +template +struct TimerImplFour : public TimerImpl +{ + virtual void SetArguments (T1 a1,T2 a2,T3 a3, T4 a4) = 0; +}; +template +struct TimerImplFive : public TimerImpl +{ + virtual void SetArguments (T1 a1,T2 a2,T3 a3, T4 a4, T5 a5) = 0; +}; +template +struct TimerImplSix : public TimerImpl +{ + virtual void SetArguments (T1 a1,T2 a2,T3 a3, T4 a4, T5 a5, T6 a6) = 0; +}; template @@ -264,27 +339,6 @@ Timer::DoSetFunction (IntToType<1>, FN fn) m_impl = function; } - -template -void -Timer::SetArguments (T1 a1) -{ - if (m_impl == 0) - { - NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); - return; - } - struct TimerImplOne::ParameterType> *impl = - dynamic_cast::ParameterType> *> (m_impl); - if (impl == 0) - { - NS_FATAL_ERROR ("You tried to set Timer arguments incompatible with its function."); - return; - } - impl->SetArguments (a1); -} - - template void Timer::SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr) @@ -337,6 +391,150 @@ Timer::DoSetFunction (IntToType<1>, MEM_PTR memPtr, OBJ_PTR objPtr) m_impl = function; } + +template +void +Timer::SetArguments (T1 a1) +{ + if (m_impl == 0) + { + NS_FATAL_ERROR ("You cannot set the arguments of a Timer before setting its function."); + return; + } + typedef struct TimerImplOne< + typename TimerTraits::ParameterType + > TimerImplBase; + TimerImplBase *impl = dynamic_cast (m_impl); + if (impl == 0) + { + NS_FATAL_ERROR ("You tried to set Timer arguments incompatible with its function."); + return; + } + impl->SetArguments (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; + } + typedef struct TimerImplTwo< + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType + > TimerImplBase; + TimerImplBase *impl = dynamic_cast (m_impl); + if (impl == 0) + { + NS_FATAL_ERROR ("You tried to set Timer arguments incompatible with its function."); + return; + } + impl->SetArguments (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; + } + typedef struct TimerImplThree< + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType + > TimerImplBase; + TimerImplBase *impl = dynamic_cast (m_impl); + if (impl == 0) + { + NS_FATAL_ERROR ("You tried to set Timer arguments incompatible with its function."); + return; + } + impl->SetArguments (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; + } + typedef struct TimerImplFour< + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType + > TimerImplBase; + TimerImplBase *impl = dynamic_cast (m_impl); + if (impl == 0) + { + NS_FATAL_ERROR ("You tried to set Timer arguments incompatible with its function."); + return; + } + impl->SetArguments (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; + } + typedef struct TimerImplFive< + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType + > TimerImplBase; + TimerImplBase *impl = dynamic_cast (m_impl); + if (impl == 0) + { + NS_FATAL_ERROR ("You tried to set Timer arguments incompatible with its function."); + return; + } + impl->SetArguments (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; + } + typedef struct TimerImplSix< + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType, + typename TimerTraits::ParameterType + > TimerImplBase; + TimerImplBase *impl = dynamic_cast (m_impl); + if (impl == 0) + { + NS_FATAL_ERROR ("You tried to set Timer arguments incompatible with its function."); + return; + } + impl->SetArguments (a1, a2, a3, a4, a5, a6); +} + + + } // namespace ns3 #endif /* TIMER_H */