author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Tue, 26 Aug 2008 12:25:08 +0100 | |
changeset 3554 | 6d041a5be1db |
parent 3187 | 5ef944bee832 |
child 5521 | 37c6c83d4252 |
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 |
#ifndef EVENT_ID_H |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#define EVENT_ID_H |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include <stdint.h> |
1008
6f2ea723a1db
use a Ptr<> to manage EventImpl instances
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1005
diff
changeset
|
24 |
#include "ns3/ptr.h" |
6f2ea723a1db
use a Ptr<> to manage EventImpl instances
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1005
diff
changeset
|
25 |
#include "event-impl.h" |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
namespace ns3 { |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
class EventImpl; |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
70
fcd8da09ef75
document EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
31 |
/** |
3187 | 32 |
* \ingroup simulator |
70
fcd8da09ef75
document EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
33 |
* \brief an identifier for simulation events. |
3187 | 34 |
* |
35 |
* Each EventId identifies a unique event scheduled with one |
|
36 |
* of the many Simulator::Schedule methods. This EventId can |
|
37 |
* be used to Cancel or Remove events after they are scheduled |
|
38 |
* with Simulator::Cancel or Simulator::Remove. |
|
39 |
* |
|
40 |
* The important thing to remember about this class is that |
|
41 |
* every variable of this type is _always_ in a valid state, |
|
42 |
* even when it has not been assigned an EventId coming from a Schedule |
|
43 |
* method: calling Cancel, IsRunning, IsExpired or passing around |
|
44 |
* instances of this object will not result in crashes or memory leaks. |
|
70
fcd8da09ef75
document EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
54
diff
changeset
|
45 |
*/ |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
class EventId { |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
public: |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
48 |
EventId (); |
3187 | 49 |
// internal. |
1010
3a252ceeac44
more optimizations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1009
diff
changeset
|
50 |
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
|
51 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
52 |
* This method is syntactic sugar for the ns3::Simulator::cancel |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
53 |
* method. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
54 |
*/ |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
55 |
void Cancel (void); |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
56 |
/** |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
57 |
* This method is syntactic sugar for the ns3::Simulator::isExpired |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
58 |
* method. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
59 |
* \returns true if the event has expired, false otherwise. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
60 |
*/ |
981
eda90b17fc05
EvenId const fixes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
962
diff
changeset
|
61 |
bool IsExpired (void) const; |
3187 | 62 |
/** |
63 |
* This method is syntactic sugar for the ns3::Simulator::isExpired |
|
64 |
* method. |
|
65 |
* \returns true if the event has not expired, false otherwise. |
|
66 |
*/ |
|
981
eda90b17fc05
EvenId const fixes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
962
diff
changeset
|
67 |
bool IsRunning (void) const; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
68 |
public: |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
69 |
/* The following methods are semi-private |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
70 |
* they are supposed to be invoked only by |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
71 |
* subclasses of the Scheduler base class. |
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
72 |
*/ |
1009
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
73 |
EventImpl *PeekEventImpl (void) const; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
209
diff
changeset
|
74 |
uint64_t GetTs (void) const; |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
75 |
uint32_t GetUid (void) const; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
private: |
962
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
77 |
friend bool operator == (const EventId &a, const EventId &b); |
1008
6f2ea723a1db
use a Ptr<> to manage EventImpl instances
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1005
diff
changeset
|
78 |
Ptr<EventImpl> m_eventImpl; |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
209
diff
changeset
|
79 |
uint64_t m_ts; |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
80 |
uint32_t m_uid; |
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 |
|
962
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
|
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
}; // namespace ns3 |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
87 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
#endif /* EVENT_ID_H */ |