A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
event-impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef EVENT_IMPL_H
9#define EVENT_IMPL_H
10
11#include "simple-ref-count.h"
12
13#include <stdint.h>
14
15/**
16 * \file
17 * \ingroup events
18 * ns3::EventImpl declarations.
19 */
20
21namespace ns3
22{
23
24/**
25 * \ingroup events
26 * \brief A simulation event.
27 *
28 * Each subclass of this base class represents a simulation event. The
29 * Invoke() method will be called by the simulation engine
30 * when it reaches the time associated to this event. Most subclasses
31 * are usually created by one of the many Simulator::Schedule
32 * methods.
33 */
34class EventImpl : public SimpleRefCount<EventImpl>
35{
36 public:
37 /** Default constructor. */
38 EventImpl();
39 /** Destructor. */
40 virtual ~EventImpl() = 0;
41 /**
42 * Called by the simulation engine to notify the event that it is time
43 * to execute.
44 */
45 void Invoke();
46 /**
47 * Marks the event as 'canceled'. The event is not removed from
48 * the event list but the simulation engine will check its canceled status
49 * before calling Invoke().
50 */
51 void Cancel();
52 /**
53 * \returns true if the event has been canceled.
54 *
55 * Checked by the simulation engine before calling Invoke().
56 */
57 bool IsCancelled();
58
59 protected:
60 /**
61 * Implementation for Invoke().
62 *
63 * This typically calls a method or function pointer with the
64 * arguments bound by a call to one of the MakeEvent() functions.
65 */
66 virtual void Notify() = 0;
67
68 private:
69 bool m_cancel; /**< Has this event been cancelled. */
70};
71
72} // namespace ns3
73
74#endif /* EVENT_IMPL_H */
A simulation event.
Definition event-impl.h:35
EventImpl()
Default constructor.
Definition event-impl.cc:29
void Invoke()
Called by the simulation engine to notify the event that it is time to execute.
Definition event-impl.cc:36
virtual void Notify()=0
Implementation for Invoke().
void Cancel()
Marks the event as 'canceled'.
Definition event-impl.cc:46
virtual ~EventImpl()=0
Destructor.
Definition event-impl.cc:24
bool m_cancel
Has this event been cancelled.
Definition event-impl.h:69
bool IsCancelled()
Definition event-impl.cc:53
A template-based reference counting class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SimpleRefCount declaration and template implementation.