A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
event-id.h
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#ifndef EVENT_ID_H
20#define EVENT_ID_H
21
22#include "event-impl.h"
23#include "ptr.h"
24
25#include <stdint.h>
26
33namespace ns3
34{
35
36class EventImpl;
37
55{
56 public:
58 enum UID
59 {
63 NOW = 1,
69 VALID = 4
70 };
71
73 EventId();
82 EventId(const Ptr<EventImpl>& impl, uint64_t ts, uint32_t context, uint32_t uid);
87 void Cancel();
92 void Remove();
98 bool IsExpired() const;
104 bool IsRunning() const;
105
106 public:
114 EventImpl* PeekEventImpl() const;
116 uint64_t GetTs() const;
118 uint32_t GetContext() const;
120 uint32_t GetUid() const;
129 friend bool operator==(const EventId& a, const EventId& b);
136 friend bool operator!=(const EventId& a, const EventId& b);
143 friend bool operator<(const EventId& a, const EventId& b);
144
145 private:
147 uint64_t m_ts;
150};
151
152/*************************************************
153 ** Inline implementations
154 ************************************************/
155
156inline bool
157operator==(const EventId& a, const EventId& b)
158{
159 return a.m_uid == b.m_uid && a.m_context == b.m_context && a.m_ts == b.m_ts &&
161}
162
163inline bool
164operator!=(const EventId& a, const EventId& b)
165{
166 return !(a == b);
167}
168
169inline bool
170operator<(const EventId& a, const EventId& b)
171{
172 return (a.GetTs() < b.GetTs());
173}
174
175} // namespace ns3
176
177#endif /* EVENT_ID_H */
An identifier for simulation events.
Definition: event-id.h:55
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
UID
Special values of the event UID.
Definition: event-id.h:59
@ INVALID
Invalid UID value.
Definition: event-id.h:61
@ RESERVED
Reserved UID.
Definition: event-id.h:67
@ VALID
Schedule(), etc.
Definition: event-id.h:69
@ DESTROY
ScheduleDestroy() events.
Definition: event-id.h:65
@ NOW
ScheduleNow() events.
Definition: event-id.h:63
friend bool operator!=(const EventId &a, const EventId &b)
Test if two EventId's are not equal.
Definition: event-id.h:164
friend bool operator<(const EventId &a, const EventId &b)
Less than operator for two EventId's, based on time stamps.
Definition: event-id.h:170
EventImpl * PeekEventImpl() const
Definition: event-id.cc:83
friend bool operator==(const EventId &a, const EventId &b)
Test if two EventId's are equal.
Definition: event-id.h:157
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
ns3::EventImpl declarations.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition: callback.h:676
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170
ns3::Ptr smart pointer declaration and implementation.