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 {
198  NO_CONTEXT = 0xffffffff
199  };
200 
205  static uint64_t GetEventCount (void);
206 
207 
228  template <typename MEM, typename OBJ>
229  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj);
230 
242  template <typename MEM, typename OBJ, typename T1>
243  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
244 
258  template <typename MEM, typename OBJ, typename T1, typename T2>
259  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
260 
276  template <typename MEM, typename OBJ,
277  typename T1, typename T2, typename T3>
278  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
279 
297  template <typename MEM, typename OBJ,
298  typename T1, typename T2, typename T3, typename T4>
299  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
300 
320  template <typename MEM, typename OBJ,
321  typename T1, typename T2, typename T3, typename T4, typename T5>
322  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
323  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
324 
337  template <typename MEM, typename OBJ,
338  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
339  static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj,
340  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
341 
354  static EventId Schedule (Time const &delay, void (*f)(void));
355 
365  template <typename U1, typename T1>
366  static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1);
367 
380  template <typename U1, typename U2,
381  typename T1, typename T2>
382  static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
383 
399  template <typename U1, typename U2, typename U3,
400  typename T1, typename T2, typename T3>
401  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
402 
421  template <typename U1, typename U2, typename U3, typename U4,
422  typename T1, typename T2, typename T3, typename T4>
423  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
424 
446  template <typename U1, typename U2, typename U3, typename U4, typename U5,
447  typename T1, typename T2, typename T3, typename T4, typename T5>
448  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
449 
461  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
462  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
463  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);
464 
465  // Schedule events (in the same context) to run at a future time.
467 
487  template <typename MEM, typename OBJ>
488  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj);
489 
501  template <typename MEM, typename OBJ, typename T1>
502  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
503 
517  template <typename MEM, typename OBJ, typename T1, typename T2>
518  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
519 
535  template <typename MEM, typename OBJ,
536  typename T1, typename T2, typename T3>
537  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
538 
556  template <typename MEM, typename OBJ,
557  typename T1, typename T2, typename T3, typename T4>
558  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
559 
579  template <typename MEM, typename OBJ,
580  typename T1, typename T2, typename T3, typename T4, typename T5>
581  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
582  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
583 
598  template <typename MEM, typename OBJ,
599  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
600  static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
601  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
602 
616  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void));
617 
627  template <typename U1,
628  typename T1>
629  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1);
630 
643  template <typename U1, typename U2,
644  typename T1, typename T2>
645  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
646 
662  template <typename U1, typename U2, typename U3,
663  typename T1, typename T2, typename T3>
664  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
665 
684  template <typename U1, typename U2, typename U3, typename U4,
685  typename T1, typename T2, typename T3, typename T4>
686  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
687 
709  template <typename U1, typename U2, typename U3, typename U4, typename U5,
710  typename T1, typename T2, typename T3, typename T4, typename T5>
711  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);
712 
726  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
727  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
728  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);
729  // Schedule events (in a different context) to run now or at a future time.
731 
747  template <typename MEM, typename OBJ>
748  static EventId ScheduleNow (MEM mem_ptr, OBJ obj);
749 
760  template <typename MEM, typename OBJ,
761  typename T1>
762  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1);
763 
776  template <typename MEM, typename OBJ,
777  typename T1, typename T2>
778  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
779 
794  template <typename MEM, typename OBJ,
795  typename T1, typename T2, typename T3>
796  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
797 
814  template <typename MEM, typename OBJ,
815  typename T1, typename T2, typename T3, typename T4>
816  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
817  T1 a1, T2 a2, T3 a3, T4 a4);
836  template <typename MEM, typename OBJ,
837  typename T1, typename T2, typename T3, typename T4, typename T5>
838  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
839  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
840 
852  template <typename MEM, typename OBJ,
853  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
854  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
855  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
856 
865  static EventId ScheduleNow (void (*f)(void));
866 
875  template <typename U1,
876  typename T1>
877  static EventId ScheduleNow (void (*f)(U1), T1 a1);
878 
890  template <typename U1, typename U2,
891  typename T1, typename T2>
892  static EventId ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2);
893 
908  template <typename U1, typename U2, typename U3,
909  typename T1, typename T2, typename T3>
910  static EventId ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
911 
929  template <typename U1, typename U2, typename U3, typename U4,
930  typename T1, typename T2, typename T3, typename T4>
931  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
932 
953  template <typename U1, typename U2, typename U3, typename U4, typename U5,
954  typename T1, typename T2, typename T3, typename T4, typename T5>
955  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
956 
967  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
968  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
969  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
970  // Schedule events (in the same context) to run now.
972 
989  template <typename MEM, typename OBJ>
990  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj);
991 
1002  template <typename MEM, typename OBJ,
1003  typename T1>
1004  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1);
1005 
1018  template <typename MEM, typename OBJ,
1019  typename T1, typename T2>
1020  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
1021 
1036  template <typename MEM, typename OBJ,
1037  typename T1, typename T2, typename T3>
1038  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
1039 
1056  template <typename MEM, typename OBJ,
1057  typename T1, typename T2, typename T3, typename T4>
1058  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1059  T1 a1, T2 a2, T3 a3, T4 a4);
1078  template <typename MEM, typename OBJ,
1079  typename T1, typename T2, typename T3, typename T4, typename T5>
1080  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1081  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1082 
1094  template <typename MEM, typename OBJ,
1095  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1096  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1097  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
1098 
1106  static EventId ScheduleDestroy (void (*f)(void));
1107 
1116  template <typename U1,
1117  typename T1>
1118  static EventId ScheduleDestroy (void (*f)(U1), T1 a1);
1119 
1131  template <typename U1, typename U2,
1132  typename T1, typename T2>
1133  static EventId ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2);
1134 
1149  template <typename U1, typename U2, typename U3,
1150  typename T1, typename T2, typename T3>
1151  static EventId ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
1152 
1170  template <typename U1, typename U2, typename U3, typename U4,
1171  typename T1, typename T2, typename T3, typename T4>
1172  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
1173 
1194  template <typename U1, typename U2, typename U3, typename U4, typename U5,
1195  typename T1, typename T2, typename T3, typename T4, typename T5>
1196  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1197 
1208  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1209  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1210  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
1211  // Schedule events to run when Simulator:Destroy() is called.
1213 
1226  static void Remove (const EventId &id);
1227 
1241  static void Cancel (const EventId &id);
1242 
1257  static bool IsExpired (const EventId &id);
1258 
1264  static Time Now (void);
1265 
1274  static Time GetDelayLeft (const EventId &id);
1275 
1284  static Time GetMaximumSimulationTime (void);
1285 
1293  static EventId Schedule (const Time &delay, const Ptr<EventImpl> &event);
1294 
1304  static void ScheduleWithContext (uint32_t context, const Time &delay, EventImpl *event);
1305 
1313  static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
1314 
1321  static EventId ScheduleNow (const Ptr<EventImpl> &event);
1322 
1330  static uint32_t GetSystemId (void);
1331 
1332 private:
1334  Simulator ();
1336  ~Simulator ();
1337 
1344  static EventId DoSchedule (Time const &delay, EventImpl *event);
1350  static EventId DoScheduleNow (EventImpl *event);
1356  static EventId DoScheduleDestroy (EventImpl *event);
1357 
1358 }; // class Simulator
1359 
1373 Time Now (void);
1374 
1375 } // namespace ns3
1376 
1377 
1378 /********************************************************************
1379  * Implementation of the templates declared above.
1380  ********************************************************************/
1381 
1382 namespace ns3 {
1383 
1384 // Doxygen has trouble with static template functions in a class:
1385 // it treats the in-class declaration as different from the
1386 // out of class definition, so makes two entries in the member list. Ugh
1387 
1388 template <typename MEM, typename OBJ>
1389 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj)
1390 {
1391  return DoSchedule (delay, MakeEvent (mem_ptr, obj));
1392 }
1393 
1394 
1395 template <typename MEM, typename OBJ,
1396  typename T1>
1397 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1398 {
1399  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1));
1400 }
1401 
1402 template <typename MEM, typename OBJ,
1403  typename T1, typename T2>
1404 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1405 {
1406  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2));
1407 }
1408 
1409 template <typename MEM, typename OBJ,
1410  typename T1, typename T2, typename T3>
1411 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1412 {
1413  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1414 }
1415 
1416 template <typename MEM, typename OBJ,
1417  typename T1, typename T2, typename T3, typename T4>
1418 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1419 {
1420  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1421 }
1422 
1423 template <typename MEM, typename OBJ,
1424  typename T1, typename T2, typename T3, typename T4, typename T5>
1425 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
1426  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1427 {
1428  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1429 }
1430 
1431 template <typename MEM, typename OBJ,
1432  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1433 EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj,
1434  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1435 {
1436  return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1437 }
1438 
1439 template <typename U1,
1440  typename T1>
1441 EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1)
1442 {
1443  return DoSchedule (delay, MakeEvent (f, a1));
1444 }
1445 
1446 template <typename U1, typename U2,
1447  typename T1, typename T2>
1448 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1449 {
1450  return DoSchedule (delay, MakeEvent (f, a1, a2));
1451 }
1452 
1453 template <typename U1, typename U2, typename U3,
1454  typename T1, typename T2, typename T3>
1455 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1456 {
1457  return DoSchedule (delay, MakeEvent (f, a1, a2, a3));
1458 }
1459 
1460 template <typename U1, typename U2, typename U3, typename U4,
1461  typename T1, typename T2, typename T3, typename T4>
1462 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1463 {
1464  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4));
1465 }
1466 
1467 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1468  typename T1, typename T2, typename T3, typename T4, typename T5>
1469 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1470 {
1471  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4, a5));
1472 }
1473 
1474 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1475  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1476 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)
1477 {
1478  return DoSchedule (time, MakeEvent (f, a1, a2, a3, a4, a5, a6));
1479 }
1480 
1481 
1482 template <typename MEM, typename OBJ>
1483 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
1484 {
1485  ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj));
1486 }
1487 
1488 
1489 template <typename MEM, typename OBJ,
1490  typename T1>
1491 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1492 {
1493  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1));
1494 }
1495 
1496 template <typename MEM, typename OBJ,
1497  typename T1, typename T2>
1498 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1499 {
1500  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2));
1501 }
1502 
1503 template <typename MEM, typename OBJ,
1504  typename T1, typename T2, typename T3>
1505 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1506 {
1507  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1508 }
1509 
1510 template <typename MEM, typename OBJ,
1511  typename T1, typename T2, typename T3, typename T4>
1512 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1513 {
1514  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1515 }
1516 
1517 template <typename MEM, typename OBJ,
1518  typename T1, typename T2, typename T3, typename T4, typename T5>
1519 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
1520  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1521 {
1522  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1523 }
1524 
1525 template <typename MEM, typename OBJ,
1526  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1527 void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
1528  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1529 {
1530  return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1531 }
1532 
1533 template <typename U1,
1534  typename T1>
1535 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1)
1536 {
1537  return ScheduleWithContext (context, delay, MakeEvent (f, a1));
1538 }
1539 
1540 template <typename U1, typename U2,
1541  typename T1, typename T2>
1542 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1543 {
1544  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2));
1545 }
1546 
1547 template <typename U1, typename U2, typename U3,
1548  typename T1, typename T2, typename T3>
1549 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1550 {
1551  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3));
1552 }
1553 
1554 template <typename U1, typename U2, typename U3, typename U4,
1555  typename T1, typename T2, typename T3, typename T4>
1556 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1557 {
1558  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4));
1559 }
1560 
1561 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1562  typename T1, typename T2, typename T3, typename T4, typename T5>
1563 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)
1564 {
1565  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4, a5));
1566 }
1567 
1568 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1569  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1570 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)
1571 {
1572  return ScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4, a5, a6));
1573 }
1574 
1575 
1576 template <typename MEM, typename OBJ>
1577 EventId
1578 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj)
1579 {
1580  return DoScheduleNow (MakeEvent (mem_ptr, obj));
1581 }
1582 
1583 
1584 template <typename MEM, typename OBJ,
1585  typename T1>
1586 EventId
1587 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1)
1588 {
1589  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1));
1590 }
1591 
1592 template <typename MEM, typename OBJ,
1593  typename T1, typename T2>
1594 EventId
1595 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1596 {
1597  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2));
1598 }
1599 
1600 template <typename MEM, typename OBJ,
1601  typename T1, typename T2, typename T3>
1602 EventId
1603 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1604 {
1605  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3));
1606 }
1607 
1608 template <typename MEM, typename OBJ,
1609  typename T1, typename T2, typename T3, typename T4>
1610 EventId
1611 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1612 {
1613  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1614 }
1615 
1616 template <typename MEM, typename OBJ,
1617  typename T1, typename T2, typename T3, typename T4, typename T5>
1618 EventId
1619 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1620  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1621 {
1622  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1623 }
1624 
1625 template <typename MEM, typename OBJ,
1626  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1627 EventId
1628 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1629  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1630 {
1631  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1632 }
1633 
1634 template <typename U1,
1635  typename T1>
1636 EventId
1637 Simulator::ScheduleNow (void (*f)(U1), T1 a1)
1638 {
1639  return DoScheduleNow (MakeEvent (f, a1));
1640 }
1641 
1642 template <typename U1, typename U2,
1643  typename T1, typename T2>
1644 EventId
1645 Simulator::ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2)
1646 {
1647  return DoScheduleNow (MakeEvent (f, a1, a2));
1648 }
1649 
1650 template <typename U1, typename U2, typename U3,
1651  typename T1, typename T2, typename T3>
1652 EventId
1653 Simulator::ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1654 {
1655  return DoScheduleNow (MakeEvent (f, a1, a2, a3));
1656 }
1657 
1658 template <typename U1, typename U2, typename U3, typename U4,
1659  typename T1, typename T2, typename T3, typename T4>
1660 EventId
1661 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1662 {
1663  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4));
1664 }
1665 
1666 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1667  typename T1, typename T2, typename T3, typename T4, typename T5>
1668 EventId
1669 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1670 {
1671  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5));
1672 }
1673 
1674 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1675  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1676 EventId
1677 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1678 {
1679  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5, a6));
1680 }
1681 
1682 
1683 template <typename MEM, typename OBJ>
1684 EventId
1685 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj)
1686 {
1687  return DoScheduleDestroy (MakeEvent (mem_ptr, obj));
1688 }
1689 
1690 
1691 template <typename MEM, typename OBJ,
1692  typename T1>
1693 EventId
1694 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1)
1695 {
1696  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1));
1697 }
1698 
1699 template <typename MEM, typename OBJ,
1700  typename T1, typename T2>
1701 EventId
1702 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1703 {
1704  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2));
1705 }
1706 
1707 template <typename MEM, typename OBJ,
1708  typename T1, typename T2, typename T3>
1709 EventId
1710 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1711 {
1712  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3));
1713 }
1714 
1715 template <typename MEM, typename OBJ,
1716  typename T1, typename T2, typename T3, typename T4>
1717 EventId
1718 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1719 {
1720  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1721 }
1722 
1723 template <typename MEM, typename OBJ,
1724  typename T1, typename T2, typename T3, typename T4, typename T5>
1725 EventId
1726 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1727  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1728 {
1729  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1730 }
1731 
1732 template <typename MEM, typename OBJ,
1733  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1734 EventId
1735 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1736  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1737 {
1738  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1739 }
1740 
1741 template <typename U1,
1742  typename T1>
1743 EventId
1744 Simulator::ScheduleDestroy (void (*f)(U1), T1 a1)
1745 {
1746  return DoScheduleDestroy (MakeEvent (f, a1));
1747 }
1748 
1749 template <typename U1, typename U2,
1750  typename T1, typename T2>
1751 EventId
1752 Simulator::ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2)
1753 {
1754  return DoScheduleDestroy (MakeEvent (f, a1, a2));
1755 }
1756 
1757 template <typename U1, typename U2, typename U3,
1758  typename T1, typename T2, typename T3>
1759 EventId
1760 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1761 {
1762  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3));
1763 }
1764 
1765 template <typename U1, typename U2, typename U3, typename U4,
1766  typename T1, typename T2, typename T3, typename T4>
1767 EventId
1768 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1769 {
1770  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4));
1771 }
1772 
1773 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1774  typename T1, typename T2, typename T3, typename T4, typename T5>
1775 EventId
1776 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1777 {
1778  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5));
1779 }
1780 
1781 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1782  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1783 EventId
1784 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1785 {
1786  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5, a6));
1787 }
1788 
1789 } // namespace ns3
1790 
1791 #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:743
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1389
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:1578
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:1483
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:198
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:1685
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