A Discrete-Event Network Simulator
API
event-id.h
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 #ifndef EVENT_ID_H
21 #define EVENT_ID_H
22 
23 #include <stdint.h>
24 #include "ptr.h"
25 #include "event-impl.h"
26 
33 namespace ns3 {
34 
35 class EventImpl;
36 
53 class EventId {
54 public:
56  EventId ();
65  EventId (const Ptr<EventImpl> &impl, uint64_t ts, uint32_t context, uint32_t uid);
70  void Cancel (void);
76  bool IsExpired (void) const;
82  bool IsRunning (void) const;
83 public:
91  EventImpl *PeekEventImpl (void) const;
93  uint64_t GetTs (void) const;
95  uint32_t GetContext (void) const;
97  uint32_t GetUid (void) const;
106  friend bool operator == (const EventId &a, const EventId &b);
113  friend bool operator != (const EventId &a, const EventId &b);
120  friend bool operator < (const EventId &a, const EventId &b);
121 
122 private:
124  uint64_t m_ts;
125  uint32_t m_context;
126  uint32_t m_uid;
127 };
128 
129 /*************************************************
130  ** Inline implementations
131  ************************************************/
132 
133 inline
134 bool
135 operator == (const EventId &a, const EventId &b)
136 {
137  return
138  a.m_uid == b.m_uid &&
139  a.m_context == b.m_context &&
140  a.m_ts == b.m_ts &&
141  a.m_eventImpl == b.m_eventImpl;
142 }
143 
144 inline
145 bool
146 operator != (const EventId &a, const EventId &b)
147 {
148  return !(a == b);
149 }
150 
151 inline
152 bool
153 operator < (const EventId &a, const EventId &b)
154 {
155  return (a.GetTs () < b.GetTs ());
156 }
157 
158 } // namespace ns3
159 
160 #endif /* EVENT_ID_H */
uint32_t m_uid
The unique id.
Definition: event-id.h:126
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
ns3::EventImpl declarations.
uint64_t m_ts
The virtual time stamp.
Definition: event-id.h:124
ns3::Ptr smart pointer declaration and implementation.
EventImpl * PeekEventImpl(void) const
Definition: event-id.cc:71
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:153
EventId()
Default constructor.
Definition: event-id.cc:35
Ptr< EventImpl > m_eventImpl
The underlying event implementation.
Definition: event-id.h:123
friend bool operator!=(const EventId &a, const EventId &b)
Test if two EventId&#39;s are not equal.
Definition: event-id.h:146
uint64_t GetTs(void) const
Definition: event-id.cc:77
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition: callback.h:1471
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetUid(void) const
Definition: event-id.cc:89
uint32_t GetContext(void) const
Definition: event-id.cc:83
A simulation event.
Definition: event-impl.h:44
An identifier for simulation events.
Definition: event-id.h:53
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:135
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
friend bool operator<(const EventId &a, const EventId &b)
Less than operator for two EventId&#39;s, based on time stamps.
Definition: event-id.h:153
friend bool operator==(const EventId &a, const EventId &b)
Test if two EventId&#39;s are equal.
Definition: event-id.h:135
uint32_t m_context
The context.
Definition: event-id.h:125