59 template <
typename... Args>
83template <
typename... Args>
101template <
typename U,
typename... Ts>
105 struct FnTimerImpl :
public TimerImplX<const std::remove_cvref_t<Ts>&...>
107 using FN = U (*)(Ts...);
109 FnTimerImpl(
void (*fn)(Ts...))
114 void SetArguments(
const std::remove_cvref_t<Ts>&... args)
override
116 m_arguments = std::tuple(args...);
122 [&,
this](Ts... args) { return Simulator::Schedule(delay, m_fn, args...); },
126 void Invoke()
override
128 std::apply([
this](Ts... args) { (m_fn)(args...); }, m_arguments);
132 std::tuple<std::remove_cvref_t<Ts>...> m_arguments;
133 }* function =
new FnTimerImpl(fn);
150template <
typename OBJ_PTR,
typename U,
typename V,
typename... Ts>
154 struct MemFnTimerImpl :
public TimerImplX<const std::remove_cvref_t<Ts>&...>
156 using MEM_PTR = U (V::*)(Ts...);
158 MemFnTimerImpl(MEM_PTR memPtr, OBJ_PTR objPtr)
164 void SetArguments(
const std::remove_cvref_t<Ts>&... args)
override
166 m_arguments = std::tuple(args...);
172 [&,
this](Ts... args) {
173 return Simulator::Schedule(delay, m_memPtr, m_objPtr, args...);
178 void Invoke()
override
180 std::apply([
this](Ts... args) { ((*m_objPtr).*m_memPtr)(args...); }, m_arguments);
185 std::tuple<std::remove_cvref_t<Ts>...> m_arguments;
186 }* function =
new MemFnTimerImpl(memPtr, objPtr);
197template <
typename... Args>
202 auto impl =
dynamic_cast<TimerImplBase*
>(
this);
205 NS_FATAL_ERROR(
"You tried to set Timer arguments incompatible with its function.");
208 impl->SetArguments(args...);
An identifier for simulation events.
Simulation virtual time values and global simulation resolution.
The timer implementation underlying Timer and Watchdog.
virtual void Invoke()=0
Invoke the expire function.
virtual EventId Schedule(const Time &delay)=0
Schedule the callback for a future time.
void SetArgs(Args... args)
Set the arguments to be used when invoking the expire function.
virtual ~TimerImpl()
Destructor.
NS_FATAL_x macro definitions.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
TimerImpl * MakeTimerImpl(U(fn)(Ts...))
Make a TimerImpl from a function pointer taking varying numbers of arguments.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Simulator declaration.
TimerImpl specialization class for varying numbers of arguments.
virtual void SetArguments(Args... args)=0
Bind the arguments to be used when the callback function is invoked.