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 
188  enum {
192  NO_CONTEXT = 0xffffffff
193  };
194 
215  template <typename MEM, typename OBJ>
216  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj);
217 
229  template <typename MEM, typename OBJ, typename T1>
230  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
231 
245  template <typename MEM, typename OBJ, typename T1, typename T2>
246  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
247 
263  template <typename MEM, typename OBJ,
264  typename T1, typename T2, typename T3>
265  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
266 
284  template <typename MEM, typename OBJ,
285  typename T1, typename T2, typename T3, typename T4>
286  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
287 
307  template <typename MEM, typename OBJ,
308  typename T1, typename T2, typename T3, typename T4, typename T5>
309  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
310  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
323  static EventId Schedule (Time const &delay, void (*f)(void));
324 
334  template <typename U1, typename T1>
335  static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1);
336 
349  template <typename U1, typename U2,
350  typename T1, typename T2>
351  static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
352 
368  template <typename U1, typename U2, typename U3,
369  typename T1, typename T2, typename T3>
370  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
371 
390  template <typename U1, typename U2, typename U3, typename U4,
391  typename T1, typename T2, typename T3, typename T4>
392  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
393 
415  template <typename U1, typename U2, typename U3, typename U4, typename U5,
416  typename T1, typename T2, typename T3, typename T4, typename T5>
417  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
418 
440  template <typename MEM, typename OBJ>
441  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj);
442 
454  template <typename MEM, typename OBJ, typename T1>
455  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
456 
470  template <typename MEM, typename OBJ, typename T1, typename T2>
471  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
472 
488  template <typename MEM, typename OBJ,
489  typename T1, typename T2, typename T3>
490  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
491 
509  template <typename MEM, typename OBJ,
510  typename T1, typename T2, typename T3, typename T4>
511  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
512 
532  template <typename MEM, typename OBJ,
533  typename T1, typename T2, typename T3, typename T4, typename T5>
534  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
535  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
549  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void));
550 
560  template <typename U1,
561  typename T1>
562  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1);
563 
576  template <typename U1, typename U2,
577  typename T1, typename T2>
578  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
579 
595  template <typename U1, typename U2, typename U3,
596  typename T1, typename T2, typename T3>
597  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
598 
617  template <typename U1, typename U2, typename U3, typename U4,
618  typename T1, typename T2, typename T3, typename T4>
619  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
620 
642  template <typename U1, typename U2, typename U3, typename U4, typename U5,
643  typename T1, typename T2, typename T3, typename T4, typename T5>
644  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);
645 
663  template <typename MEM, typename OBJ>
664  static EventId ScheduleNow (MEM mem_ptr, OBJ obj);
665 
676  template <typename MEM, typename OBJ,
677  typename T1>
678  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1);
679 
692  template <typename MEM, typename OBJ,
693  typename T1, typename T2>
694  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
695 
710  template <typename MEM, typename OBJ,
711  typename T1, typename T2, typename T3>
712  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
713 
730  template <typename MEM, typename OBJ,
731  typename T1, typename T2, typename T3, typename T4>
732  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
733  T1 a1, T2 a2, T3 a3, T4 a4);
752  template <typename MEM, typename OBJ,
753  typename T1, typename T2, typename T3, typename T4, typename T5>
754  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
755  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
764  static EventId ScheduleNow (void (*f)(void));
765 
774  template <typename U1,
775  typename T1>
776  static EventId ScheduleNow (void (*f)(U1), T1 a1);
777 
789  template <typename U1, typename U2,
790  typename T1, typename T2>
791  static EventId ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2);
792 
807  template <typename U1, typename U2, typename U3,
808  typename T1, typename T2, typename T3>
809  static EventId ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
810 
828  template <typename U1, typename U2, typename U3, typename U4,
829  typename T1, typename T2, typename T3, typename T4>
830  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
831 
852  template <typename U1, typename U2, typename U3, typename U4, typename U5,
853  typename T1, typename T2, typename T3, typename T4, typename T5>
854  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
855 
874  template <typename MEM, typename OBJ>
875  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj);
876 
887  template <typename MEM, typename OBJ,
888  typename T1>
889  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1);
890 
903  template <typename MEM, typename OBJ,
904  typename T1, typename T2>
905  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
906 
921  template <typename MEM, typename OBJ,
922  typename T1, typename T2, typename T3>
923  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
924 
941  template <typename MEM, typename OBJ,
942  typename T1, typename T2, typename T3, typename T4>
943  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
944  T1 a1, T2 a2, T3 a3, T4 a4);
963  template <typename MEM, typename OBJ,
964  typename T1, typename T2, typename T3, typename T4, typename T5>
965  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
966  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
974  static EventId ScheduleDestroy (void (*f)(void));
975 
984  template <typename U1,
985  typename T1>
986  static EventId ScheduleDestroy (void (*f)(U1), T1 a1);
987 
999  template <typename U1, typename U2,
1000  typename T1, typename T2>
1001  static EventId ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2);
1002 
1017  template <typename U1, typename U2, typename U3,
1018  typename T1, typename T2, typename T3>
1019  static EventId ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
1020 
1038  template <typename U1, typename U2, typename U3, typename U4,
1039  typename T1, typename T2, typename T3, typename T4>
1040  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
1041 
1062  template <typename U1, typename U2, typename U3, typename U4, typename U5,
1063  typename T1, typename T2, typename T3, typename T4, typename T5>
1064  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1065 
1080  static void Remove (const EventId &id);
1081 
1095  static void Cancel (const EventId &id);
1096 
1111  static bool IsExpired (const EventId &id);
1112 
1118  static Time Now (void);
1119 
1128  static Time GetDelayLeft (const EventId &id);
1129 
1138  static Time GetMaximumSimulationTime (void);
1139 
1147  static EventId Schedule (const Time &delay, const Ptr<EventImpl> &event);
1148 
1158  static void ScheduleWithContext (uint32_t context, const Time &delay, EventImpl *event);
1159 
1167  static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
1168 
1175  static EventId ScheduleNow (const Ptr<EventImpl> &event);
1176 
1184  static uint32_t GetSystemId (void);
1185 
1186 private:
1188  Simulator ();
1190  ~Simulator ();
1191 
1198  static EventId DoSchedule (Time const &delay, EventImpl *event);
1204  static EventId DoScheduleNow (EventImpl *event);
1210  static EventId DoScheduleDestroy (EventImpl *event);
1211 };
1212 
1226 Time Now (void);
1227 
1228 } // namespace ns3
1229 
1230 
1231 /********************************************************************
1232  * Implementation of the templates declared above.
1233  ********************************************************************/
1234 
1235 namespace ns3 {
1236 
1237 template <typename MEM, typename OBJ>
1238 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj)
1239 {
1240  return DoSchedule (delay, MakeEvent (mem_ptr, obj));
1241 }
1242 
1243 
1244 template <typename MEM, typename OBJ,
1245  typename T1>
1246 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1247 {
1248  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1));
1249 }
1250 
1251 template <typename MEM, typename OBJ,
1252  typename T1, typename T2>
1253 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1254 {
1255  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2));
1256 }
1257 
1258 template <typename MEM, typename OBJ,
1259  typename T1, typename T2, typename T3>
1260 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1261 {
1262  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1263 }
1264 
1265 template <typename MEM, typename OBJ,
1266  typename T1, typename T2, typename T3, typename T4>
1267 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1268 {
1269  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1270 }
1271 
1272 template <typename MEM, typename OBJ,
1273  typename T1, typename T2, typename T3, typename T4, typename T5>
1274 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
1275  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1276 {
1277  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1278 }
1279 
1280 template <typename U1,
1281  typename T1>
1282 EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1)
1283 {
1284  return DoSchedule (delay, MakeEvent (f, a1));
1285 }
1286 
1287 template <typename U1, typename U2,
1288  typename T1, typename T2>
1289 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1290 {
1291  return DoSchedule (delay, MakeEvent (f, a1, a2));
1292 }
1293 
1294 template <typename U1, typename U2, typename U3,
1295  typename T1, typename T2, typename T3>
1296 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1297 {
1298  return DoSchedule (delay, MakeEvent (f, a1, a2, a3));
1299 }
1300 
1301 template <typename U1, typename U2, typename U3, typename U4,
1302  typename T1, typename T2, typename T3, typename T4>
1303 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1304 {
1305  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4));
1306 }
1307 
1308 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1309  typename T1, typename T2, typename T3, typename T4, typename T5>
1310 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1311 {
1312  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4, a5));
1313 }
1314 
1315 
1316 
1317 
1318 template <typename MEM, typename OBJ>
1319 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
1320 {
1321  ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj));
1322 }
1323 
1324 
1325 template <typename MEM, typename OBJ,
1326  typename T1>
1327 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1328 {
1329  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1));
1330 }
1331 
1332 template <typename MEM, typename OBJ,
1333  typename T1, typename T2>
1334 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1335 {
1336  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2));
1337 }
1338 
1339 template <typename MEM, typename OBJ,
1340  typename T1, typename T2, typename T3>
1341 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1342 {
1343  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1344 }
1345 
1346 template <typename MEM, typename OBJ,
1347  typename T1, typename T2, typename T3, typename T4>
1348 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1349 {
1350  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1351 }
1352 
1353 template <typename MEM, typename OBJ,
1354  typename T1, typename T2, typename T3, typename T4, typename T5>
1355 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
1356  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1357 {
1358  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1359 }
1360 
1361 template <typename U1,
1362  typename T1>
1363 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1)
1364 {
1365  return ScheduleWithContext (context, delay, MakeEvent (f, a1));
1366 }
1367 
1368 template <typename U1, typename U2,
1369  typename T1, typename T2>
1370 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1371 {
1372  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2));
1373 }
1374 
1375 template <typename U1, typename U2, typename U3,
1376  typename T1, typename T2, typename T3>
1377 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1378 {
1379  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3));
1380 }
1381 
1382 template <typename U1, typename U2, typename U3, typename U4,
1383  typename T1, typename T2, typename T3, typename T4>
1384 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1385 {
1386  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4));
1387 }
1388 
1389 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1390  typename T1, typename T2, typename T3, typename T4, typename T5>
1391 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)
1392 {
1393  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4, a5));
1394 }
1395 
1396 
1397 
1398 
1399 template <typename MEM, typename OBJ>
1400 EventId
1401 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj)
1402 {
1403  return DoScheduleNow (MakeEvent (mem_ptr, obj));
1404 }
1405 
1406 
1407 template <typename MEM, typename OBJ,
1408  typename T1>
1409 EventId
1410 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1)
1411 {
1412  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1));
1413 }
1414 
1415 template <typename MEM, typename OBJ,
1416  typename T1, typename T2>
1417 EventId
1418 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1419 {
1420  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2));
1421 }
1422 
1423 template <typename MEM, typename OBJ,
1424  typename T1, typename T2, typename T3>
1425 EventId
1426 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1427 {
1428  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3));
1429 }
1430 
1431 template <typename MEM, typename OBJ,
1432  typename T1, typename T2, typename T3, typename T4>
1433 EventId
1434 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1435 {
1436  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1437 }
1438 
1439 template <typename MEM, typename OBJ,
1440  typename T1, typename T2, typename T3, typename T4, typename T5>
1441 EventId
1442 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1443  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1444 {
1445  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1446 }
1447 
1448 template <typename U1,
1449  typename T1>
1450 EventId
1451 Simulator::ScheduleNow (void (*f)(U1), T1 a1)
1452 {
1453  return DoScheduleNow (MakeEvent (f, a1));
1454 }
1455 
1456 template <typename U1, typename U2,
1457  typename T1, typename T2>
1458 EventId
1459 Simulator::ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2)
1460 {
1461  return DoScheduleNow (MakeEvent (f, a1, a2));
1462 }
1463 
1464 template <typename U1, typename U2, typename U3,
1465  typename T1, typename T2, typename T3>
1466 EventId
1467 Simulator::ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1468 {
1469  return DoScheduleNow (MakeEvent (f, a1, a2, a3));
1470 }
1471 
1472 template <typename U1, typename U2, typename U3, typename U4,
1473  typename T1, typename T2, typename T3, typename T4>
1474 EventId
1475 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1476 {
1477  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4));
1478 }
1479 
1480 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1481  typename T1, typename T2, typename T3, typename T4, typename T5>
1482 EventId
1483 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1484 {
1485  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5));
1486 }
1487 
1488 
1489 
1490 template <typename MEM, typename OBJ>
1491 EventId
1492 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj)
1493 {
1494  return DoScheduleDestroy (MakeEvent (mem_ptr, obj));
1495 }
1496 
1497 
1498 template <typename MEM, typename OBJ,
1499  typename T1>
1500 EventId
1501 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1)
1502 {
1503  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1));
1504 }
1505 
1506 template <typename MEM, typename OBJ,
1507  typename T1, typename T2>
1508 EventId
1509 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1510 {
1511  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2));
1512 }
1513 
1514 template <typename MEM, typename OBJ,
1515  typename T1, typename T2, typename T3>
1516 EventId
1517 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1518 {
1519  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3));
1520 }
1521 
1522 template <typename MEM, typename OBJ,
1523  typename T1, typename T2, typename T3, typename T4>
1524 EventId
1525 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1526 {
1527  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1528 }
1529 
1530 template <typename MEM, typename OBJ,
1531  typename T1, typename T2, typename T3, typename T4, typename T5>
1532 EventId
1533 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1534  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1535 {
1536  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1537 }
1538 
1539 template <typename U1,
1540  typename T1>
1541 EventId
1542 Simulator::ScheduleDestroy (void (*f)(U1), T1 a1)
1543 {
1544  return DoScheduleDestroy (MakeEvent (f, a1));
1545 }
1546 
1547 template <typename U1, typename U2,
1548  typename T1, typename T2>
1549 EventId
1550 Simulator::ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2)
1551 {
1552  return DoScheduleDestroy (MakeEvent (f, a1, a2));
1553 }
1554 
1555 template <typename U1, typename U2, typename U3,
1556  typename T1, typename T2, typename T3>
1557 EventId
1558 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1559 {
1560  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3));
1561 }
1562 
1563 template <typename U1, typename U2, typename U3, typename U4,
1564  typename T1, typename T2, typename T3, typename T4>
1565 EventId
1566 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1567 {
1568  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4));
1569 }
1570 
1571 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1572  typename T1, typename T2, typename T3, typename T4, typename T5>
1573 EventId
1574 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1575 {
1576  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5));
1577 }
1578 
1579 } // namespace ns3
1580 
1581 #endif /* SIMULATOR_H */
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:233
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:374
static EventId DoScheduleDestroy(EventImpl *event)
Implementation of the various ScheduleDestroy methods.
Definition: simulator.cc:280
static Ptr< SimulatorImpl > GetImplementation(void)
Get the SimulatorImpl singleton.
Definition: simulator.cc:400
static uint32_t GetSystemId(void)
Get the system id of this simulator.
Definition: simulator.cc:359
static uint32_t GetContext(void)
Get the current simulation context.
Definition: simulator.cc:353
ns3::ObjectFactory class declaration.
static void Run(void)
Run the simulation.
Definition: simulator.cc:201
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition: simulator.cc:321
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:719
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1238
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:264
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:165
double f(double x, void *params)
Definition: 80211b.c:60
static void Remove(const EventId &id)
Remove an event from the event list.
Definition: simulator.cc:311
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:331
Simulator()
Default constructor.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1401
static void SetScheduler(ObjectFactory schedulerFactory)
Set the scheduler type with an ObjectFactory.
Definition: simulator.cc:187
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:224
Flag for events not associated with any particular context.
Definition: simulator.h:192
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:1319
A simulation event.
Definition: event-impl.h:44
static EventId DoScheduleNow(EventImpl *event)
Implementation of the various ScheduleNow methods.
Definition: simulator.cc:272
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:209
static bool IsFinished(void)
Check if the simulation should finish.
Definition: simulator.cc:194
static EventId ScheduleDestroy(MEM mem_ptr, OBJ obj)
Schedule an event to expire when Simulator::Destroy is called.
Definition: simulator.h:1492
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:340
ns3::EventId declarations.
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:346
EventImpl * MakeEvent(void(*f)(void))
Make an EventImpl from a function pointer taking varying numbers of arguments.
Definition: make-event.cc:34