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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#include "event-id.h"
9
10#include "event-impl.h"
11#include "log.h"
12#include "simulator.h"
13
14/**
15 * \file
16 * \ingroup events
17 * ns3::EventId implementation.
18 */
19
20namespace ns3
21{
22
24
26 : m_eventImpl(nullptr),
27 m_ts(0),
28 m_context(0),
29 m_uid(0)
30{
31 NS_LOG_FUNCTION(this);
32}
33
34EventId::EventId(const Ptr<EventImpl>& impl, uint64_t ts, uint32_t context, uint32_t uid)
35 : m_eventImpl(impl),
36 m_ts(ts),
37 m_context(context),
38 m_uid(uid)
39{
40 NS_LOG_FUNCTION(this << impl << ts << context << uid);
41}
42
43void
45{
46 NS_LOG_FUNCTION(this);
47 Simulator::Cancel(*this);
48}
49
50void
52{
53 NS_LOG_FUNCTION(this);
54 Simulator::Remove(*this);
55}
56
57bool
59{
60 NS_LOG_FUNCTION(this);
61 return Simulator::IsExpired(*this);
62}
63
64bool
66{
67 NS_LOG_FUNCTION(this);
68 return !IsExpired();
69}
70
71bool
73{
74 return IsPending();
75}
76
79{
80 NS_LOG_FUNCTION(this);
82}
83
84uint64_t
86{
87 NS_LOG_FUNCTION(this);
88 return m_ts;
89}
90
93{
94 NS_LOG_FUNCTION(this);
95 return m_context;
96}
97
100{
101 NS_LOG_FUNCTION(this);
102 return m_uid;
103}
104
105} // namespace ns3
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition event-id.cc:44
uint32_t GetUid() const
Definition event-id.cc:99
bool IsPending() const
This method is syntactic sugar for !IsExpired().
Definition event-id.cc:65
EventImpl * PeekEventImpl() const
Definition event-id.cc:78
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition event-id.cc:58
uint64_t m_ts
The virtual time stamp.
Definition event-id.h:145
uint32_t m_uid
The unique id.
Definition event-id.h:147
void Remove()
This method is syntactic sugar for the ns3::Simulator::Remove method.
Definition event-id.cc:51
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Definition event-id.cc:72
uint32_t GetContext() const
Definition event-id.cc:92
uint64_t GetTs() const
Definition event-id.cc:85
EventId()
Default constructor.
Definition event-id.cc:25
uint32_t m_context
The context.
Definition event-id.h:146
Ptr< EventImpl > m_eventImpl
The underlying event implementation.
Definition event-id.h:144
A simulation event.
Definition event-impl.h:35
Smart pointer class similar to boost::intrusive_ptr.
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:274
static bool IsExpired(const EventId &id)
Check if an event has already run or been cancelled.
Definition simulator.cc:284
static void Remove(const EventId &id)
Remove an event from the event list.
Definition simulator.cc:264
ns3::EventId declarations.
ns3::EventImpl declarations.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:443
ns3::Simulator declaration.