equal
deleted
inserted
replaced
1 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ |
|
2 #include "ns3/event.h" |
|
3 #include "ns3/event.tcc" |
|
4 #include <iostream> |
|
5 |
|
6 using namespace ns3; |
|
7 |
|
8 class MyModel { |
|
9 public: |
|
10 void deal_with_event (double event_value); |
|
11 }; |
|
12 |
|
13 void |
|
14 MyModel::deal_with_event (double value) |
|
15 { |
|
16 std::cout << "Member method received event." << std::endl; |
|
17 } |
|
18 |
|
19 static void |
|
20 random_function (void) |
|
21 { |
|
22 std::cout << "Function received event." << std::endl; |
|
23 } |
|
24 |
|
25 |
|
26 int main (int argc, char *argv[]) |
|
27 { |
|
28 Event ev; |
|
29 // create event to forward to random_function |
|
30 ev = make_event (&random_function); |
|
31 // set cancel bit to on |
|
32 ev.cancel (); |
|
33 // try to invoke the random_function through the event. |
|
34 // This does nothing since cancel bit is on. |
|
35 ev (); |
|
36 MyModel model; |
|
37 // create event to forward to MyModel::deal_with_event |
|
38 // on the class instance "model". |
|
39 ev = make_event (&MyModel::deal_with_event, &model, 10.0); |
|
40 // invoke member method through the event. |
|
41 ev (); |
|
42 } |
|