160 * @param time the relative expiration time of the event. |
160 * @param time the relative expiration time of the event. |
161 * @param mem_ptr member method pointer to invoke |
161 * @param mem_ptr member method pointer to invoke |
162 * @param obj the object on which to invoke the member method |
162 * @param obj the object on which to invoke the member method |
163 * @returns an id for the scheduled event. |
163 * @returns an id for the scheduled event. |
164 */ |
164 */ |
165 template <typename T> |
165 template <typename T, typename OBJ> |
166 static EventId Schedule (Time const &time, void (T::*mem_ptr) (void), T *obj); |
166 static EventId Schedule (Time const &time, void (T::*mem_ptr) (void), OBJ obj); |
167 /** |
167 /** |
168 * @param time the relative expiration time of the event. |
168 * @param time the relative expiration time of the event. |
169 * @param mem_ptr member method pointer to invoke |
169 * @param mem_ptr member method pointer to invoke |
170 * @param obj the object on which to invoke the member method |
170 * @param obj the object on which to invoke the member method |
171 * @param a1 the first argument to pass to the invoked method |
171 * @param a1 the first argument to pass to the invoked method |
172 * @returns an id for the scheduled event. |
172 * @returns an id for the scheduled event. |
173 */ |
173 */ |
174 template <typename T, typename T1> |
174 template <typename T, typename OBJ, typename T1> |
175 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1), T* obj, T1 a1); |
175 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1), OBJ obj, T1 a1); |
176 /** |
176 /** |
177 * @param time the relative expiration time of the event. |
177 * @param time the relative expiration time of the event. |
178 * @param mem_ptr member method pointer to invoke |
178 * @param mem_ptr member method pointer to invoke |
179 * @param obj the object on which to invoke the member method |
179 * @param obj the object on which to invoke the member method |
180 * @param a1 the first argument to pass to the invoked method |
180 * @param a1 the first argument to pass to the invoked method |
181 * @param a2 the second argument to pass to the invoked method |
181 * @param a2 the second argument to pass to the invoked method |
182 * @returns an id for the scheduled event. |
182 * @returns an id for the scheduled event. |
183 */ |
183 */ |
184 template <typename T, typename T1, typename T2> |
184 template <typename T, typename OBJ, typename T1, typename T2> |
185 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2); |
185 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2); |
186 /** |
186 /** |
187 * @param time the relative expiration time of the event. |
187 * @param time the relative expiration time of the event. |
188 * @param mem_ptr member method pointer to invoke |
188 * @param mem_ptr member method pointer to invoke |
189 * @param obj the object on which to invoke the member method |
189 * @param obj the object on which to invoke the member method |
190 * @param a1 the first argument to pass to the invoked method |
190 * @param a1 the first argument to pass to the invoked method |
191 * @param a2 the second argument to pass to the invoked method |
191 * @param a2 the second argument to pass to the invoked method |
192 * @param a3 the third argument to pass to the invoked method |
192 * @param a3 the third argument to pass to the invoked method |
193 * @returns an id for the scheduled event. |
193 * @returns an id for the scheduled event. |
194 */ |
194 */ |
195 template <typename T, typename T1, typename T2, typename T3> |
195 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
196 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3); |
196 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3); |
197 /** |
197 /** |
198 * @param time the relative expiration time of the event. |
198 * @param time the relative expiration time of the event. |
199 * @param mem_ptr member method pointer to invoke |
199 * @param mem_ptr member method pointer to invoke |
200 * @param obj the object on which to invoke the member method |
200 * @param obj the object on which to invoke the member method |
201 * @param a1 the first argument to pass to the invoked method |
201 * @param a1 the first argument to pass to the invoked method |
202 * @param a2 the second argument to pass to the invoked method |
202 * @param a2 the second argument to pass to the invoked method |
203 * @param a3 the third argument to pass to the invoked method |
203 * @param a3 the third argument to pass to the invoked method |
204 * @param a4 the fourth argument to pass to the invoked method |
204 * @param a4 the fourth argument to pass to the invoked method |
205 * @returns an id for the scheduled event. |
205 * @returns an id for the scheduled event. |
206 */ |
206 */ |
207 template <typename T, typename T1, typename T2, typename T3, typename T4> |
207 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
208 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, T1 a1, T2 a2, T3 a3, T4 a4); |
208 static EventId Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); |
209 /** |
209 /** |
210 * @param time the relative expiration time of the event. |
210 * @param time the relative expiration time of the event. |
211 * @param mem_ptr member method pointer to invoke |
211 * @param mem_ptr member method pointer to invoke |
212 * @param obj the object on which to invoke the member method |
212 * @param obj the object on which to invoke the member method |
213 * @param a1 the first argument to pass to the invoked method |
213 * @param a1 the first argument to pass to the invoked method |
284 * have expired. |
284 * have expired. |
285 * |
285 * |
286 * @param mem_ptr member method pointer to invoke |
286 * @param mem_ptr member method pointer to invoke |
287 * @param obj the object on which to invoke the member method |
287 * @param obj the object on which to invoke the member method |
288 */ |
288 */ |
289 template <typename T> |
289 template <typename T, typename OBJ> |
290 static void ScheduleNow (void (T::*mem_ptr) (void), T *obj); |
290 static void ScheduleNow (void (T::*mem_ptr) (void), OBJ obj); |
291 /** |
291 /** |
292 * @param mem_ptr member method pointer to invoke |
292 * @param mem_ptr member method pointer to invoke |
293 * @param obj the object on which to invoke the member method |
293 * @param obj the object on which to invoke the member method |
294 * @param a1 the first argument to pass to the invoked method |
294 * @param a1 the first argument to pass to the invoked method |
295 */ |
295 */ |
296 template <typename T, typename T1> |
296 template <typename T, typename OBJ, typename T1> |
297 static void ScheduleNow (void (T::*mem_ptr) (T1), T* obj, T1 a1); |
297 static void ScheduleNow (void (T::*mem_ptr) (T1), OBJ obj, T1 a1); |
298 /** |
298 /** |
299 * @param mem_ptr member method pointer to invoke |
299 * @param mem_ptr member method pointer to invoke |
300 * @param obj the object on which to invoke the member method |
300 * @param obj the object on which to invoke the member method |
301 * @param a1 the first argument to pass to the invoked method |
301 * @param a1 the first argument to pass to the invoked method |
302 * @param a2 the second argument to pass to the invoked method |
302 * @param a2 the second argument to pass to the invoked method |
303 */ |
303 */ |
304 template <typename T, typename T1, typename T2> |
304 template <typename T, typename OBJ, typename T1, typename T2> |
305 static void ScheduleNow (void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2); |
305 static void ScheduleNow (void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2); |
306 /** |
306 /** |
307 * @param mem_ptr member method pointer to invoke |
307 * @param mem_ptr member method pointer to invoke |
308 * @param obj the object on which to invoke the member method |
308 * @param obj the object on which to invoke the member method |
309 * @param a1 the first argument to pass to the invoked method |
309 * @param a1 the first argument to pass to the invoked method |
310 * @param a2 the second argument to pass to the invoked method |
310 * @param a2 the second argument to pass to the invoked method |
311 * @param a3 the third argument to pass to the invoked method |
311 * @param a3 the third argument to pass to the invoked method |
312 */ |
312 */ |
313 template <typename T, typename T1, typename T2, typename T3> |
313 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
314 static void ScheduleNow (void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3); |
314 static void ScheduleNow (void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3); |
315 /** |
315 /** |
316 * @param mem_ptr member method pointer to invoke |
316 * @param mem_ptr member method pointer to invoke |
317 * @param obj the object on which to invoke the member method |
317 * @param obj the object on which to invoke the member method |
318 * @param a1 the first argument to pass to the invoked method |
318 * @param a1 the first argument to pass to the invoked method |
319 * @param a2 the second argument to pass to the invoked method |
319 * @param a2 the second argument to pass to the invoked method |
320 * @param a3 the third argument to pass to the invoked method |
320 * @param a3 the third argument to pass to the invoked method |
321 * @param a4 the fourth argument to pass to the invoked method |
321 * @param a4 the fourth argument to pass to the invoked method |
322 */ |
322 */ |
323 template <typename T, typename T1, typename T2, typename T3, typename T4> |
323 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
324 static void ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, |
324 static void ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, |
325 T1 a1, T2 a2, T3 a3, T4 a4); |
325 T1 a1, T2 a2, T3 a3, T4 a4); |
326 /** |
326 /** |
327 * @param mem_ptr member method pointer to invoke |
327 * @param mem_ptr member method pointer to invoke |
328 * @param obj the object on which to invoke the member method |
328 * @param obj the object on which to invoke the member method |
329 * @param a1 the first argument to pass to the invoked method |
329 * @param a1 the first argument to pass to the invoked method |
330 * @param a2 the second argument to pass to the invoked method |
330 * @param a2 the second argument to pass to the invoked method |
331 * @param a3 the third argument to pass to the invoked method |
331 * @param a3 the third argument to pass to the invoked method |
332 * @param a4 the fourth argument to pass to the invoked method |
332 * @param a4 the fourth argument to pass to the invoked method |
333 * @param a5 the fifth argument to pass to the invoked method |
333 * @param a5 the fifth argument to pass to the invoked method |
334 */ |
334 */ |
335 template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> |
335 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4, typename T5> |
336 static void ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj, |
336 static void ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj, |
337 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
337 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
338 /** |
338 /** |
339 * @param f the function to invoke |
339 * @param f the function to invoke |
340 */ |
340 */ |
341 static void ScheduleNow (void (*f) (void)); |
341 static void ScheduleNow (void (*f) (void)); |
388 * Simulator::Destroy is invoked. |
388 * Simulator::Destroy is invoked. |
389 * |
389 * |
390 * @param mem_ptr member method pointer to invoke |
390 * @param mem_ptr member method pointer to invoke |
391 * @param obj the object on which to invoke the member method |
391 * @param obj the object on which to invoke the member method |
392 */ |
392 */ |
393 template <typename T> |
393 template <typename T, typename OBJ> |
394 static void ScheduleDestroy (void (T::*mem_ptr) (void), T *obj); |
394 static void ScheduleDestroy (void (T::*mem_ptr) (void), OBJ obj); |
395 /** |
395 /** |
396 * @param mem_ptr member method pointer to invoke |
396 * @param mem_ptr member method pointer to invoke |
397 * @param obj the object on which to invoke the member method |
397 * @param obj the object on which to invoke the member method |
398 * @param a1 the first argument to pass to the invoked method |
398 * @param a1 the first argument to pass to the invoked method |
399 */ |
399 */ |
400 template <typename T, typename T1> |
400 template <typename T, typename OBJ, typename T1> |
401 static void ScheduleDestroy (void (T::*mem_ptr) (T1), T* obj, T1 a1); |
401 static void ScheduleDestroy (void (T::*mem_ptr) (T1), OBJ obj, T1 a1); |
402 /** |
402 /** |
403 * @param mem_ptr member method pointer to invoke |
403 * @param mem_ptr member method pointer to invoke |
404 * @param obj the object on which to invoke the member method |
404 * @param obj the object on which to invoke the member method |
405 * @param a1 the first argument to pass to the invoked method |
405 * @param a1 the first argument to pass to the invoked method |
406 * @param a2 the second argument to pass to the invoked method |
406 * @param a2 the second argument to pass to the invoked method |
407 */ |
407 */ |
408 template <typename T, typename T1, typename T2> |
408 template <typename T, typename OBJ, typename T1, typename T2> |
409 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2); |
409 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2); |
410 /** |
410 /** |
411 * @param mem_ptr member method pointer to invoke |
411 * @param mem_ptr member method pointer to invoke |
412 * @param obj the object on which to invoke the member method |
412 * @param obj the object on which to invoke the member method |
413 * @param a1 the first argument to pass to the invoked method |
413 * @param a1 the first argument to pass to the invoked method |
414 * @param a2 the second argument to pass to the invoked method |
414 * @param a2 the second argument to pass to the invoked method |
415 * @param a3 the third argument to pass to the invoked method |
415 * @param a3 the third argument to pass to the invoked method |
416 */ |
416 */ |
417 template <typename T, typename T1, typename T2, typename T3> |
417 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
418 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3); |
418 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3); |
419 /** |
419 /** |
420 * @param mem_ptr member method pointer to invoke |
420 * @param mem_ptr member method pointer to invoke |
421 * @param obj the object on which to invoke the member method |
421 * @param obj the object on which to invoke the member method |
422 * @param a1 the first argument to pass to the invoked method |
422 * @param a1 the first argument to pass to the invoked method |
423 * @param a2 the second argument to pass to the invoked method |
423 * @param a2 the second argument to pass to the invoked method |
424 * @param a3 the third argument to pass to the invoked method |
424 * @param a3 the third argument to pass to the invoked method |
425 * @param a4 the fourth argument to pass to the invoked method |
425 * @param a4 the fourth argument to pass to the invoked method |
426 */ |
426 */ |
427 template <typename T, typename T1, typename T2, typename T3, typename T4> |
427 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
428 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, |
428 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, |
429 T1 a1, T2 a2, T3 a3, T4 a4); |
429 T1 a1, T2 a2, T3 a3, T4 a4); |
430 /** |
430 /** |
431 * @param mem_ptr member method pointer to invoke |
431 * @param mem_ptr member method pointer to invoke |
432 * @param obj the object on which to invoke the member method |
432 * @param obj the object on which to invoke the member method |
433 * @param a1 the first argument to pass to the invoked method |
433 * @param a1 the first argument to pass to the invoked method |
434 * @param a2 the second argument to pass to the invoked method |
434 * @param a2 the second argument to pass to the invoked method |
435 * @param a3 the third argument to pass to the invoked method |
435 * @param a3 the third argument to pass to the invoked method |
436 * @param a4 the fourth argument to pass to the invoked method |
436 * @param a4 the fourth argument to pass to the invoked method |
437 * @param a5 the fifth argument to pass to the invoked method |
437 * @param a5 the fifth argument to pass to the invoked method |
438 */ |
438 */ |
439 template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> |
439 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4, typename T5> |
440 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj, |
440 static void ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj, |
441 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
441 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
442 /** |
442 /** |
443 * @param f the function to invoke |
443 * @param f the function to invoke |
444 */ |
444 */ |
445 static void ScheduleDestroy (void (*f) (void)); |
445 static void ScheduleDestroy (void (*f) (void)); |
446 /** |
446 /** |
527 */ |
527 */ |
528 static Time Now (void); |
528 static Time Now (void); |
529 private: |
529 private: |
530 Simulator (); |
530 Simulator (); |
531 ~Simulator (); |
531 ~Simulator (); |
532 template <typename T> |
532 template <typename T, typename OBJ> |
533 static EventImpl *MakeEvent (void (T::*mem_ptr) (void), T *obj); |
533 static EventImpl *MakeEvent (void (T::*mem_ptr) (void), OBJ obj); |
534 template <typename T, typename T1> |
534 template <typename T, typename OBJ, typename T1> |
535 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1), T* obj, T1 a1); |
535 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1), OBJ obj, T1 a1); |
536 template <typename T, typename T1, typename T2> |
536 template <typename T, typename OBJ, typename T1, typename T2> |
537 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2); |
537 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2); |
538 template <typename T, typename T1, typename T2, typename T3> |
538 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
539 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3); |
539 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3); |
540 template <typename T, typename T1, typename T2, typename T3, typename T4> |
540 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
541 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, T1 a1, T2 a2, T3 a3, T4 a4); |
541 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); |
542 template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> |
542 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4, typename T5> |
543 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj, |
543 static EventImpl *MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj, |
544 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
544 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); |
545 static EventImpl *MakeEvent (void (*f) (void)); |
545 static EventImpl *MakeEvent (void (*f) (void)); |
546 template <typename T1> |
546 template <typename T1> |
547 static EventImpl *MakeEvent (void (*f) (T1), T1 a1); |
547 static EventImpl *MakeEvent (void (*f) (T1), T1 a1); |
548 template <typename T1, typename T2> |
548 template <typename T1, typename T2> |
549 static EventImpl *MakeEvent (void (*f) (T1,T2), T1 a1, T2 a2); |
549 static EventImpl *MakeEvent (void (*f) (T1,T2), T1 a1, T2 a2); |
582 ********************************************************************/ |
582 ********************************************************************/ |
583 |
583 |
584 namespace ns3 { |
584 namespace ns3 { |
585 |
585 |
586 template <typename T> |
586 template <typename T> |
587 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (void), T *obj) |
587 struct EventMemberImplTraits; |
|
588 |
|
589 template <typename T> |
|
590 struct EventMemberImplTraits<T *> |
|
591 { |
|
592 static T &GetReference (T *p) { |
|
593 return *p; |
|
594 } |
|
595 }; |
|
596 |
|
597 template <typename T, typename OBJ> |
|
598 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (void), OBJ obj) |
588 { |
599 { |
589 // zero argument version |
600 // zero argument version |
590 class EventMemberImpl0 : public EventImpl { |
601 class EventMemberImpl0 : public EventImpl { |
591 public: |
602 public: |
592 typedef void (T::*F)(void); |
603 typedef void (T::*F)(void); |
593 EventMemberImpl0 (T *obj, F function) |
604 EventMemberImpl0 (OBJ obj, F function) |
594 : m_obj (obj), |
605 : m_obj (obj), |
595 m_function (function) |
606 m_function (function) |
596 {} |
607 {} |
597 virtual ~EventMemberImpl0 () {} |
608 virtual ~EventMemberImpl0 () {} |
598 private: |
609 private: |
599 virtual void Notify (void) { |
610 virtual void Notify (void) { |
600 (m_obj->*m_function) (); |
611 (EventMemberImplTraits<OBJ>::GetReference (m_obj).*m_function) (); |
601 } |
612 } |
602 T* m_obj; |
613 OBJ m_obj; |
603 F m_function; |
614 F m_function; |
604 } *ev = new EventMemberImpl0 (obj, mem_ptr); |
615 } *ev = new EventMemberImpl0 (obj, mem_ptr); |
605 return ev; |
616 return ev; |
606 } |
617 } |
607 |
618 |
608 |
619 |
609 template <typename T, typename T1> |
620 template <typename T, typename OBJ, typename T1> |
610 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1), T* obj, T1 a1) |
621 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1), OBJ obj, T1 a1) |
611 { |
622 { |
612 // one argument version |
623 // one argument version |
613 class EventMemberImpl1 : public EventImpl { |
624 class EventMemberImpl1 : public EventImpl { |
614 public: |
625 public: |
615 typedef void (T::*F)(T1); |
626 typedef void (T::*F)(T1); |
616 EventMemberImpl1 (T *obj, F function, T1 a1) |
627 EventMemberImpl1 (OBJ obj, F function, T1 a1) |
617 : m_obj (obj), |
628 : m_obj (obj), |
618 m_function (function), |
629 m_function (function), |
619 m_a1 (a1) |
630 m_a1 (a1) |
620 {} |
631 {} |
621 protected: |
632 protected: |
622 virtual ~EventMemberImpl1 () {} |
633 virtual ~EventMemberImpl1 () {} |
623 private: |
634 private: |
624 virtual void Notify (void) { |
635 virtual void Notify (void) { |
625 (m_obj->*m_function) (m_a1); |
636 (EventMemberImplTraits<OBJ>::GetReference (m_obj).*m_function) (m_a1); |
626 } |
637 } |
627 T* m_obj; |
638 OBJ m_obj; |
628 F m_function; |
639 F m_function; |
629 T1 m_a1; |
640 T1 m_a1; |
630 } *ev = new EventMemberImpl1 (obj, mem_ptr, a1); |
641 } *ev = new EventMemberImpl1 (obj, mem_ptr, a1); |
631 return ev; |
642 return ev; |
632 } |
643 } |
633 |
644 |
634 template <typename T, typename T1, typename T2> |
645 template <typename T, typename OBJ, typename T1, typename T2> |
635 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2) |
646 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2) |
636 { |
647 { |
637 // two argument version |
648 // two argument version |
638 class EventMemberImpl2 : public EventImpl { |
649 class EventMemberImpl2 : public EventImpl { |
639 public: |
650 public: |
640 typedef void (T::*F)(T1, T2); |
651 typedef void (T::*F)(T1, T2); |
641 |
652 |
642 EventMemberImpl2 (T *obj, F function, T1 a1, T2 a2) |
653 EventMemberImpl2 (OBJ obj, F function, T1 a1, T2 a2) |
643 : m_obj (obj), |
654 : m_obj (obj), |
644 m_function (function), |
655 m_function (function), |
645 m_a1 (a1), |
656 m_a1 (a1), |
646 m_a2 (a2) |
657 m_a2 (a2) |
647 { } |
658 { } |
648 protected: |
659 protected: |
649 virtual ~EventMemberImpl2 () {} |
660 virtual ~EventMemberImpl2 () {} |
650 private: |
661 private: |
651 virtual void Notify (void) { |
662 virtual void Notify (void) { |
652 (m_obj->*m_function) (m_a1, m_a2); |
663 (EventMemberImplTraits<OBJ>::GetReference (m_obj).*m_function) (m_a1, m_a2); |
653 } |
664 } |
654 T* m_obj; |
665 OBJ m_obj; |
655 F m_function; |
666 F m_function; |
656 T1 m_a1; |
667 T1 m_a1; |
657 T2 m_a2; |
668 T2 m_a2; |
658 } *ev = new EventMemberImpl2 (obj, mem_ptr, a1, a2); |
669 } *ev = new EventMemberImpl2 (obj, mem_ptr, a1, a2); |
659 return ev; |
670 return ev; |
660 } |
671 } |
661 |
672 |
662 template <typename T, typename T1, typename T2, typename T3> |
673 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
663 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3) |
674 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3) |
664 { |
675 { |
665 // three argument version |
676 // three argument version |
666 class EventMemberImpl3 : public EventImpl { |
677 class EventMemberImpl3 : public EventImpl { |
667 public: |
678 public: |
668 typedef void (T::*F)(T1, T2, T3); |
679 typedef void (T::*F)(T1, T2, T3); |
669 |
680 |
670 EventMemberImpl3 (T *obj, F function, T1 a1, T2 a2, T3 a3) |
681 EventMemberImpl3 (OBJ obj, F function, T1 a1, T2 a2, T3 a3) |
671 : m_obj (obj), |
682 : m_obj (obj), |
672 m_function (function), |
683 m_function (function), |
673 m_a1 (a1), |
684 m_a1 (a1), |
674 m_a2 (a2), |
685 m_a2 (a2), |
675 m_a3 (a3) |
686 m_a3 (a3) |
676 { } |
687 { } |
677 protected: |
688 protected: |
678 virtual ~EventMemberImpl3 () {} |
689 virtual ~EventMemberImpl3 () {} |
679 private: |
690 private: |
680 virtual void Notify (void) { |
691 virtual void Notify (void) { |
681 (m_obj->*m_function) (m_a1, m_a2, m_a3); |
692 (EventMemberImplTraits<OBJ>::GetReference (m_obj).*m_function) (m_a1, m_a2, m_a3); |
682 } |
693 } |
683 T* m_obj; |
694 OBJ m_obj; |
684 F m_function; |
695 F m_function; |
685 T1 m_a1; |
696 T1 m_a1; |
686 T2 m_a2; |
697 T2 m_a2; |
687 T3 m_a3; |
698 T3 m_a3; |
688 } *ev = new EventMemberImpl3 (obj, mem_ptr, a1, a2, a3); |
699 } *ev = new EventMemberImpl3 (obj, mem_ptr, a1, a2, a3); |
689 return ev; |
700 return ev; |
690 } |
701 } |
691 |
702 |
692 template <typename T, typename T1, typename T2, typename T3, typename T4> |
703 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
693 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, T1 a1, T2 a2, T3 a3, T4 a4) |
704 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) |
694 { |
705 { |
695 // four argument version |
706 // four argument version |
696 class EventMemberImpl4 : public EventImpl { |
707 class EventMemberImpl4 : public EventImpl { |
697 public: |
708 public: |
698 typedef void (T::*F)(T1, T2, T3, T4); |
709 typedef void (T::*F)(T1, T2, T3, T4); |
699 |
710 |
700 EventMemberImpl4 (T *obj, F function, T1 a1, T2 a2, T3 a3, T4 a4) |
711 EventMemberImpl4 (OBJ obj, F function, T1 a1, T2 a2, T3 a3, T4 a4) |
701 : m_obj (obj), |
712 : m_obj (obj), |
702 m_function (function), |
713 m_function (function), |
703 m_a1 (a1), |
714 m_a1 (a1), |
704 m_a2 (a2), |
715 m_a2 (a2), |
705 m_a3 (a3), |
716 m_a3 (a3), |
706 m_a4 (a4) |
717 m_a4 (a4) |
707 { } |
718 { } |
708 protected: |
719 protected: |
709 virtual ~EventMemberImpl4 () {} |
720 virtual ~EventMemberImpl4 () {} |
710 private: |
721 private: |
711 virtual void Notify (void) { |
722 virtual void Notify (void) { |
712 (m_obj->*m_function) (m_a1, m_a2, m_a3, m_a4); |
723 (EventMemberImplTraits<OBJ>::GetReference (m_obj).*m_function) (m_a1, m_a2, m_a3, m_a4); |
713 } |
724 } |
714 T* m_obj; |
725 OBJ m_obj; |
715 F m_function; |
726 F m_function; |
716 T1 m_a1; |
727 T1 m_a1; |
717 T2 m_a2; |
728 T2 m_a2; |
718 T3 m_a3; |
729 T3 m_a3; |
719 T4 m_a4; |
730 T4 m_a4; |
720 } *ev = new EventMemberImpl4 (obj, mem_ptr, a1, a2, a3, a4); |
731 } *ev = new EventMemberImpl4 (obj, mem_ptr, a1, a2, a3, a4); |
721 return ev; |
732 return ev; |
722 } |
733 } |
723 |
734 |
724 template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> |
735 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4, typename T5> |
725 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj, |
736 EventImpl *Simulator::MakeEvent (void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj, |
726 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
737 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
727 { |
738 { |
728 // five argument version |
739 // five argument version |
729 class EventMemberImpl5 : public EventImpl { |
740 class EventMemberImpl5 : public EventImpl { |
730 public: |
741 public: |
731 typedef void (T::*F)(T1, T2, T3, T4, T5); |
742 typedef void (T::*F)(T1, T2, T3, T4, T5); |
732 |
743 |
733 EventMemberImpl5 (T *obj, F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
744 EventMemberImpl5 (OBJ obj, F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
734 : m_obj (obj), |
745 : m_obj (obj), |
735 m_function (function), |
746 m_function (function), |
736 m_a1 (a1), |
747 m_a1 (a1), |
737 m_a2 (a2), |
748 m_a2 (a2), |
738 m_a3 (a3), |
749 m_a3 (a3), |
739 m_a4 (a4), |
750 m_a4 (a4), |
740 m_a5 (a5) |
751 m_a5 (a5) |
741 { } |
752 { } |
742 protected: |
753 protected: |
743 virtual ~EventMemberImpl5 () {} |
754 virtual ~EventMemberImpl5 () {} |
744 private: |
755 private: |
745 virtual void Notify (void) { |
756 virtual void Notify (void) { |
746 (m_obj->*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5); |
757 (EventMemberImplTraits<OBJ>::GetReference (m_obj).*m_function) (m_a1, m_a2, m_a3, m_a4, m_a5); |
747 } |
758 } |
748 T* m_obj; |
759 OBJ m_obj; |
749 F m_function; |
760 F m_function; |
750 T1 m_a1; |
761 T1 m_a1; |
751 T2 m_a2; |
762 T2 m_a2; |
752 T3 m_a3; |
763 T3 m_a3; |
753 T4 m_a4; |
764 T4 m_a4; |
754 T5 m_a5; |
765 T5 m_a5; |
755 } *ev = new EventMemberImpl5 (obj, mem_ptr, a1, a2, a3, a4, a5); |
766 } *ev = new EventMemberImpl5 (obj, mem_ptr, a1, a2, a3, a4, a5); |
756 return ev; |
767 return ev; |
757 } |
768 } |
758 |
769 |
759 template <typename T1> |
770 template <typename T1> |
894 T5 m_a5; |
905 T5 m_a5; |
895 } *ev = new EventFunctionImpl5 (f, a1, a2, a3, a4, a5); |
906 } *ev = new EventFunctionImpl5 (f, a1, a2, a3, a4, a5); |
896 return ev; |
907 return ev; |
897 } |
908 } |
898 |
909 |
899 template <typename T> |
910 template <typename T, typename OBJ> |
900 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (void), T *obj) |
911 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (void), OBJ obj) |
901 { |
912 { |
902 return Schedule (time, MakeEvent (mem_ptr, obj)); |
913 return Schedule (time, MakeEvent (mem_ptr, obj)); |
903 } |
914 } |
904 |
915 |
905 |
916 |
906 template <typename T, typename T1> |
917 template <typename T, typename OBJ, typename T1> |
907 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1), T* obj, T1 a1) |
918 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1), OBJ obj, T1 a1) |
908 { |
919 { |
909 return Schedule (time, MakeEvent (mem_ptr, obj, a1)); |
920 return Schedule (time, MakeEvent (mem_ptr, obj, a1)); |
910 } |
921 } |
911 |
922 |
912 template <typename T, typename T1, typename T2> |
923 template <typename T, typename OBJ, typename T1, typename T2> |
913 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2) |
924 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2) |
914 { |
925 { |
915 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2)); |
926 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2)); |
916 } |
927 } |
917 |
928 |
918 template <typename T, typename T1, typename T2, typename T3> |
929 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
919 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3) |
930 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3) |
920 { |
931 { |
921 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3)); |
932 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3)); |
922 } |
933 } |
923 |
934 |
924 template <typename T, typename T1, typename T2, typename T3, typename T4> |
935 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
925 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, T1 a1, T2 a2, T3 a3, T4 a4) |
936 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) |
926 { |
937 { |
927 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); |
938 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); |
928 } |
939 } |
929 |
940 |
930 template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> |
941 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4, typename T5> |
931 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj, |
942 EventId Simulator::Schedule (Time const &time, void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj, |
932 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
943 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
933 { |
944 { |
934 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); |
945 return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); |
935 } |
946 } |
936 |
947 |
965 } |
976 } |
966 |
977 |
967 |
978 |
968 |
979 |
969 |
980 |
970 template <typename T> |
981 template <typename T, typename OBJ> |
971 void |
982 void |
972 Simulator::ScheduleNow (void (T::*mem_ptr) (void), T *obj) |
983 Simulator::ScheduleNow (void (T::*mem_ptr) (void), OBJ obj) |
973 { |
984 { |
974 ScheduleNow (MakeEvent (mem_ptr, obj)); |
985 ScheduleNow (MakeEvent (mem_ptr, obj)); |
975 } |
986 } |
976 |
987 |
977 |
988 |
978 template <typename T, typename T1> |
989 template <typename T, typename OBJ, typename T1> |
979 void |
990 void |
980 Simulator::ScheduleNow (void (T::*mem_ptr) (T1), T* obj, T1 a1) |
991 Simulator::ScheduleNow (void (T::*mem_ptr) (T1), OBJ obj, T1 a1) |
981 { |
992 { |
982 ScheduleNow (MakeEvent (mem_ptr, obj, a1)); |
993 ScheduleNow (MakeEvent (mem_ptr, obj, a1)); |
983 } |
994 } |
984 |
995 |
985 template <typename T, typename T1, typename T2> |
996 template <typename T, typename OBJ, typename T1, typename T2> |
986 void |
997 void |
987 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2) |
998 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2) |
988 { |
999 { |
989 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2)); |
1000 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2)); |
990 } |
1001 } |
991 |
1002 |
992 template <typename T, typename T1, typename T2, typename T3> |
1003 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
993 void |
1004 void |
994 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3) |
1005 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3) |
995 { |
1006 { |
996 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3)); |
1007 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3)); |
997 } |
1008 } |
998 |
1009 |
999 template <typename T, typename T1, typename T2, typename T3, typename T4> |
1010 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
1000 void |
1011 void |
1001 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, T1 a1, T2 a2, T3 a3, T4 a4) |
1012 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) |
1002 { |
1013 { |
1003 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); |
1014 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); |
1004 } |
1015 } |
1005 |
1016 |
1006 template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> |
1017 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4, typename T5> |
1007 void |
1018 void |
1008 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj, |
1019 Simulator::ScheduleNow (void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj, |
1009 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
1020 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
1010 { |
1021 { |
1011 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); |
1022 ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); |
1012 } |
1023 } |
1013 |
1024 |
1014 template <typename T1> |
1025 template <typename T1> |
1046 ScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5)); |
1057 ScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5)); |
1047 } |
1058 } |
1048 |
1059 |
1049 |
1060 |
1050 |
1061 |
1051 template <typename T> |
1062 template <typename T, typename OBJ> |
1052 void |
1063 void |
1053 Simulator::ScheduleDestroy (void (T::*mem_ptr) (void), T *obj) |
1064 Simulator::ScheduleDestroy (void (T::*mem_ptr) (void), OBJ obj) |
1054 { |
1065 { |
1055 ScheduleDestroy (MakeEvent (mem_ptr, obj)); |
1066 ScheduleDestroy (MakeEvent (mem_ptr, obj)); |
1056 } |
1067 } |
1057 |
1068 |
1058 |
1069 |
1059 template <typename T, typename T1> |
1070 template <typename T, typename OBJ, typename T1> |
1060 void |
1071 void |
1061 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1), T* obj, T1 a1) |
1072 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1), OBJ obj, T1 a1) |
1062 { |
1073 { |
1063 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1)); |
1074 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1)); |
1064 } |
1075 } |
1065 |
1076 |
1066 template <typename T, typename T1, typename T2> |
1077 template <typename T, typename OBJ, typename T1, typename T2> |
1067 void |
1078 void |
1068 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2), T* obj, T1 a1, T2 a2) |
1079 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2), OBJ obj, T1 a1, T2 a2) |
1069 { |
1080 { |
1070 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2)); |
1081 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2)); |
1071 } |
1082 } |
1072 |
1083 |
1073 template <typename T, typename T1, typename T2, typename T3> |
1084 template <typename T, typename OBJ, typename T1, typename T2, typename T3> |
1074 void |
1085 void |
1075 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3), T* obj, T1 a1, T2 a2, T3 a3) |
1086 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3), OBJ obj, T1 a1, T2 a2, T3 a3) |
1076 { |
1087 { |
1077 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3)); |
1088 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3)); |
1078 } |
1089 } |
1079 |
1090 |
1080 template <typename T, typename T1, typename T2, typename T3, typename T4> |
1091 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4> |
1081 void |
1092 void |
1082 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4), T* obj, T1 a1, T2 a2, T3 a3, T4 a4) |
1093 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4), OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) |
1083 { |
1094 { |
1084 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); |
1095 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); |
1085 } |
1096 } |
1086 |
1097 |
1087 template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> |
1098 template <typename T, typename OBJ, typename T1, typename T2, typename T3, typename T4, typename T5> |
1088 void |
1099 void |
1089 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4,T5), T* obj, |
1100 Simulator::ScheduleDestroy (void (T::*mem_ptr) (T1,T2,T3,T4,T5), OBJ obj, |
1090 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
1101 T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
1091 { |
1102 { |
1092 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); |
1103 ScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); |
1093 } |
1104 } |
1094 |
1105 |
1095 template <typename T1> |
1106 template <typename T1> |