A Discrete-Event Network Simulator
API
event-id.cc
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#include "event-id.h"
21#include "simulator.h"
22#include "event-impl.h"
23#include "log.h"
24
31namespace ns3 {
32
33NS_LOG_COMPONENT_DEFINE ("EventId");
34
36 : m_eventImpl (0),
37 m_ts (0),
38 m_context (0),
39 m_uid (0)
40{
41 NS_LOG_FUNCTION (this);
42}
43
44EventId::EventId (const Ptr<EventImpl> &impl, uint64_t ts, uint32_t context, uint32_t uid)
45 : m_eventImpl (impl),
46 m_ts (ts),
47 m_context (context),
48 m_uid (uid)
49{
50 NS_LOG_FUNCTION (this << impl << ts << context << uid);
51}
52void
54{
55 NS_LOG_FUNCTION (this);
56 Simulator::Cancel (*this);
57}
58void
60{
61 NS_LOG_FUNCTION (this);
62 Simulator::Remove (*this);
63}
64bool
66{
67 NS_LOG_FUNCTION (this);
68 return Simulator::IsExpired (*this);
69}
70bool
72{
73 NS_LOG_FUNCTION (this);
74 return !IsExpired ();
75}
78{
79 NS_LOG_FUNCTION (this);
80 return PeekPointer (m_eventImpl);
81}
82uint64_t
83EventId::GetTs (void) const
84{
85 NS_LOG_FUNCTION (this);
86 return m_ts;
87}
90{
91 NS_LOG_FUNCTION (this);
92 return m_context;
93}
95EventId::GetUid (void) const
96{
97 NS_LOG_FUNCTION (this);
98 return m_uid;
99}
100
101
102} // namespace ns3
uint32_t GetContext(void) const
Definition: event-id.cc:89
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
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
EventImpl * PeekEventImpl(void) const
Definition: event-id.cc:77
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
uint32_t GetUid(void) const
Definition: event-id.cc:95
void Remove(void)
This method is syntactic sugar for the ns3::Simulator::Remove method.
Definition: event-id.cc:59
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
uint64_t GetTs(void) const
Definition: event-id.cc:83
EventId()
Default constructor.
Definition: event-id.cc:35
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:45
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
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:268
static bool IsExpired(const EventId &id)
Check if an event has already run or been cancelled.
Definition: simulator.cc:278
static void Remove(const EventId &id)
Remove an event from the event list.
Definition: simulator.cc:258
ns3::EventId declarations.
ns3::EventImpl declarations.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:415
ns3::Simulator declaration.