author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Fri, 11 Jul 2008 18:39:19 +0100 | |
changeset 3416 | 926ccb845111 |
parent 1696 | 0de65f4c8c43 |
permissions | -rw-r--r-- |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#include "event-id.h" |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#include "simulator.h" |
472
41aa5fca4f49
make sure that Simulator::Cancel deals correctly with events which were already scheduled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
22 |
#include "event-impl.h" |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
namespace ns3 { |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
EventId::EventId () |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
27 |
: m_eventImpl (0), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
28 |
m_ts (0), |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
29 |
m_uid (0) |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
{} |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
31 |
|
1010
3a252ceeac44
more optimizations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1009
diff
changeset
|
32 |
EventId::EventId (const Ptr<EventImpl> &impl, uint64_t ts, uint32_t uid) |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
33 |
: m_eventImpl (impl), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
34 |
m_ts (ts), |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
35 |
m_uid (uid) |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
{} |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
void |
122
6b8f1eda5c57
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
110
diff
changeset
|
38 |
EventId::Cancel (void) |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
{ |
1008
6f2ea723a1db
use a Ptr<> to manage EventImpl instances
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1005
diff
changeset
|
40 |
Simulator::Cancel (*this); |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
} |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
bool |
981
eda90b17fc05
EvenId const fixes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
962
diff
changeset
|
43 |
EventId::IsExpired (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
{ |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
45 |
return Simulator::IsExpired (*this); |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
} |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
47 |
bool |
981
eda90b17fc05
EvenId const fixes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
962
diff
changeset
|
48 |
EventId::IsRunning (void) const |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
49 |
{ |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
50 |
return !IsExpired (); |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
51 |
} |
1009
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
52 |
EventImpl * |
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
53 |
EventId::PeekEventImpl (void) const |
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
54 |
{ |
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
55 |
return PeekPointer (m_eventImpl); |
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
56 |
} |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
uint64_t |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
58 |
EventId::GetTs (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
{ |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
60 |
return m_ts; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
61 |
} |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
uint32_t |
122
6b8f1eda5c57
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
110
diff
changeset
|
63 |
EventId::GetUid (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
{ |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
65 |
return m_uid; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
} |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
|
962
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
68 |
bool operator == (const EventId &a, const EventId &b) |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
69 |
{ |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
70 |
return |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
71 |
a.m_uid == b.m_uid && |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
72 |
a.m_ts == b.m_ts && |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
73 |
a.m_eventImpl == b.m_eventImpl; |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
74 |
} |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
75 |
bool operator != (const EventId &a, const EventId &b) |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
76 |
{ |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
77 |
return !(a == b); |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
78 |
} |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
79 |
|
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
80 |
|
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
82 |
}; // namespace ns3 |