A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
watchdog.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 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 WATCHDOG_H
21
#define WATCHDOG_H
22
23
#include "
nstime.h
"
24
#include "
event-id.h
"
25
26
namespace
ns3 {
27
28
class
TimerImpl;
29
37
class
Watchdog
38
{
39
public
:
40
Watchdog
();
41
~Watchdog
();
42
50
void
Ping
(
Time
delay);
51
57
template
<
typename
FN>
58
void
SetFunction
(FN fn);
59
66
template
<
typename
MEM_PTR,
typename
OBJ_PTR>
67
void
SetFunction
(MEM_PTR memPtr, OBJ_PTR objPtr);
68
69
75
template
<
typename
T1>
76
void
SetArguments
(T1 a1);
83
template
<
typename
T1,
typename
T2>
84
void
SetArguments
(T1 a1, T2 a2);
92
template
<
typename
T1,
typename
T2,
typename
T3>
93
void
SetArguments
(T1 a1, T2 a2, T3 a3);
102
template
<
typename
T1,
typename
T2,
typename
T3,
typename
T4>
103
void
SetArguments
(T1 a1, T2 a2, T3 a3, T4 a4);
113
template
<
typename
T1,
typename
T2,
typename
T3,
typename
T4,
typename
T5>
114
void
SetArguments
(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
125
template
<
typename
T1,
typename
T2,
typename
T3,
typename
T4,
typename
T5,
typename
T6>
126
void
SetArguments
(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
127
128
private
:
129
void
Expire
(
void
);
130
TimerImpl
*
m_impl
;
131
EventId
m_event
;
132
Time
m_end
;
133
};
134
135
}
// namespace ns3
136
137
#include "
timer-impl.h
"
138
139
namespace
ns3 {
140
141
142
template
<
typename
FN>
143
void
144
Watchdog::SetFunction
(FN fn)
145
{
146
delete
m_impl
;
147
m_impl
=
MakeTimerImpl
(fn);
148
}
149
template
<
typename
MEM_PTR,
typename
OBJ_PTR>
150
void
151
Watchdog::SetFunction
(MEM_PTR memPtr, OBJ_PTR objPtr)
152
{
153
delete
m_impl
;
154
m_impl
=
MakeTimerImpl
(memPtr, objPtr);
155
}
156
157
template
<
typename
T1>
158
void
159
Watchdog::SetArguments
(T1 a1)
160
{
161
if
(
m_impl
== 0)
162
{
163
NS_FATAL_ERROR
(
"You cannot set the arguments of a Watchdog before setting its function."
);
164
return
;
165
}
166
m_impl
->
SetArgs
(a1);
167
}
168
template
<
typename
T1,
typename
T2>
169
void
170
Watchdog::SetArguments
(T1 a1, T2 a2)
171
{
172
if
(
m_impl
== 0)
173
{
174
NS_FATAL_ERROR
(
"You cannot set the arguments of a Watchdog before setting its function."
);
175
return
;
176
}
177
m_impl
->
SetArgs
(a1, a2);
178
}
179
180
template
<
typename
T1,
typename
T2,
typename
T3>
181
void
182
Watchdog::SetArguments
(T1 a1, T2 a2, T3 a3)
183
{
184
if
(
m_impl
== 0)
185
{
186
NS_FATAL_ERROR
(
"You cannot set the arguments of a Watchdog before setting its function."
);
187
return
;
188
}
189
m_impl
->
SetArgs
(a1, a2, a3);
190
}
191
192
template
<
typename
T1,
typename
T2,
typename
T3,
typename
T4>
193
void
194
Watchdog::SetArguments
(T1 a1, T2 a2, T3 a3, T4 a4)
195
{
196
if
(
m_impl
== 0)
197
{
198
NS_FATAL_ERROR
(
"You cannot set the arguments of a Watchdog before setting its function."
);
199
return
;
200
}
201
m_impl
->
SetArgs
(a1, a2, a3, a4);
202
}
203
204
template
<
typename
T1,
typename
T2,
typename
T3,
typename
T4,
typename
T5>
205
void
206
Watchdog::SetArguments
(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
207
{
208
if
(
m_impl
== 0)
209
{
210
NS_FATAL_ERROR
(
"You cannot set the arguments of a Watchdog before setting its function."
);
211
return
;
212
}
213
m_impl
->
SetArgs
(a1, a2, a3, a4, a5);
214
}
215
216
template
<
typename
T1,
typename
T2,
typename
T3,
typename
T4,
typename
T5,
typename
T6>
217
void
218
Watchdog::SetArguments
(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
219
{
220
if
(
m_impl
== 0)
221
{
222
NS_FATAL_ERROR
(
"You cannot set the arguments of a Watchdog before setting its function."
);
223
return
;
224
}
225
m_impl
->
SetArgs
(a1, a2, a3, a4, a5, a6);
226
}
227
228
}
// namespace ns3
229
230
231
#endif
/* WATCHDOG_H */
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::Watchdog::m_end
Time m_end
Definition:
watchdog.h:132
ns3::Watchdog::Ping
void Ping(Time delay)
Definition:
watchdog.cc:42
ns3::Watchdog::m_event
EventId m_event
Definition:
watchdog.h:131
ns3::Watchdog::SetFunction
void SetFunction(FN fn)
Definition:
watchdog.h:144
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition:
fatal-error.h:72
ns3::Watchdog
a very simple watchdog
Definition:
watchdog.h:37
ns3::Watchdog::Watchdog
Watchdog()
Definition:
watchdog.cc:27
nstime.h
ns3::Watchdog::~Watchdog
~Watchdog()
Definition:
watchdog.cc:35
ns3::TimerImpl
Definition:
timer-impl.h:30
ns3::Watchdog::m_impl
TimerImpl * m_impl
Definition:
watchdog.h:130
ns3::EventId
an identifier for simulation events.
Definition:
event-id.h:46
ns3::MakeTimerImpl
TimerImpl * MakeTimerImpl(FN fn)
Definition:
timer-impl.h:100
ns3::Watchdog::SetArguments
void SetArguments(T1 a1)
Definition:
watchdog.h:159
ns3::TimerImpl::SetArgs
void SetArgs(T1 a1)
Definition:
timer-impl.h:725
timer-impl.h
event-id.h
ns3::Watchdog::Expire
void Expire(void)
Definition:
watchdog.cc:55
src
core
model
watchdog.h
Generated on Sat Apr 19 2014 14:06:52 for ns-3 by
1.8.6