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 
31 namespace ns3 {
32 
33 NS_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 
44 EventId::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 }
52 void
54 {
55  NS_LOG_FUNCTION (this);
56  Simulator::Cancel (*this);
57 }
58 void
60 {
61  NS_LOG_FUNCTION (this);
62  Simulator::Remove (*this);
63 }
64 bool
65 EventId::IsExpired (void) const
66 {
67  NS_LOG_FUNCTION (this);
68  return Simulator::IsExpired (*this);
69 }
70 bool
71 EventId::IsRunning (void) const
72 {
73  NS_LOG_FUNCTION (this);
74  return !IsExpired ();
75 }
76 EventImpl *
78 {
79  NS_LOG_FUNCTION (this);
80  return PeekPointer (m_eventImpl);
81 }
82 uint64_t
83 EventId::GetTs (void) const
84 {
85  NS_LOG_FUNCTION (this);
86  return m_ts;
87 }
88 uint32_t
89 EventId::GetContext (void) const
90 {
91  NS_LOG_FUNCTION (this);
92  return m_context;
93 }
94 uint32_t
95 EventId::GetUid (void) const
96 {
97  NS_LOG_FUNCTION (this);
98  return m_uid;
99 }
100 
101 
102 } // namespace ns3
uint32_t m_uid
The unique id.
Definition: event-id.h:133
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
ns3::EventImpl declarations.
uint64_t m_ts
The virtual time stamp.
Definition: event-id.h:131
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:411
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event&#39;s associated function will not be invoked when it expires...
Definition: simulator.cc:268
ns3::Simulator declaration.
void Remove(void)
This method is syntactic sugar for the ns3::Simulator::Remove method.
Definition: event-id.cc:59
EventImpl * PeekEventImpl(void) const
Definition: event-id.cc:77
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
EventId()
Default constructor.
Definition: event-id.cc:35
Ptr< EventImpl > m_eventImpl
The underlying event implementation.
Definition: event-id.h:130
uint64_t GetTs(void) const
Definition: event-id.cc:83
static void Remove(const EventId &id)
Remove an event from the event list.
Definition: simulator.cc:258
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static bool IsExpired(const EventId &id)
Check if an event has already run or been cancelled.
Definition: simulator.cc:278
uint32_t GetUid(void) const
Definition: event-id.cc:95
uint32_t GetContext(void) const
Definition: event-id.cc:89
A simulation event.
Definition: event-impl.h:44
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
Debug message logging.
ns3::EventId declarations.
uint32_t m_context
The context.
Definition: event-id.h:132