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 
70 class Simulator
71 {
72 public:
85  static void SetImplementation (Ptr<SimulatorImpl> impl);
86 
105 
114  static void SetScheduler (ObjectFactory schedulerFactory);
115 
125  static void Destroy (void);
126 
136  static bool IsFinished (void);
137 
148  static void Run (void);
149 
158  static void Stop (void);
159 
169  static void Stop (Time const &delay);
170 
191  template <typename MEM, typename OBJ>
192  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj);
193 
205  template <typename MEM, typename OBJ, typename T1>
206  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
207 
221  template <typename MEM, typename OBJ, typename T1, typename T2>
222  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
223 
239  template <typename MEM, typename OBJ,
240  typename T1, typename T2, typename T3>
241  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
242 
260  template <typename MEM, typename OBJ,
261  typename T1, typename T2, typename T3, typename T4>
262  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
263 
283  template <typename MEM, typename OBJ,
284  typename T1, typename T2, typename T3, typename T4, typename T5>
285  static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
286  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
296  static EventId Schedule (Time const &delay, void (*f)(void));
297 
307  template <typename U1, typename T1>
308  static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1);
309 
322  template <typename U1, typename U2,
323  typename T1, typename T2>
324  static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
325 
341  template <typename U1, typename U2, typename U3,
342  typename T1, typename T2, typename T3>
343  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
344 
363  template <typename U1, typename U2, typename U3, typename U4,
364  typename T1, typename T2, typename T3, typename T4>
365  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
366 
388  template <typename U1, typename U2, typename U3, typename U4, typename U5,
389  typename T1, typename T2, typename T3, typename T4, typename T5>
390  static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
391 
413  template <typename MEM, typename OBJ>
414  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj);
415 
427  template <typename MEM, typename OBJ, typename T1>
428  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
429 
443  template <typename MEM, typename OBJ, typename T1, typename T2>
444  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
445 
461  template <typename MEM, typename OBJ,
462  typename T1, typename T2, typename T3>
463  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
464 
482  template <typename MEM, typename OBJ,
483  typename T1, typename T2, typename T3, typename T4>
484  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
485 
505  template <typename MEM, typename OBJ,
506  typename T1, typename T2, typename T3, typename T4, typename T5>
507  static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
508  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
520  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void));
521 
531  template <typename U1,
532  typename T1>
533  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1);
534 
547  template <typename U1, typename U2,
548  typename T1, typename T2>
549  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
550 
566  template <typename U1, typename U2, typename U3,
567  typename T1, typename T2, typename T3>
568  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
569 
588  template <typename U1, typename U2, typename U3, typename U4,
589  typename T1, typename T2, typename T3, typename T4>
590  static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
591 
613  template <typename U1, typename U2, typename U3, typename U4, typename U5,
614  typename T1, typename T2, typename T3, typename T4, typename T5>
615  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);
616 
634  template <typename MEM, typename OBJ>
635  static EventId ScheduleNow (MEM mem_ptr, OBJ obj);
636 
647  template <typename MEM, typename OBJ,
648  typename T1>
649  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1);
650 
663  template <typename MEM, typename OBJ,
664  typename T1, typename T2>
665  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
666 
681  template <typename MEM, typename OBJ,
682  typename T1, typename T2, typename T3>
683  static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
684 
701  template <typename MEM, typename OBJ,
702  typename T1, typename T2, typename T3, typename T4>
703  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
704  T1 a1, T2 a2, T3 a3, T4 a4);
723  template <typename MEM, typename OBJ,
724  typename T1, typename T2, typename T3, typename T4, typename T5>
725  static EventId ScheduleNow (MEM mem_ptr, OBJ obj,
726  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
735  static EventId ScheduleNow (void (*f)(void));
736 
745  template <typename U1,
746  typename T1>
747  static EventId ScheduleNow (void (*f)(U1), T1 a1);
748 
760  template <typename U1, typename U2,
761  typename T1, typename T2>
762  static EventId ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2);
763 
778  template <typename U1, typename U2, typename U3,
779  typename T1, typename T2, typename T3>
780  static EventId ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
781 
799  template <typename U1, typename U2, typename U3, typename U4,
800  typename T1, typename T2, typename T3, typename T4>
801  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
802 
823  template <typename U1, typename U2, typename U3, typename U4, typename U5,
824  typename T1, typename T2, typename T3, typename T4, typename T5>
825  static EventId ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
826 
845  template <typename MEM, typename OBJ>
846  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj);
847 
858  template <typename MEM, typename OBJ,
859  typename T1>
860  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1);
861 
874  template <typename MEM, typename OBJ,
875  typename T1, typename T2>
876  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
877 
892  template <typename MEM, typename OBJ,
893  typename T1, typename T2, typename T3>
894  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
895 
912  template <typename MEM, typename OBJ,
913  typename T1, typename T2, typename T3, typename T4>
914  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
915  T1 a1, T2 a2, T3 a3, T4 a4);
934  template <typename MEM, typename OBJ,
935  typename T1, typename T2, typename T3, typename T4, typename T5>
936  static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj,
937  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
945  static EventId ScheduleDestroy (void (*f)(void));
946 
955  template <typename U1,
956  typename T1>
957  static EventId ScheduleDestroy (void (*f)(U1), T1 a1);
958 
970  template <typename U1, typename U2,
971  typename T1, typename T2>
972  static EventId ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2);
973 
988  template <typename U1, typename U2, typename U3,
989  typename T1, typename T2, typename T3>
990  static EventId ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
991 
1009  template <typename U1, typename U2, typename U3, typename U4,
1010  typename T1, typename T2, typename T3, typename T4>
1011  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
1012 
1033  template <typename U1, typename U2, typename U3, typename U4, typename U5,
1034  typename T1, typename T2, typename T3, typename T4, typename T5>
1035  static EventId ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
1036 
1051  static void Remove (const EventId &id);
1052 
1066  static void Cancel (const EventId &id);
1067 
1082  static bool IsExpired (const EventId &id);
1083 
1089  static Time Now (void);
1090 
1099  static Time GetDelayLeft (const EventId &id);
1100 
1109  static Time GetMaximumSimulationTime (void);
1110 
1116  static uint32_t GetContext (void);
1117 
1125  static EventId Schedule (Time const &delay, const Ptr<EventImpl> &event);
1126 
1136  static void ScheduleWithContext (uint32_t context, const Time &delay, EventImpl *event);
1137 
1145  static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
1146 
1153  static EventId ScheduleNow (const Ptr<EventImpl> &event);
1154 
1162  static uint32_t GetSystemId (void);
1163 
1164 private:
1166  Simulator ();
1168  ~Simulator ();
1169 
1176  static EventId DoSchedule (Time const &delay, EventImpl *event);
1182  static EventId DoScheduleNow (EventImpl *event);
1188  static EventId DoScheduleDestroy (EventImpl *event);
1189 };
1190 
1204 Time Now (void);
1205 
1206 } // namespace ns3
1207 
1208 
1209 /********************************************************************
1210  * Implementation of the templates declared above.
1211  ********************************************************************/
1212 
1213 namespace ns3 {
1214 
1215 template <typename MEM, typename OBJ>
1216 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj)
1217 {
1218  return DoSchedule (delay, MakeEvent (mem_ptr, obj));
1219 }
1220 
1221 
1222 template <typename MEM, typename OBJ,
1223  typename T1>
1224 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1225 {
1226  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1));
1227 }
1228 
1229 template <typename MEM, typename OBJ,
1230  typename T1, typename T2>
1231 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1232 {
1233  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2));
1234 }
1235 
1236 template <typename MEM, typename OBJ,
1237  typename T1, typename T2, typename T3>
1238 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1239 {
1240  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1241 }
1242 
1243 template <typename MEM, typename OBJ,
1244  typename T1, typename T2, typename T3, typename T4>
1245 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1246 {
1247  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1248 }
1249 
1250 template <typename MEM, typename OBJ,
1251  typename T1, typename T2, typename T3, typename T4, typename T5>
1252 EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
1253  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1254 {
1255  return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1256 }
1257 
1258 template <typename U1,
1259  typename T1>
1260 EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1)
1261 {
1262  return DoSchedule (delay, MakeEvent (f, a1));
1263 }
1264 
1265 template <typename U1, typename U2,
1266  typename T1, typename T2>
1267 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1268 {
1269  return DoSchedule (delay, MakeEvent (f, a1, a2));
1270 }
1271 
1272 template <typename U1, typename U2, typename U3,
1273  typename T1, typename T2, typename T3>
1274 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1275 {
1276  return DoSchedule (delay, MakeEvent (f, a1, a2, a3));
1277 }
1278 
1279 template <typename U1, typename U2, typename U3, typename U4,
1280  typename T1, typename T2, typename T3, typename T4>
1281 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1282 {
1283  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4));
1284 }
1285 
1286 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1287  typename T1, typename T2, typename T3, typename T4, typename T5>
1288 EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1289 {
1290  return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4, a5));
1291 }
1292 
1293 
1294 
1295 
1296 template <typename MEM, typename OBJ>
1297 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
1298 {
1299  ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj));
1300 }
1301 
1302 
1303 template <typename MEM, typename OBJ,
1304  typename T1>
1305 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
1306 {
1307  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1));
1308 }
1309 
1310 template <typename MEM, typename OBJ,
1311  typename T1, typename T2>
1312 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1313 {
1314  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2));
1315 }
1316 
1317 template <typename MEM, typename OBJ,
1318  typename T1, typename T2, typename T3>
1319 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1320 {
1321  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
1322 }
1323 
1324 template <typename MEM, typename OBJ,
1325  typename T1, typename T2, typename T3, typename T4>
1326 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1327 {
1328  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1329 }
1330 
1331 template <typename MEM, typename OBJ,
1332  typename T1, typename T2, typename T3, typename T4, typename T5>
1333 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
1334  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1335 {
1336  return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1337 }
1338 
1339 template <typename U1,
1340  typename T1>
1341 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1)
1342 {
1343  return ScheduleWithContext (context, delay, MakeEvent (f, a1));
1344 }
1345 
1346 template <typename U1, typename U2,
1347  typename T1, typename T2>
1348 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
1349 {
1350  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2));
1351 }
1352 
1353 template <typename U1, typename U2, typename U3,
1354  typename T1, typename T2, typename T3>
1355 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1356 {
1357  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3));
1358 }
1359 
1360 template <typename U1, typename U2, typename U3, typename U4,
1361  typename T1, typename T2, typename T3, typename T4>
1362 void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1363 {
1364  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4));
1365 }
1366 
1367 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1368  typename T1, typename T2, typename T3, typename T4, typename T5>
1369 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)
1370 {
1371  return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4, a5));
1372 }
1373 
1374 
1375 
1376 
1377 template <typename MEM, typename OBJ>
1378 EventId
1379 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj)
1380 {
1381  return DoScheduleNow (MakeEvent (mem_ptr, obj));
1382 }
1383 
1384 
1385 template <typename MEM, typename OBJ,
1386  typename T1>
1387 EventId
1388 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1)
1389 {
1390  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1));
1391 }
1392 
1393 template <typename MEM, typename OBJ,
1394  typename T1, typename T2>
1395 EventId
1396 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1397 {
1398  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2));
1399 }
1400 
1401 template <typename MEM, typename OBJ,
1402  typename T1, typename T2, typename T3>
1403 EventId
1404 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1405 {
1406  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3));
1407 }
1408 
1409 template <typename MEM, typename OBJ,
1410  typename T1, typename T2, typename T3, typename T4>
1411 EventId
1412 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1413 {
1414  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1415 }
1416 
1417 template <typename MEM, typename OBJ,
1418  typename T1, typename T2, typename T3, typename T4, typename T5>
1419 EventId
1420 Simulator::ScheduleNow (MEM mem_ptr, OBJ obj,
1421  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1422 {
1423  return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1424 }
1425 
1426 template <typename U1,
1427  typename T1>
1428 EventId
1429 Simulator::ScheduleNow (void (*f)(U1), T1 a1)
1430 {
1431  return DoScheduleNow (MakeEvent (f, a1));
1432 }
1433 
1434 template <typename U1, typename U2,
1435  typename T1, typename T2>
1436 EventId
1437 Simulator::ScheduleNow (void (*f)(U1,U2), T1 a1, T2 a2)
1438 {
1439  return DoScheduleNow (MakeEvent (f, a1, a2));
1440 }
1441 
1442 template <typename U1, typename U2, typename U3,
1443  typename T1, typename T2, typename T3>
1444 EventId
1445 Simulator::ScheduleNow (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1446 {
1447  return DoScheduleNow (MakeEvent (f, a1, a2, a3));
1448 }
1449 
1450 template <typename U1, typename U2, typename U3, typename U4,
1451  typename T1, typename T2, typename T3, typename T4>
1452 EventId
1453 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1454 {
1455  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4));
1456 }
1457 
1458 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1459  typename T1, typename T2, typename T3, typename T4, typename T5>
1460 EventId
1461 Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1462 {
1463  return DoScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5));
1464 }
1465 
1466 
1467 
1468 template <typename MEM, typename OBJ>
1469 EventId
1470 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj)
1471 {
1472  return DoScheduleDestroy (MakeEvent (mem_ptr, obj));
1473 }
1474 
1475 
1476 template <typename MEM, typename OBJ,
1477  typename T1>
1478 EventId
1479 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1)
1480 {
1481  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1));
1482 }
1483 
1484 template <typename MEM, typename OBJ,
1485  typename T1, typename T2>
1486 EventId
1487 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
1488 {
1489  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2));
1490 }
1491 
1492 template <typename MEM, typename OBJ,
1493  typename T1, typename T2, typename T3>
1494 EventId
1495 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
1496 {
1497  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3));
1498 }
1499 
1500 template <typename MEM, typename OBJ,
1501  typename T1, typename T2, typename T3, typename T4>
1502 EventId
1503 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
1504 {
1505  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
1506 }
1507 
1508 template <typename MEM, typename OBJ,
1509  typename T1, typename T2, typename T3, typename T4, typename T5>
1510 EventId
1511 Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj,
1512  T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1513 {
1514  return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
1515 }
1516 
1517 template <typename U1,
1518  typename T1>
1519 EventId
1520 Simulator::ScheduleDestroy (void (*f)(U1), T1 a1)
1521 {
1522  return DoScheduleDestroy (MakeEvent (f, a1));
1523 }
1524 
1525 template <typename U1, typename U2,
1526  typename T1, typename T2>
1527 EventId
1528 Simulator::ScheduleDestroy (void (*f)(U1,U2), T1 a1, T2 a2)
1529 {
1530  return DoScheduleDestroy (MakeEvent (f, a1, a2));
1531 }
1532 
1533 template <typename U1, typename U2, typename U3,
1534  typename T1, typename T2, typename T3>
1535 EventId
1536 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
1537 {
1538  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3));
1539 }
1540 
1541 template <typename U1, typename U2, typename U3, typename U4,
1542  typename T1, typename T2, typename T3, typename T4>
1543 EventId
1544 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
1545 {
1546  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4));
1547 }
1548 
1549 template <typename U1, typename U2, typename U3, typename U4, typename U5,
1550  typename T1, typename T2, typename T3, typename T4, typename T5>
1551 EventId
1552 Simulator::ScheduleDestroy (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
1553 {
1554  return DoScheduleDestroy (MakeEvent (f, a1, a2, a3, a4, a5));
1555 }
1556 
1557 } // namespace ns3
1558 
1559 #endif /* SIMULATOR_H */
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:232
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:70
ns3::EventImpl declarations.
static void SetImplementation(Ptr< SimulatorImpl > impl)
Definition: simulator.cc:364
static EventId DoScheduleDestroy(EventImpl *event)
Implementation of the various ScheduleDestroy methods.
Definition: simulator.cc:270
static Ptr< SimulatorImpl > GetImplementation(void)
Get the SimulatorImpl singleton.
Definition: simulator.cc:390
static uint32_t GetSystemId(void)
Get the system id of this simulator.
Definition: simulator.cc:349
static uint32_t GetContext(void)
Get the current simulation context.
Definition: simulator.cc:343
ns3::ObjectFactory class declaration.
static void Run(void)
Run the simulation.
Definition: simulator.cc:200
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:311
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1216
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:260
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:164
static void Remove(const EventId &id)
Remove an event from the event list.
Definition: simulator.cc:301
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:321
Simulator()
Default constructor.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1379
static void SetScheduler(ObjectFactory schedulerFactory)
Set the scheduler type with an ObjectFactory.
Definition: simulator.cc:186
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
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:1297
A simulation event.
Definition: event-impl.h:44
static EventId DoScheduleNow(EventImpl *event)
Implementation of the various ScheduleNow methods.
Definition: simulator.cc:265
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:208
static bool IsFinished(void)
Check if the simulation should finish.
Definition: simulator.cc:193
static EventId ScheduleDestroy(MEM mem_ptr, OBJ obj)
Schedule an event to expire when Simulator::Destroy is called.
Definition: simulator.h:1470
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:330
ns3::EventId declarations.
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:336
EventImpl * MakeEvent(void(*f)(void))
Make an EventImpl from a function pointer taking varying numbers of arguments.
Definition: make-event.cc:34