00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef WATCHDOG_H
00021 #define WATCHDOG_H
00022
00023 #include "nstime.h"
00024 #include "event-id.h"
00025
00026 namespace ns3 {
00027
00028 class TimerImpl;
00029
00030
00031
00032
00033
00034
00035
00036
00037 class Watchdog
00038 {
00039 public:
00040 Watchdog ();
00041 ~Watchdog ();
00042
00043
00044
00045
00046
00047
00048
00049
00050 void Ping (Time delay);
00051
00052
00053
00054
00055
00056
00057 template <typename FN>
00058 void SetFunction (FN fn);
00059
00060
00061
00062
00063
00064
00065
00066 template <typename MEM_PTR, typename OBJ_PTR>
00067 void SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr);
00068
00069
00070
00071
00072
00073
00074
00075 template <typename T1>
00076 void SetArguments (T1 a1);
00077
00078
00079
00080
00081
00082
00083 template <typename T1, typename T2>
00084 void SetArguments (T1 a1, T2 a2);
00085
00086
00087
00088
00089
00090
00091
00092 template <typename T1, typename T2, typename T3>
00093 void SetArguments (T1 a1, T2 a2, T3 a3);
00094
00095
00096
00097
00098
00099
00100
00101
00102 template <typename T1, typename T2, typename T3, typename T4>
00103 void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 template <typename T1, typename T2, typename T3, typename T4, typename T5>
00114 void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
00126 void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6);
00127
00128 private:
00129 void Expire (void);
00130 TimerImpl *m_impl;
00131 EventId m_event;
00132 Time m_end;
00133 };
00134
00135 }
00136
00137 #include "timer-impl.h"
00138
00139 namespace ns3 {
00140
00141
00142 template <typename FN>
00143 void
00144 Watchdog::SetFunction (FN fn)
00145 {
00146 delete m_impl;
00147 m_impl = MakeTimerImpl (fn);
00148 }
00149 template <typename MEM_PTR, typename OBJ_PTR>
00150 void
00151 Watchdog::SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr)
00152 {
00153 delete m_impl;
00154 m_impl = MakeTimerImpl (memPtr, objPtr);
00155 }
00156
00157 template <typename T1>
00158 void
00159 Watchdog::SetArguments (T1 a1)
00160 {
00161 if (m_impl == 0)
00162 {
00163 NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function.");
00164 return;
00165 }
00166 m_impl->SetArgs (a1);
00167 }
00168 template <typename T1, typename T2>
00169 void
00170 Watchdog::SetArguments (T1 a1, T2 a2)
00171 {
00172 if (m_impl == 0)
00173 {
00174 NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function.");
00175 return;
00176 }
00177 m_impl->SetArgs (a1, a2);
00178 }
00179
00180 template <typename T1, typename T2, typename T3>
00181 void
00182 Watchdog::SetArguments (T1 a1, T2 a2, T3 a3)
00183 {
00184 if (m_impl == 0)
00185 {
00186 NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function.");
00187 return;
00188 }
00189 m_impl->SetArgs (a1, a2, a3);
00190 }
00191
00192 template <typename T1, typename T2, typename T3, typename T4>
00193 void
00194 Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4)
00195 {
00196 if (m_impl == 0)
00197 {
00198 NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function.");
00199 return;
00200 }
00201 m_impl->SetArgs (a1, a2, a3, a4);
00202 }
00203
00204 template <typename T1, typename T2, typename T3, typename T4, typename T5>
00205 void
00206 Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
00207 {
00208 if (m_impl == 0)
00209 {
00210 NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function.");
00211 return;
00212 }
00213 m_impl->SetArgs (a1, a2, a3, a4, a5);
00214 }
00215
00216 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
00217 void
00218 Watchdog::SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
00219 {
00220 if (m_impl == 0)
00221 {
00222 NS_FATAL_ERROR ("You cannot set the arguments of a Watchdog before setting its function.");
00223 return;
00224 }
00225 m_impl->SetArgs (a1, a2, a3, a4, a5, a6);
00226 }
00227
00228 }
00229
00230
00231 #endif