A Discrete-Event Network Simulator
API
simulator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef SIMULATOR_H
22 #define SIMULATOR_H
23 
24 #include "event-id.h"
25 #include "event-impl.h"
26 #include "make-event.h"
27 #include "nstime.h"
28 
29 #include "object-factory.h"
30 
31 #include <stdint.h>
32 #include <string>
33 
40 namespace ns3 {
41 
42 class SimulatorImpl;
43 class Scheduler;
44 
68 class Simulator
69 {
70 public:
83  static void SetImplementation (Ptr<SimulatorImpl> impl);
84 
103 
112  static void SetScheduler (ObjectFactory schedulerFactory);
113 
123  static void Destroy (void);
124 
134  static bool IsFinished (void);
135 
146  static void Run (void);
147 
156  static void Stop (void);
157 
167  static void Stop (const Time &delay);
168 
185  static uint32_t GetContext (void);
186 
194  enum : uint32_t
195  {
199  NO_CONTEXT = 0xffffffff
200  };
201 
206  static uint64_t GetEventCount (void);
207 
208 
229  template <typename MEM, typename OBJ>
230  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj);
231 
243  template <typename MEM, typename OBJ, typename T1>
244  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
245 
259  template <typename MEM, typename OBJ, typename T1, typename T2>
260  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
261 
277  template <typename MEM, typename OBJ,
278  typename T1, typename T2, typename T3>
279  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
280 
298  template <typename MEM, typename OBJ,
299  typename T1, typename T2, typename T3, typename T4>
300  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
301 
321  template <typename MEM, typename OBJ,
322  typename T1, typename T2, typename T3, typename T4, typename T5>
323  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
324  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
325 
338  template <typename MEM, typename OBJ,
339  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
340  static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj,
341  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
342 
355  static EventId Schedule (Time const &delay, void (*f)(void));
356 
366  template <typename U1, typename T1>
367  static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1);
368 
381  template <typename U1, typename U2,
382  typename T1, typename T2>
383  static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
384 
400  template <typename U1, typename U2, typename U3,
401  typename T1, typename T2, typename T3>
402  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
403 
422  template <typename U1, typename U2, typename U3, typename U4,
423  typename T1, typename T2, typename T3, typename T4>
424  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
425 
447  template <typename U1, typename U2, typename U3, typename U4, typename U5,
448  typename T1, typename T2, typename T3, typename T4, typename T5>
449  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
450 
462  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
463  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
464  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);
465 
466  // Schedule events (in the same context) to run at a future time.
468 
488  template <typename MEM, typename OBJ>
489  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj);
490 
502  template <typename MEM, typename OBJ, typename T1>
503  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
504 
518  template <typename MEM, typename OBJ, typename T1, typename T2>
519  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
520 
536  template <typename MEM, typename OBJ,
537  typename T1, typename T2, typename T3>
538  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
539 
557  template <typename MEM, typename OBJ,
558  typename T1, typename T2, typename T3, typename T4>
559  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
560 
580  template <typename MEM, typename OBJ,
581  typename T1, typename T2, typename T3, typename T4, typename T5>
582  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
583  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
584 
599  template <typename MEM, typename OBJ,
600  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
601  static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
602  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
603 
617  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void));
618 
628  template <typename U1,
629  typename T1>
630  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1);
631 
644  template <typename U1, typename U2,
645  typename T1, typename T2>
646  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
647 
663  template <typename U1, typename U2, typename U3,
664  typename T1, typename T2, typename T3>
665  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
666 
685  template <typename U1, typename U2, typename U3, typename U4,
686  typename T1, typename T2, typename T3, typename T4>
687  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
688 
710  template <typename U1, typename U2, typename U3, typename U4, typename U5,
711  typename T1, typename T2, typename T3, typename T4, typename T5>
712  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);
713 
727  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
728  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
729  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);
730  // Schedule events (in a different context) to run now or at a future time.
732 
748  template <typename MEM, typename OBJ>
749  static EventId ScheduleNow (MEM mem_ptr, OBJ obj);
750 
761  template <typename MEM, typename OBJ,
762  typename T1>
763  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1);
764 
777  template <typename MEM, typename OBJ,
778  typename T1, typename T2>
779  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
780 
795  template <typename MEM, typename OBJ,
796  typename T1, typename T2, typename T3>
797  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
798 
815  template <typename MEM, typename OBJ,
816  typename T1, typename T2, typename T3, typename T4>
817  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
818  T1 a1, T2 a2, T3 a3, T4 a4);
837  template <typename MEM, typename OBJ,
838  typename T1, typename T2, typename T3, typename T4, typename T5>
839  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
840  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
841 
853  template <typename MEM, typename OBJ,
854  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
855  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
856  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
857 
866  static EventId ScheduleNow (void (*f)(void));
867 
876  template <typename U1,
877  typename T1>
878  static EventId ScheduleNow (void (*f)(U1), T1 a1);
879 
891  template <typename U1, typename U2,
892  typename T1, typename T2>
893  static EventId ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2);
894 
909  template <typename U1, typename U2, typename U3,
910  typename T1, typename T2, typename T3>
911  static EventId ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
912 
930  template <typename U1, typename U2, typename U3, typename U4,
931  typename T1, typename T2, typename T3, typename T4>
932  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
933 
954  template <typename U1, typename U2, typename U3, typename U4, typename U5,
955  typename T1, typename T2, typename T3, typename T4, typename T5>
956  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
957 
968  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
969  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
970  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
971  // Schedule events (in the same context) to run now.
973 
990  template <typename MEM, typename OBJ>
991  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj);
992 
1003  template <typename MEM, typename OBJ,
1004  typename T1>
1005  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1);
1006 
1019  template <typename MEM, typename OBJ,
1020  typename T1, typename T2>
1021  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
1022 
1037  template <typename MEM, typename OBJ,
1038  typename T1, typename T2, typename T3>
1039  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
1040 
1057  template <typename MEM, typename OBJ,
1058  typename T1, typename T2, typename T3, typename T4>
1059  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1060  T1 a1, T2 a2, T3 a3, T4 a4);
1079  template <typename MEM, typename OBJ,
1080  typename T1, typename T2, typename T3, typename T4, typename T5>
1081  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1082  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1083 
1095  template <typename MEM, typename OBJ,
1096  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1097  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1098  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
1099 
1107  static EventId ScheduleDestroy (void (*f)(void));
1108 
1117  template <typename U1,
1118  typename T1>
1119  static EventId ScheduleDestroy (void (*f)(U1), T1 a1);
1120 
1132  template <typename U1, typename U2,
1133  typename T1, typename T2>
1134  static EventId ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2);
1135 
1150  template <typename U1, typename U2, typename U3,
1151  typename T1, typename T2, typename T3>
1152  static EventId ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
1153 
1171  template <typename U1, typename U2, typename U3, typename U4,
1172  typename T1, typename T2, typename T3, typename T4>
1173  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
1174 
1195  template <typename U1, typename U2, typename U3, typename U4, typename U5,
1196  typename T1, typename T2, typename T3, typename T4, typename T5>
1197  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1198 
1209  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1210  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1211  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
1212  // Schedule events to run when Simulator:Destroy() is called.
1214 
1227  static void Remove (const EventId &id);
1228 
1242  static void Cancel (const EventId &id);
1243 
1258  static bool IsExpired (const EventId &id);
1259 
1265  static Time Now (void);
1266 
1275  static Time GetDelayLeft (const EventId &id);
1276 
1285  static Time GetMaximumSimulationTime (void);
1286 
1294  static EventId Schedule (const Time &delay, const Ptr<EventImpl> &event);
1295 
1305  static void ScheduleWithContext (uint32_t context, const Time &delay, EventImpl *event);
1306 
1314  static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
1315 
1322  static EventId ScheduleNow (const Ptr<EventImpl> &event);
1323 
1331  static uint32_t GetSystemId (void);
1332 
1333 private:
1335  Simulator ();
1337  ~Simulator ();
1338 
1345  static EventId DoSchedule (Time const &delay, EventImpl *event);
1351  static EventId DoScheduleNow (EventImpl *event);
1357  static EventId DoScheduleDestroy (EventImpl *event);
1358 
1359 }; // class Simulator
1360 
1374 Time Now (void);
1375 
1376 } // namespace ns3
1377 
1378 
1379 /********************************************************************
1380  * Implementation of the templates declared above.
1381  ********************************************************************/
1382 
1383 namespace ns3 {
1384 
1385 // Doxygen has trouble with static template functions in a class:
1386 // it treats the in-class declaration as different from the
1387 // out of class definition, so makes two entries in the member list. Ugh
1388 
1389 template <typename MEM, typename OBJ>
1390 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj)
1391 {
1392  return DoSchedule (delay, MakeEvent (mem_ptr, obj));
1393 }
1394 
1395 
1396 template <typename MEM, typename OBJ,
1397  typename T1>
1398 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1399 {
1400  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1));
1401 }
1402 
1403 template <typename MEM, typename OBJ,
1404  typename T1, typename T2>
1405 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1406 {
1407  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2));
1408 }
1409 
1410 template <typename MEM, typename OBJ,
1411  typename T1, typename T2, typename T3>
1412 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1413 {
1414  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1415 }
1416 
1417 template <typename MEM, typename OBJ,
1418  typename T1, typename T2, typename T3, typename T4>
1419 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1420 {
1421  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1422 }
1423 
1424 template <typename MEM, typename OBJ,
1425  typename T1, typename T2, typename T3, typename T4, typename T5>
1426 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
1427  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1428 {
1429  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1430 }
1431 
1432 template <typename MEM, typename OBJ,
1433  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1434 EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj,
1435  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1436 {
1437  return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1438 }
1439 
1440 template <typename U1,
1441  typename T1>
1442 EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1)
1443 {
1444  return DoSchedule (delay, MakeEvent (f, a1));
1445 }
1446 
1447 template <typename U1, typename U2,
1448  typename T1, typename T2>
1449 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1450 {
1451  return DoSchedule (delay, MakeEvent (f, a1, a2));
1452 }
1453 
1454 template <typename U1, typename U2, typename U3,
1455  typename T1, typename T2, typename T3>
1456 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1457 {
1458  return DoSchedule (delay, MakeEvent (f, a1, a2, a3));
1459 }
1460 
1461 template <typename U1, typename U2, typename U3, typename U4,
1462  typename T1, typename T2, typename T3, typename T4>
1463 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1464 {
1465  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4));
1466 }
1467 
1468 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1469  typename T1, typename T2, typename T3, typename T4, typename T5>
1470 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1471 {
1472  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4, a5));
1473 }
1474 
1475 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1476  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1477 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)
1478 {
1479  return DoSchedule (time, MakeEvent (f, a1, a2, a3, a4, a5, a6));
1480 }
1481 
1482 
1483 template <typename MEM, typename OBJ>
1484 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
1485 {
1486  ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj));
1487 }
1488 
1489 
1490 template <typename MEM, typename OBJ,
1491  typename T1>
1492 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1493 {
1494  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1));
1495 }
1496 
1497 template <typename MEM, typename OBJ,
1498  typename T1, typename T2>
1499 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1500 {
1501  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2));
1502 }
1503 
1504 template <typename MEM, typename OBJ,
1505  typename T1, typename T2, typename T3>
1506 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1507 {
1508  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1509 }
1510 
1511 template <typename MEM, typename OBJ,
1512  typename T1, typename T2, typename T3, typename T4>
1513 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1514 {
1515  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1516 }
1517 
1518 template <typename MEM, typename OBJ,
1519  typename T1, typename T2, typename T3, typename T4, typename T5>
1520 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
1521  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1522 {
1523  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1524 }
1525 
1526 template <typename MEM, typename OBJ,
1527  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1528 void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
1529  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1530 {
1531  return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1532 }
1533 
1534 template <typename U1,
1535  typename T1>
1536 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1)
1537 {
1538  return ScheduleWithContext (context, delay, MakeEvent (f, a1));
1539 }
1540 
1541 template <typename U1, typename U2,
1542  typename T1, typename T2>
1543 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1544 {
1545  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2));
1546 }
1547 
1548 template <typename U1, typename U2, typename U3,
1549  typename T1, typename T2, typename T3>
1550 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1551 {
1552  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3));
1553 }
1554 
1555 template <typename U1, typename U2, typename U3, typename U4,
1556  typename T1, typename T2, typename T3, typename T4>
1557 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1558 {
1559  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4));
1560 }
1561 
1562 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1563  typename T1, typename T2, typename T3, typename T4, typename T5>
1564 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1565 {
1566  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4, a5));
1567 }
1568 
1569 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1570  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1571 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)
1572 {
1573  return ScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4, a5, a6));
1574 }
1575 
1576 
1577 template <typename MEM, typename OBJ>
1578 EventId
1579 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj)
1580 {
1581  return DoScheduleNow (MakeEvent (mem_ptr, obj));
1582 }
1583 
1584 
1585 template <typename MEM, typename OBJ,
1586  typename T1>
1587 EventId
1588 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1)
1589 {
1590  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1));
1591 }
1592 
1593 template <typename MEM, typename OBJ,
1594  typename T1, typename T2>
1595 EventId
1596 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1597 {
1598  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2));
1599 }
1600 
1601 template <typename MEM, typename OBJ,
1602  typename T1, typename T2, typename T3>
1603 EventId
1604 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1605 {
1606  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3));
1607 }
1608 
1609 template <typename MEM, typename OBJ,
1610  typename T1, typename T2, typename T3, typename T4>
1611 EventId
1612 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1613 {
1614  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1615 }
1616 
1617 template <typename MEM, typename OBJ,
1618  typename T1, typename T2, typename T3, typename T4, typename T5>
1619 EventId
1620 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1621  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1622 {
1623  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1624 }
1625 
1626 template <typename MEM, typename OBJ,
1627  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1628 EventId
1629 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1630  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1631 {
1632  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1633 }
1634 
1635 template <typename U1,
1636  typename T1>
1637 EventId
1638 Simulator::ScheduleNow (void (*f)(U1), T1 a1)
1639 {
1640  return DoScheduleNow (MakeEvent (f, a1));
1641 }
1642 
1643 template <typename U1, typename U2,
1644  typename T1, typename T2>
1645 EventId
1646 Simulator::ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2)
1647 {
1648  return DoScheduleNow (MakeEvent (f, a1, a2));
1649 }
1650 
1651 template <typename U1, typename U2, typename U3,
1652  typename T1, typename T2, typename T3>
1653 EventId
1654 Simulator::ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1655 {
1656  return DoScheduleNow (MakeEvent (f, a1, a2, a3));
1657 }
1658 
1659 template <typename U1, typename U2, typename U3, typename U4,
1660  typename T1, typename T2, typename T3, typename T4>
1661 EventId
1662 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1663 {
1664  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4));
1665 }
1666 
1667 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1668  typename T1, typename T2, typename T3, typename T4, typename T5>
1669 EventId
1670 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1671 {
1672  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5));
1673 }
1674 
1675 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1676  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1677 EventId
1678 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1679 {
1680  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5, a6));
1681 }
1682 
1683 
1684 template <typename MEM, typename OBJ>
1685 EventId
1686 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj)
1687 {
1688  return DoScheduleDestroy (MakeEvent (mem_ptr, obj));
1689 }
1690 
1691 
1692 template <typename MEM, typename OBJ,
1693  typename T1>
1694 EventId
1695 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1)
1696 {
1697  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1));
1698 }
1699 
1700 template <typename MEM, typename OBJ,
1701  typename T1, typename T2>
1702 EventId
1703 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1704 {
1705  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2));
1706 }
1707 
1708 template <typename MEM, typename OBJ,
1709  typename T1, typename T2, typename T3>
1710 EventId
1711 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1712 {
1713  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3));
1714 }
1715 
1716 template <typename MEM, typename OBJ,
1717  typename T1, typename T2, typename T3, typename T4>
1718 EventId
1719 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1720 {
1721  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1722 }
1723 
1724 template <typename MEM, typename OBJ,
1725  typename T1, typename T2, typename T3, typename T4, typename T5>
1726 EventId
1727 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1728  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1729 {
1730  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1731 }
1732 
1733 template <typename MEM, typename OBJ,
1734  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1735 EventId
1736 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1737  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1738 {
1739  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1740 }
1741 
1742 template <typename U1,
1743  typename T1>
1744 EventId
1745 Simulator::ScheduleDestroy (void (*f)(U1), T1 a1)
1746 {
1747  return DoScheduleDestroy (MakeEvent (f, a1));
1748 }
1749 
1750 template <typename U1, typename U2,
1751  typename T1, typename T2>
1752 EventId
1753 Simulator::ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2)
1754 {
1755  return DoScheduleDestroy (MakeEvent (f, a1, a2));
1756 }
1757 
1758 template <typename U1, typename U2, typename U3,
1759  typename T1, typename T2, typename T3>
1760 EventId
1761 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1762 {
1763  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3));
1764 }
1765 
1766 template <typename U1, typename U2, typename U3, typename U4,
1767  typename T1, typename T2, typename T3, typename T4>
1768 EventId
1769 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1770 {
1771  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4));
1772 }
1773 
1774 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1775  typename T1, typename T2, typename T3, typename T4, typename T5>
1776 EventId
1777 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1778 {
1779  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5));
1780 }
1781 
1782 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1783  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1784 EventId
1785 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1786 {
1787  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5, a6));
1788 }
1789 
1790 } // namespace ns3
1791 
1792 #endif /* SIMULATOR_H */
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:202
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Control the scheduling of simulation events.
Definition: simulator.h:68
ns3::EventImpl declarations.
static void SetImplementation(Ptr< SimulatorImpl > impl)
Definition: simulator.cc:349
static EventId DoScheduleDestroy(EventImpl *event)
Implementation of the various ScheduleDestroy methods.
Definition: simulator.cc:249
static Ptr< SimulatorImpl > GetImplementation(void)
Get the SimulatorImpl singleton.
Definition: simulator.cc:375
static uint32_t GetSystemId(void)
Get the system id of this simulator.
Definition: simulator.cc:334
static uint32_t GetContext(void)
Get the current simulation context.
Definition: simulator.cc:322
ns3::ObjectFactory class declaration.
static void Run(void)
Run the simulation.
Definition: simulator.cc:170
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event&#39;s associated function will not be invoked when it expires...
Definition: simulator.cc:290
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:745
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1390
ns3::MakeEvent function declarations and template implementation.
Declaration of classes ns3::Time and ns3::TimeWithUnit, and the TimeValue implementation classes...
~Simulator()
Destructor.
static EventId DoSchedule(Time const &delay, EventImpl *event)
Implementation of the various Schedule methods.
Definition: simulator.cc:233
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:134
double f(double x, void *params)
Definition: 80211b.c:70
static void Remove(const EventId &id)
Remove an event from the event list.
Definition: simulator.cc:280
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static bool IsExpired(const EventId &id)
Check if an event has already run or been cancelled.
Definition: simulator.cc:300
Simulator()
Default constructor.
static uint64_t GetEventCount(void)
Get the number of events executed.
Definition: simulator.cc:328
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1579
static void SetScheduler(ObjectFactory schedulerFactory)
Set the scheduler type with an ObjectFactory.
Definition: simulator.cc:156
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
Instantiate subclasses of ns3::Object.
static void ScheduleWithContext(uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
Definition: simulator.h:1484
A simulation event.
Definition: event-impl.h:44
static EventId DoScheduleNow(EventImpl *event)
Implementation of the various ScheduleNow methods.
Definition: simulator.cc:241
An identifier for simulation events.
Definition: event-id.h:53
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:178
Flag for events not associated with any particular context.
Definition: simulator.h:199
static bool IsFinished(void)
Check if the simulation should finish.
Definition: simulator.cc:163
static EventId ScheduleDestroy(MEM mem_ptr, OBJ obj)
Schedule an event to expire when Simulator::Destroy is called.
Definition: simulator.h:1686
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
ns3::EventId declarations.
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:315
EventImpl * MakeEvent(void(*f)(void))
Make an EventImpl from a function pointer taking varying numbers of arguments.
Definition: make-event.cc:34