|
|
| 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 |
|
| 3 |
#ifndef MAKE_FUNCTIONAL_EVENT_H |
| 4 |
#define MAKE_FUNCTIONAL_EVENT_H |
| 5 |
|
| 6 |
#include <ns3/event-impl.h> |
| 7 |
|
| 8 |
namespace ns3 { |
| 9 |
|
| 10 |
template <typename T> |
| 11 |
EventImpl * MakeFunctionalEvent (T function) |
| 12 |
{ |
| 13 |
class EventMemberImplFunctional : public EventImpl |
| 14 |
{ |
| 15 |
public: |
| 16 |
EventMemberImplFunctional (T function) |
| 17 |
: m_function (function) |
| 18 |
{ |
| 19 |
} |
| 20 |
virtual ~EventMemberImplFunctional () |
| 21 |
{ |
| 22 |
} |
| 23 |
private: |
| 24 |
virtual void Notify (void) |
| 25 |
{ |
| 26 |
m_function(); |
| 27 |
} |
| 28 |
T m_function; |
| 29 |
} *ev = new EventMemberImplFunctional (function); |
| 30 |
return ev; |
| 31 |
} |
| 32 |
|
| 33 |
} // namespace ns3 |
| 34 |
|
| 35 |
#endif /* MAKE_FUNCTIONAL_EVENT_H */ |