22 #include "ns3/simulator.h"
23 #include "ns3/nstime.h"
24 #include "ns3/command-line.h"
25 #include "ns3/double.h"
26 #include "ns3/random-variable-stream.h"
52 void HandleEvent (
double eventValue);
59 &MyModel::HandleEvent,
63 MyModel::HandleEvent (
double value)
65 std::cout <<
"Member method received event at "
67 <<
"s started at " << value <<
"s" << std::endl;
78 std::cout <<
"ExampleFunction received event at "
89 std::cout <<
"RandomFunction received event at "
97 std::cout <<
"I should never be called... " << std::endl;
103 int main (
int argc,
char *argv[])
106 cmd.Parse (argc, argv);
123 std::cout <<
"Code within a lambda expression at time "
Simple model object to illustrate event handling.
void Start(void)
Start model execution by scheduling a HandleEvent.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
An identifier for simulation events.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
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...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Run(void)
Run the simulation.
static Time Now(void)
Return the current simulation virtual time.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void RandomFunction(void)
Simple function event handler; this function is called randomly.
static void ExampleFunction(MyModel *model)
Simple function event handler which Starts a MyModel object.
static void CancelledEvent(void)
Simple function event handler; the corresponding event is cancelled.
Every class exported by the ns3 library is enclosed in the ns3 namespace.