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 
221  template <typename MEM, typename OBJ>
222  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj);
223 
235  template <typename MEM, typename OBJ, typename T1>
236  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
237 
251  template <typename MEM, typename OBJ, typename T1, typename T2>
252  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
253 
269  template <typename MEM, typename OBJ,
270  typename T1, typename T2, typename T3>
271  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
272 
290  template <typename MEM, typename OBJ,
291  typename T1, typename T2, typename T3, typename T4>
292  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
293 
313  template <typename MEM, typename OBJ,
314  typename T1, typename T2, typename T3, typename T4, typename T5>
315  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
316  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
317 
330  template <typename MEM, typename OBJ,
331  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
332  static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj,
333  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
334 
347  static EventId Schedule (Time const &delay, void (*f)(void));
348 
358  template <typename U1, typename T1>
359  static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1);
360 
373  template <typename U1, typename U2,
374  typename T1, typename T2>
375  static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
376 
392  template <typename U1, typename U2, typename U3,
393  typename T1, typename T2, typename T3>
394  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
395 
414  template <typename U1, typename U2, typename U3, typename U4,
415  typename T1, typename T2, typename T3, typename T4>
416  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
417 
439  template <typename U1, typename U2, typename U3, typename U4, typename U5,
440  typename T1, typename T2, typename T3, typename T4, typename T5>
441  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
442 
454  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
455  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
456  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);
457 
458  // Schedule events (in the same context) to run at a future time.
460 
480  template <typename MEM, typename OBJ>
481  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj);
482 
494  template <typename MEM, typename OBJ, typename T1>
495  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
496 
510  template <typename MEM, typename OBJ, typename T1, typename T2>
511  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
512 
528  template <typename MEM, typename OBJ,
529  typename T1, typename T2, typename T3>
530  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
531 
549  template <typename MEM, typename OBJ,
550  typename T1, typename T2, typename T3, typename T4>
551  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
552 
572  template <typename MEM, typename OBJ,
573  typename T1, typename T2, typename T3, typename T4, typename T5>
574  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
575  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
576 
591  template <typename MEM, typename OBJ,
592  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
593  static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
594  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
595 
609  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void));
610 
620  template <typename U1,
621  typename T1>
622  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1);
623 
636  template <typename U1, typename U2,
637  typename T1, typename T2>
638  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
639 
655  template <typename U1, typename U2, typename U3,
656  typename T1, typename T2, typename T3>
657  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
658 
677  template <typename U1, typename U2, typename U3, typename U4,
678  typename T1, typename T2, typename T3, typename T4>
679  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
680 
702  template <typename U1, typename U2, typename U3, typename U4, typename U5,
703  typename T1, typename T2, typename T3, typename T4, typename T5>
704  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);
705 
719  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
720  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
721  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);
722  // Schedule events (in a different context) to run now or at a future time.
724 
740  template <typename MEM, typename OBJ>
741  static EventId ScheduleNow (MEM mem_ptr, OBJ obj);
742 
753  template <typename MEM, typename OBJ,
754  typename T1>
755  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1);
756 
769  template <typename MEM, typename OBJ,
770  typename T1, typename T2>
771  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
772 
787  template <typename MEM, typename OBJ,
788  typename T1, typename T2, typename T3>
789  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
790 
807  template <typename MEM, typename OBJ,
808  typename T1, typename T2, typename T3, typename T4>
809  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
810  T1 a1, T2 a2, T3 a3, T4 a4);
829  template <typename MEM, typename OBJ,
830  typename T1, typename T2, typename T3, typename T4, typename T5>
831  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
832  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
833 
845  template <typename MEM, typename OBJ,
846  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
847  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
848  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
849 
858  static EventId ScheduleNow (void (*f)(void));
859 
868  template <typename U1,
869  typename T1>
870  static EventId ScheduleNow (void (*f)(U1), T1 a1);
871 
883  template <typename U1, typename U2,
884  typename T1, typename T2>
885  static EventId ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2);
886 
901  template <typename U1, typename U2, typename U3,
902  typename T1, typename T2, typename T3>
903  static EventId ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
904 
922  template <typename U1, typename U2, typename U3, typename U4,
923  typename T1, typename T2, typename T3, typename T4>
924  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
925 
946  template <typename U1, typename U2, typename U3, typename U4, typename U5,
947  typename T1, typename T2, typename T3, typename T4, typename T5>
948  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
949 
960  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
961  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
962  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
963  // Schedule events (in the same context) to run now.
965 
982  template <typename MEM, typename OBJ>
983  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj);
984 
995  template <typename MEM, typename OBJ,
996  typename T1>
997  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1);
998 
1011  template <typename MEM, typename OBJ,
1012  typename T1, typename T2>
1013  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
1014 
1029  template <typename MEM, typename OBJ,
1030  typename T1, typename T2, typename T3>
1031  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
1032 
1049  template <typename MEM, typename OBJ,
1050  typename T1, typename T2, typename T3, typename T4>
1051  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1052  T1 a1, T2 a2, T3 a3, T4 a4);
1071  template <typename MEM, typename OBJ,
1072  typename T1, typename T2, typename T3, typename T4, typename T5>
1073  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1074  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1075 
1087  template <typename MEM, typename OBJ,
1088  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1089  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
1090  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
1091 
1099  static EventId ScheduleDestroy (void (*f)(void));
1100 
1109  template <typename U1,
1110  typename T1>
1111  static EventId ScheduleDestroy (void (*f)(U1), T1 a1);
1112 
1124  template <typename U1, typename U2,
1125  typename T1, typename T2>
1126  static EventId ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2);
1127 
1142  template <typename U1, typename U2, typename U3,
1143  typename T1, typename T2, typename T3>
1144  static EventId ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
1145 
1163  template <typename U1, typename U2, typename U3, typename U4,
1164  typename T1, typename T2, typename T3, typename T4>
1165  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
1166 
1187  template <typename U1, typename U2, typename U3, typename U4, typename U5,
1188  typename T1, typename T2, typename T3, typename T4, typename T5>
1189  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1190 
1201  template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1202  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1203  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
1204  // Schedule events to run when Simulator:Destroy() is called.
1206 
1219  static void Remove (const EventId &id);
1220 
1234  static void Cancel (const EventId &id);
1235 
1250  static bool IsExpired (const EventId &id);
1251 
1257  static Time Now (void);
1258 
1267  static Time GetDelayLeft (const EventId &id);
1268 
1277  static Time GetMaximumSimulationTime (void);
1278 
1286  static EventId Schedule (const Time &delay, const Ptr<EventImpl> &event);
1287 
1297  static void ScheduleWithContext (uint32_t context, const Time &delay, EventImpl *event);
1298 
1306  static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
1307 
1314  static EventId ScheduleNow (const Ptr<EventImpl> &event);
1315 
1323  static uint32_t GetSystemId (void);
1324 
1325 private:
1327  Simulator ();
1329  ~Simulator ();
1330 
1337  static EventId DoSchedule (Time const &delay, EventImpl *event);
1343  static EventId DoScheduleNow (EventImpl *event);
1349  static EventId DoScheduleDestroy (EventImpl *event);
1350 };
1351 
1365 Time Now (void);
1366 
1367 } // namespace ns3
1368 
1369 
1370 /********************************************************************
1371  * Implementation of the templates declared above.
1372  ********************************************************************/
1373 
1374 namespace ns3 {
1375 
1376 // Doxygen has trouble with static template functions in a class:
1377 // it treats the in-class declaration as different from the
1378 // out of class definition, so makes two entries in the member list. Ugh
1379 
1380 template <typename MEM, typename OBJ>
1381 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj)
1382 {
1383  return DoSchedule (delay, MakeEvent (mem_ptr, obj));
1384 }
1385 
1386 
1387 template <typename MEM, typename OBJ,
1388  typename T1>
1389 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1390 {
1391  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1));
1392 }
1393 
1394 template <typename MEM, typename OBJ,
1395  typename T1, typename T2>
1396 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1397 {
1398  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2));
1399 }
1400 
1401 template <typename MEM, typename OBJ,
1402  typename T1, typename T2, typename T3>
1403 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1404 {
1405  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1406 }
1407 
1408 template <typename MEM, typename OBJ,
1409  typename T1, typename T2, typename T3, typename T4>
1410 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1411 {
1412  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1413 }
1414 
1415 template <typename MEM, typename OBJ,
1416  typename T1, typename T2, typename T3, typename T4, typename T5>
1417 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
1418  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1419 {
1420  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1421 }
1422 
1423 template <typename MEM, typename OBJ,
1424  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1425 EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj,
1426  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1427 {
1428  return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1429 }
1430 
1431 template <typename U1,
1432  typename T1>
1433 EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1)
1434 {
1435  return DoSchedule (delay, MakeEvent (f, a1));
1436 }
1437 
1438 template <typename U1, typename U2,
1439  typename T1, typename T2>
1440 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1441 {
1442  return DoSchedule (delay, MakeEvent (f, a1, a2));
1443 }
1444 
1445 template <typename U1, typename U2, typename U3,
1446  typename T1, typename T2, typename T3>
1447 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1448 {
1449  return DoSchedule (delay, MakeEvent (f, a1, a2, a3));
1450 }
1451 
1452 template <typename U1, typename U2, typename U3, typename U4,
1453  typename T1, typename T2, typename T3, typename T4>
1454 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1455 {
1456  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4));
1457 }
1458 
1459 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1460  typename T1, typename T2, typename T3, typename T4, typename T5>
1461 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1462 {
1463  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4, a5));
1464 }
1465 
1466 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1467  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1468 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)
1469 {
1470  return DoSchedule (time, MakeEvent (f, a1, a2, a3, a4, a5, a6));
1471 }
1472 
1473 
1474 template <typename MEM, typename OBJ>
1475 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
1476 {
1477  ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj));
1478 }
1479 
1480 
1481 template <typename MEM, typename OBJ,
1482  typename T1>
1483 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1484 {
1485  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1));
1486 }
1487 
1488 template <typename MEM, typename OBJ,
1489  typename T1, typename T2>
1490 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1491 {
1492  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2));
1493 }
1494 
1495 template <typename MEM, typename OBJ,
1496  typename T1, typename T2, typename T3>
1497 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1498 {
1499  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1500 }
1501 
1502 template <typename MEM, typename OBJ,
1503  typename T1, typename T2, typename T3, typename T4>
1504 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1505 {
1506  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1507 }
1508 
1509 template <typename MEM, typename OBJ,
1510  typename T1, typename T2, typename T3, typename T4, typename T5>
1511 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
1512  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1513 {
1514  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1515 }
1516 
1517 template <typename MEM, typename OBJ,
1518  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1519 void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
1520  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1521 {
1522  return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1523 }
1524 
1525 template <typename U1,
1526  typename T1>
1527 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1)
1528 {
1529  return ScheduleWithContext (context, delay, MakeEvent (f, a1));
1530 }
1531 
1532 template <typename U1, typename U2,
1533  typename T1, typename T2>
1534 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1535 {
1536  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2));
1537 }
1538 
1539 template <typename U1, typename U2, typename U3,
1540  typename T1, typename T2, typename T3>
1541 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1542 {
1543  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3));
1544 }
1545 
1546 template <typename U1, typename U2, typename U3, typename U4,
1547  typename T1, typename T2, typename T3, typename T4>
1548 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1549 {
1550  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4));
1551 }
1552 
1553 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1554  typename T1, typename T2, typename T3, typename T4, typename T5>
1555 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)
1556 {
1557  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4, a5));
1558 }
1559 
1560 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1561  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1562 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)
1563 {
1564  return ScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4, a5, a6));
1565 }
1566 
1567 
1568 template <typename MEM, typename OBJ>
1569 EventId
1570 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj)
1571 {
1572  return DoScheduleNow (MakeEvent (mem_ptr, obj));
1573 }
1574 
1575 
1576 template <typename MEM, typename OBJ,
1577  typename T1>
1578 EventId
1579 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1)
1580 {
1581  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1));
1582 }
1583 
1584 template <typename MEM, typename OBJ,
1585  typename T1, typename T2>
1586 EventId
1587 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1588 {
1589  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2));
1590 }
1591 
1592 template <typename MEM, typename OBJ,
1593  typename T1, typename T2, typename T3>
1594 EventId
1595 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1596 {
1597  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3));
1598 }
1599 
1600 template <typename MEM, typename OBJ,
1601  typename T1, typename T2, typename T3, typename T4>
1602 EventId
1603 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1604 {
1605  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1606 }
1607 
1608 template <typename MEM, typename OBJ,
1609  typename T1, typename T2, typename T3, typename T4, typename T5>
1610 EventId
1611 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1612  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1613 {
1614  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1615 }
1616 
1617 template <typename MEM, typename OBJ,
1618  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1619 EventId
1620 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1621  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1622 {
1623  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1624 }
1625 
1626 template <typename U1,
1627  typename T1>
1628 EventId
1629 Simulator::ScheduleNow (void (*f)(U1), T1 a1)
1630 {
1631  return DoScheduleNow (MakeEvent (f, a1));
1632 }
1633 
1634 template <typename U1, typename U2,
1635  typename T1, typename T2>
1636 EventId
1637 Simulator::ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2)
1638 {
1639  return DoScheduleNow (MakeEvent (f, a1, a2));
1640 }
1641 
1642 template <typename U1, typename U2, typename U3,
1643  typename T1, typename T2, typename T3>
1644 EventId
1645 Simulator::ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1646 {
1647  return DoScheduleNow (MakeEvent (f, a1, a2, a3));
1648 }
1649 
1650 template <typename U1, typename U2, typename U3, typename U4,
1651  typename T1, typename T2, typename T3, typename T4>
1652 EventId
1653 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1654 {
1655  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4));
1656 }
1657 
1658 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1659  typename T1, typename T2, typename T3, typename T4, typename T5>
1660 EventId
1661 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1662 {
1663  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5));
1664 }
1665 
1666 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1667  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1668 EventId
1669 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1670 {
1671  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5, a6));
1672 }
1673 
1674 
1675 template <typename MEM, typename OBJ>
1676 EventId
1677 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj)
1678 {
1679  return DoScheduleDestroy (MakeEvent (mem_ptr, obj));
1680 }
1681 
1682 
1683 template <typename MEM, typename OBJ,
1684  typename T1>
1685 EventId
1686 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1)
1687 {
1688  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1));
1689 }
1690 
1691 template <typename MEM, typename OBJ,
1692  typename T1, typename T2>
1693 EventId
1694 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1695 {
1696  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2));
1697 }
1698 
1699 template <typename MEM, typename OBJ,
1700  typename T1, typename T2, typename T3>
1701 EventId
1702 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1703 {
1704  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3));
1705 }
1706 
1707 template <typename MEM, typename OBJ,
1708  typename T1, typename T2, typename T3, typename T4>
1709 EventId
1710 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1711 {
1712  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1713 }
1714 
1715 template <typename MEM, typename OBJ,
1716  typename T1, typename T2, typename T3, typename T4, typename T5>
1717 EventId
1718 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1719  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1720 {
1721  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1722 }
1723 
1724 template <typename MEM, typename OBJ,
1725  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1726 EventId
1727 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1728  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1729 {
1730  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6));
1731 }
1732 
1733 template <typename U1,
1734  typename T1>
1735 EventId
1736 Simulator::ScheduleDestroy (void (*f)(U1), T1 a1)
1737 {
1738  return DoScheduleDestroy (MakeEvent (f, a1));
1739 }
1740 
1741 template <typename U1, typename U2,
1742  typename T1, typename T2>
1743 EventId
1744 Simulator::ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2)
1745 {
1746  return DoScheduleDestroy (MakeEvent (f, a1, a2));
1747 }
1748 
1749 template <typename U1, typename U2, typename U3,
1750  typename T1, typename T2, typename T3>
1751 EventId
1752 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1753 {
1754  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3));
1755 }
1756 
1757 template <typename U1, typename U2, typename U3, typename U4,
1758  typename T1, typename T2, typename T3, typename T4>
1759 EventId
1760 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1761 {
1762  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4));
1763 }
1764 
1765 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1766  typename T1, typename T2, typename T3, typename T4, typename T5>
1767 EventId
1768 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1769 {
1770  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5));
1771 }
1772 
1773 template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6,
1774  typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1775 EventId
1776 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
1777 {
1778  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5, a6));
1779 }
1780 
1781 } // namespace ns3
1782 
1783 #endif /* SIMULATOR_H */
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:258
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:399
static EventId DoScheduleDestroy(EventImpl *event)
Implementation of the various ScheduleDestroy methods.
Definition: simulator.cc:305
static Ptr< SimulatorImpl > GetImplementation(void)
Get the SimulatorImpl singleton.
Definition: simulator.cc:425
static uint32_t GetSystemId(void)
Get the system id of this simulator.
Definition: simulator.cc:384
static uint32_t GetContext(void)
Get the current simulation context.
Definition: simulator.cc:378
ns3::ObjectFactory class declaration.
static void Run(void)
Run the simulation.
Definition: simulator.cc:226
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:346
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
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:289
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:190
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:336
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:356
Simulator()
Default constructor.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1570
static void SetScheduler(ObjectFactory schedulerFactory)
Set the scheduler type with an ObjectFactory.
Definition: simulator.cc:212
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
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:1475
A simulation event.
Definition: event-impl.h:44
static EventId DoScheduleNow(EventImpl *event)
Implementation of the various ScheduleNow methods.
Definition: simulator.cc:297
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:234
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:219
static EventId ScheduleDestroy(MEM mem_ptr, OBJ obj)
Schedule an event to expire when Simulator::Destroy is called.
Definition: simulator.h:1677
ns3::EventId declarations.
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:371
EventImpl * MakeEvent(void(*f)(void))
Make an EventImpl from a function pointer taking varying numbers of arguments.
Definition: make-event.cc:34