A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
event-id.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#include "event-id.h"
20
21#include "event-impl.h"
22#include "log.h"
23#include "simulator.h"
24
31namespace ns3
32{
33
35
37 : m_eventImpl(nullptr),
38 m_ts(0),
39 m_context(0),
40 m_uid(0)
41{
42 NS_LOG_FUNCTION(this);
43}
44
45EventId::EventId(const Ptr<EventImpl>& impl, uint64_t ts, uint32_t context, uint32_t uid)
46 : m_eventImpl(impl),
47 m_ts(ts),
48 m_context(context),
49 m_uid(uid)
50{
51 NS_LOG_FUNCTION(this << impl << ts << context << uid);
52}
53
54void
56{
57 NS_LOG_FUNCTION(this);
58 Simulator::Cancel(*this);
59}
60
61void
63{
64 NS_LOG_FUNCTION(this);
65 Simulator::Remove(*this);
66}
67
68bool
70{
71 NS_LOG_FUNCTION(this);
72 return Simulator::IsExpired(*this);
73}
74
75bool
77{
78 NS_LOG_FUNCTION(this);
79 return !IsExpired();
80}
81
84{
85 NS_LOG_FUNCTION(this);
87}
88
89uint64_t
91{
92 NS_LOG_FUNCTION(this);
93 return m_ts;
94}
95
98{
99 NS_LOG_FUNCTION(this);
100 return m_context;
101}
102
105{
106 NS_LOG_FUNCTION(this);
107 return m_uid;
108}
109
110} // namespace ns3
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
uint32_t GetUid() const
Definition: event-id.cc:104
EventImpl * PeekEventImpl() const
Definition: event-id.cc:83
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:69
uint64_t m_ts
The virtual time stamp.
Definition: event-id.h:147
uint32_t m_uid
The unique id.
Definition: event-id.h:149
void Remove()
This method is syntactic sugar for the ns3::Simulator::Remove method.
Definition: event-id.cc:62
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:76
uint32_t GetContext() const
Definition: event-id.cc:97
uint64_t GetTs() const
Definition: event-id.cc:90
EventId()
Default constructor.
Definition: event-id.cc:36
uint32_t m_context
The context.
Definition: event-id.h:148
Ptr< EventImpl > m_eventImpl
The underlying event implementation.
Definition: event-id.h:146
A simulation event.
Definition: event-impl.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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:276
static bool IsExpired(const EventId &id)
Check if an event has already run or been cancelled.
Definition: simulator.cc:286
static void Remove(const EventId &id)
Remove an event from the event list.
Definition: simulator.cc:266
ns3::EventId declarations.
ns3::EventImpl declarations.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Debug message logging.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:488
ns3::Simulator declaration.