A Discrete-Event Network Simulator
API
callback.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 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 
21 #ifndef CALLBACK_H
22 #define CALLBACK_H
23 
24 #include "ptr.h"
25 #include "fatal-error.h"
26 #include "empty.h"
27 #include "type-traits.h"
28 #include "attribute.h"
29 #include "attribute-helper.h"
30 #include "simple-ref-count.h"
31 #include <typeinfo>
32 
39 namespace ns3 {
40 
41 // Define the doxygen subgroups all at once,
42 // since the implementations are interleaved.
43 
79 template <typename T>
81 
89 template <typename T>
90 struct CallbackTraits<T *>
91 {
96  static T & GetReference (T * const p)
97  {
98  return *p;
99  }
100 };
101 
107 class CallbackImplBase : public SimpleRefCount<CallbackImplBase>
108 {
109 public:
111  virtual ~CallbackImplBase ()
112  {}
119  virtual bool IsEqual (Ptr<const CallbackImplBase> other) const = 0;
124  virtual std::string GetTypeid (void) const = 0;
125 
126 protected:
131  static std::string Demangle (const std::string& mangled);
138  template <typename T>
139  static std::string GetCppTypeid (void)
140  {
141  std::string typeName;
142  try
143  {
144  typeName = typeid (T).name ();
145  typeName = Demangle (typeName);
146  }
147  catch (const std::bad_typeid &e)
148  {
149  typeName = e.what ();
150  }
151  return typeName;
152  }
153 };
154 
162 template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
164 
172 template <typename R>
174 {
175 public:
176  virtual ~CallbackImpl ()
177  {}
178  virtual R operator() (void) = 0;
179  virtual std::string GetTypeid (void) const
180  {
181  return DoGetTypeid ();
182  }
184  static std::string DoGetTypeid (void)
185  {
186  static std::string id = "CallbackImpl<" +
187  GetCppTypeid<R> () +
188  ">";
189  return id;
190  }
191 };
193 template <typename R, typename T1>
195 {
196 public:
197  virtual ~CallbackImpl ()
198  {}
199  virtual R operator() (T1) = 0;
200  virtual std::string GetTypeid (void) const
201  {
202  return DoGetTypeid ();
203  }
205  static std::string DoGetTypeid (void)
206  {
207  static std::string id = "CallbackImpl<" +
208  GetCppTypeid<R> () + "," +
209  GetCppTypeid<T1> () +
210  ">";
211  return id;
212  }
213 };
215 template <typename R, typename T1, typename T2>
217 {
218 public:
219  virtual ~CallbackImpl ()
220  {}
221  virtual R operator() (T1, T2) = 0;
222  virtual std::string GetTypeid (void) const
223  {
224  return DoGetTypeid ();
225  }
227  static std::string DoGetTypeid (void)
228  {
229  static std::string id = "CallbackImpl<" +
230  GetCppTypeid<R> () + "," +
231  GetCppTypeid<T1> () + "," +
232  GetCppTypeid<T2> () +
233  ">";
234  return id;
235  }
236 };
238 template <typename R, typename T1, typename T2, typename T3>
240 {
241 public:
242  virtual ~CallbackImpl ()
243  {}
244  virtual R operator() (T1, T2, T3) = 0;
245  virtual std::string GetTypeid (void) const
246  {
247  return DoGetTypeid ();
248  }
250  static std::string DoGetTypeid (void)
251  {
252  static std::string id = "CallbackImpl<" +
253  GetCppTypeid<R> () + "," +
254  GetCppTypeid<T1> () + "," +
255  GetCppTypeid<T2> () + "," +
256  GetCppTypeid<T3> () +
257  ">";
258  return id;
259  }
260 };
262 template <typename R, typename T1, typename T2, typename T3, typename T4>
263 class CallbackImpl<R,T1,T2,T3,T4,empty,empty,empty,empty,empty> : public CallbackImplBase
264 {
265 public:
266  virtual ~CallbackImpl ()
267  {}
268  virtual R operator() (T1, T2, T3, T4) = 0;
269  virtual std::string GetTypeid (void) const
270  {
271  return DoGetTypeid ();
272  }
274  static std::string DoGetTypeid (void)
275  {
276  static std::string id = "CallbackImpl<" +
277  GetCppTypeid<R> () + "," +
278  GetCppTypeid<T1> () + "," +
279  GetCppTypeid<T2> () + "," +
280  GetCppTypeid<T3> () + "," +
281  GetCppTypeid<T4> () +
282  ">";
283  return id;
284  }
285 };
287 template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5>
288 class CallbackImpl<R,T1,T2,T3,T4,T5,empty,empty,empty,empty> : public CallbackImplBase
289 {
290 public:
291  virtual ~CallbackImpl ()
292  {}
293  virtual R operator() (T1, T2, T3, T4, T5) = 0;
294  virtual std::string GetTypeid (void) const
295  {
296  return DoGetTypeid ();
297  }
299  static std::string DoGetTypeid (void)
300  {
301  static std::string id = "CallbackImpl<" +
302  GetCppTypeid<R> () + "," +
303  GetCppTypeid<T1> () + "," +
304  GetCppTypeid<T2> () + "," +
305  GetCppTypeid<T3> () + "," +
306  GetCppTypeid<T4> () + "," +
307  GetCppTypeid<T5> () +
308  ">";
309  return id;
310  }
311 };
313 template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
314 class CallbackImpl<R,T1,T2,T3,T4,T5,T6,empty,empty,empty> : public CallbackImplBase
315 {
316 public:
317  virtual ~CallbackImpl ()
318  {}
319  virtual R operator() (T1, T2, T3, T4, T5, T6) = 0;
320  virtual std::string GetTypeid (void) const
321  {
322  return DoGetTypeid ();
323  }
325  static std::string DoGetTypeid (void)
326  {
327  static std::string id = "CallbackImpl<" +
328  GetCppTypeid<R> () + "," +
329  GetCppTypeid<T1> () + "," +
330  GetCppTypeid<T2> () + "," +
331  GetCppTypeid<T3> () + "," +
332  GetCppTypeid<T4> () + "," +
333  GetCppTypeid<T5> () + "," +
334  GetCppTypeid<T6> () +
335  ">";
336  return id;
337  }
338 };
340 template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
341 class CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,empty,empty> : public CallbackImplBase
342 {
343 public:
344  virtual ~CallbackImpl ()
345  {}
346  virtual R operator() (T1, T2, T3, T4, T5, T6, T7) = 0;
347  virtual std::string GetTypeid (void) const
348  {
349  return DoGetTypeid ();
350  }
352  static std::string DoGetTypeid (void)
353  {
354  static std::string id = "CallbackImpl<" +
355  GetCppTypeid<R> () + "," +
356  GetCppTypeid<T1> () + "," +
357  GetCppTypeid<T2> () + "," +
358  GetCppTypeid<T3> () + "," +
359  GetCppTypeid<T4> () + "," +
360  GetCppTypeid<T5> () + "," +
361  GetCppTypeid<T6> () + "," +
362  GetCppTypeid<T7> () +
363  ">";
364  return id;
365  }
366 };
368 template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
369 class CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,empty> : public CallbackImplBase
370 {
371 public:
372  virtual ~CallbackImpl ()
373  {}
374  virtual R operator() (T1, T2, T3, T4, T5, T6, T7, T8) = 0;
375  virtual std::string GetTypeid (void) const
376  {
377  return DoGetTypeid ();
378  }
380  static std::string DoGetTypeid (void)
381  {
382  static std::string id = "CallbackImpl<" +
383  GetCppTypeid<R> () + "," +
384  GetCppTypeid<T1> () + "," +
385  GetCppTypeid<T2> () + "," +
386  GetCppTypeid<T3> () + "," +
387  GetCppTypeid<T4> () + "," +
388  GetCppTypeid<T5> () + "," +
389  GetCppTypeid<T6> () + "," +
390  GetCppTypeid<T7> () + "," +
391  GetCppTypeid<T8> () +
392  ">";
393  return id;
394  }
395 };
397 template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
398 class CallbackImpl : public CallbackImplBase
399 {
400 public:
401  virtual ~CallbackImpl ()
402  {}
403  virtual R operator() (T1, T2, T3, T4, T5, T6, T7, T8, T9) = 0;
404  virtual std::string GetTypeid (void) const
405  {
406  return DoGetTypeid ();
407  }
409  static std::string DoGetTypeid (void)
410  {
411  static std::string id = "CallbackImpl<" +
412  GetCppTypeid<R> () + "," +
413  GetCppTypeid<T1> () + "," +
414  GetCppTypeid<T2> () + "," +
415  GetCppTypeid<T3> () + "," +
416  GetCppTypeid<T4> () + "," +
417  GetCppTypeid<T5> () + "," +
418  GetCppTypeid<T6> () + "," +
419  GetCppTypeid<T7> () + "," +
420  GetCppTypeid<T8> () + "," +
421  GetCppTypeid<T9> () +
422  ">";
423  return id;
424  }
425 };
434 template <typename T, typename R, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6, typename T7, typename T8, typename T9>
435 class FunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9>
436 {
437 public:
443  FunctorCallbackImpl (T const &functor)
444  : m_functor (functor)
445  {}
447  {}
453  R operator() (void)
454  {
455  return m_functor ();
456  }
461  R operator() (T1 a1)
462  {
463  return m_functor (a1);
464  }
470  R operator() (T1 a1,T2 a2)
471  {
472  return m_functor (a1,a2);
473  }
480  R operator() (T1 a1,T2 a2,T3 a3)
481  {
482  return m_functor (a1,a2,a3);
483  }
491  R operator() (T1 a1,T2 a2,T3 a3,T4 a4)
492  {
493  return m_functor (a1,a2,a3,a4);
494  }
503  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5)
504  {
505  return m_functor (a1,a2,a3,a4,a5);
506  }
516  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6)
517  {
518  return m_functor (a1,a2,a3,a4,a5,a6);
519  }
530  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7)
531  {
532  return m_functor (a1,a2,a3,a4,a5,a6,a7);
533  }
545  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8)
546  {
547  return m_functor (a1,a2,a3,a4,a5,a6,a7,a8);
548  }
561  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9)
562  {
563  return m_functor (a1,a2,a3,a4,a5,a6,a7,a8,a9);
564  }
572  virtual bool IsEqual (Ptr<const CallbackImplBase> other) const
573  {
576  if (otherDerived == 0)
577  {
578  return false;
579  }
580  else if (otherDerived->m_functor != m_functor)
581  {
582  return false;
583  }
584  return true;
585  }
586 
587 private:
589 };
590 
597 template <typename OBJ_PTR, typename MEM_PTR, typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
598 class MemPtrCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9>
599 {
600 public:
607  MemPtrCallbackImpl (OBJ_PTR const&objPtr, MEM_PTR memPtr)
608  : m_objPtr (objPtr), m_memPtr (memPtr)
609  {}
611  {}
617  R operator() (void)
618  {
620  }
625  R operator() (T1 a1)
626  {
628  }
634  R operator() (T1 a1,T2 a2)
635  {
637  }
644  R operator() (T1 a1,T2 a2,T3 a3)
645  {
646  return ((CallbackTraits<OBJ_PTR>::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3);
647  }
655  R operator() (T1 a1,T2 a2,T3 a3,T4 a4)
656  {
657  return ((CallbackTraits<OBJ_PTR>::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4);
658  }
667  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5)
668  {
669  return ((CallbackTraits<OBJ_PTR>::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5);
670  }
680  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6)
681  {
682  return ((CallbackTraits<OBJ_PTR>::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6);
683  }
694  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7)
695  {
696  return ((CallbackTraits<OBJ_PTR>::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6, a7);
697  }
709  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8)
710  {
711  return ((CallbackTraits<OBJ_PTR>::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6, a7, a8);
712  }
725  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, T9 a9)
726  {
727  return ((CallbackTraits<OBJ_PTR>::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6, a7, a8, a9);
728  }
736  virtual bool IsEqual (Ptr<const CallbackImplBase> other) const
737  {
740  if (otherDerived == 0)
741  {
742  return false;
743  }
744  else if (otherDerived->m_objPtr != m_objPtr
745  || otherDerived->m_memPtr != m_memPtr)
746  {
747  return false;
748  }
749  return true;
750  }
751 
752 private:
753  OBJ_PTR const m_objPtr;
754  MEM_PTR m_memPtr;
755 };
756 
763 template <typename T, typename R, typename TX, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6, typename T7, typename T8>
764 class BoundFunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,empty>
765 {
766 public:
776  template <typename FUNCTOR, typename ARG>
777  BoundFunctorCallbackImpl (FUNCTOR functor, ARG a)
778  : m_functor (functor), m_a (a)
779  {}
781  {}
787  R operator() (void)
788  {
789  return m_functor (m_a);
790  }
795  R operator() (T1 a1)
796  {
797  return m_functor (m_a,a1);
798  }
804  R operator() (T1 a1,T2 a2)
805  {
806  return m_functor (m_a,a1,a2);
807  }
814  R operator() (T1 a1,T2 a2,T3 a3)
815  {
816  return m_functor (m_a,a1,a2,a3);
817  }
825  R operator() (T1 a1,T2 a2,T3 a3,T4 a4)
826  {
827  return m_functor (m_a,a1,a2,a3,a4);
828  }
837  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5)
838  {
839  return m_functor (m_a,a1,a2,a3,a4,a5);
840  }
850  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6)
851  {
852  return m_functor (m_a,a1,a2,a3,a4,a5,a6);
853  }
864  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7)
865  {
866  return m_functor (m_a,a1,a2,a3,a4,a5,a6,a7);
867  }
879  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8)
880  {
881  return m_functor (m_a,a1,a2,a3,a4,a5,a6,a7,a8);
882  }
890  virtual bool IsEqual (Ptr<const CallbackImplBase> other) const
891  {
894  if (otherDerived == 0)
895  {
896  return false;
897  }
898  else if (otherDerived->m_functor != m_functor
899  || otherDerived->m_a != m_a)
900  {
901  return false;
902  }
903  return true;
904  }
905 
906 private:
909 };
910 
918 template <typename T, typename R, typename TX1, typename TX2, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6, typename T7>
919 class TwoBoundFunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,empty,empty>
920 {
921 public:
934  template <typename FUNCTOR, typename ARG1, typename ARG2>
935  TwoBoundFunctorCallbackImpl (FUNCTOR functor, ARG1 arg1, ARG2 arg2)
936  : m_functor (functor), m_a1 (arg1), m_a2 (arg2)
937  {}
939  {}
945  R operator() (void)
946  {
947  return m_functor (m_a1,m_a2);
948  }
953  R operator() (T1 a1)
954  {
955  return m_functor (m_a1,m_a2,a1);
956  }
962  R operator() (T1 a1,T2 a2)
963  {
964  return m_functor (m_a1,m_a2,a1,a2);
965  }
972  R operator() (T1 a1,T2 a2,T3 a3)
973  {
974  return m_functor (m_a1,m_a2,a1,a2,a3);
975  }
983  R operator() (T1 a1,T2 a2,T3 a3,T4 a4)
984  {
985  return m_functor (m_a1,m_a2,a1,a2,a3,a4);
986  }
995  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5)
996  {
997  return m_functor (m_a1,m_a2,a1,a2,a3,a4,a5);
998  }
1008  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6)
1009  {
1010  return m_functor (m_a1,m_a2,a1,a2,a3,a4,a5,a6);
1011  }
1022  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7)
1023  {
1024  return m_functor (m_a1,m_a2,a1,a2,a3,a4,a5,a6,a7);
1025  }
1033  virtual bool IsEqual (Ptr<const CallbackImplBase> other) const
1034  {
1037  if (otherDerived == 0)
1038  {
1039  return false;
1040  }
1041  else if (otherDerived->m_functor != m_functor
1042  || otherDerived->m_a1 != m_a1 || otherDerived->m_a2 != m_a2)
1043  {
1044  return false;
1045  }
1046  return true;
1047  }
1048 
1049 private:
1053 };
1054 
1063 template <typename T, typename R, typename TX1, typename TX2, typename TX3, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6>
1064 class ThreeBoundFunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,empty,empty,empty>
1065 {
1066 public:
1082  template <typename FUNCTOR, typename ARG1, typename ARG2, typename ARG3>
1083  ThreeBoundFunctorCallbackImpl (FUNCTOR functor, ARG1 arg1, ARG2 arg2, ARG3 arg3)
1084  : m_functor (functor), m_a1 (arg1), m_a2 (arg2), m_a3 (arg3)
1085  {}
1087  {}
1093  R operator() (void)
1094  {
1095  return m_functor (m_a1,m_a2,m_a3);
1096  }
1101  R operator() (T1 a1)
1102  {
1103  return m_functor (m_a1,m_a2,m_a3,a1);
1104  }
1110  R operator() (T1 a1,T2 a2)
1111  {
1112  return m_functor (m_a1,m_a2,m_a3,a1,a2);
1113  }
1120  R operator() (T1 a1,T2 a2,T3 a3)
1121  {
1122  return m_functor (m_a1,m_a2,m_a3,a1,a2,a3);
1123  }
1131  R operator() (T1 a1,T2 a2,T3 a3,T4 a4)
1132  {
1133  return m_functor (m_a1,m_a2,m_a3,a1,a2,a3,a4);
1134  }
1143  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5)
1144  {
1145  return m_functor (m_a1,m_a2,m_a3,a1,a2,a3,a4,a5);
1146  }
1156  R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6)
1157  {
1158  return m_functor (m_a1,m_a2,m_a3,a1,a2,a3,a4,a5,a6);
1159  }
1167  virtual bool IsEqual (Ptr<const CallbackImplBase> other) const
1168  {
1171  if (otherDerived == 0)
1172  {
1173  return false;
1174  }
1175  else if (otherDerived->m_functor != m_functor
1176  || otherDerived->m_a1 != m_a1 || otherDerived->m_a2 != m_a2 || otherDerived->m_a3 != m_a3)
1177  {
1178  return false;
1179  }
1180  return true;
1181  }
1182 
1183 private:
1188 };
1189 
1196 {
1197 public:
1199  {}
1202  {
1203  return m_impl;
1204  }
1205 
1206 protected:
1212  {}
1214 };
1215 
1272 template<typename R,
1273  typename T1 = empty, typename T2 = empty,
1274  typename T3 = empty, typename T4 = empty,
1275  typename T5 = empty, typename T6 = empty,
1276  typename T7 = empty, typename T8 = empty,
1277  typename T9 = empty>
1278 class Callback : public CallbackBase
1279 {
1280 public:
1282  {}
1283 
1294  template <typename FUNCTOR>
1295  Callback (FUNCTOR const &functor, bool, bool)
1296  : CallbackBase (Create<FunctorCallbackImpl<FUNCTOR,R,T1,T2,T3,T4,T5,T6,T7,T8,T9> > (functor))
1297  {}
1298 
1307  template <typename OBJ_PTR, typename MEM_PTR>
1308  Callback (OBJ_PTR const &objPtr, MEM_PTR memPtr)
1309  : CallbackBase (Create<MemPtrCallbackImpl<OBJ_PTR,MEM_PTR,R,T1,T2,T3,T4,T5,T6,T7,T8,T9> > (objPtr, memPtr))
1310  {}
1311 
1318  : CallbackBase (impl)
1319  {}
1320 
1328  template <typename T>
1330  {
1335  R,T1,T2,T3,T4,T5,T6,T7,T8,T9> (*this, a), false);
1337  }
1338 
1348  template <typename TX1, typename TX2>
1350  {
1355  R,T1,T2,T3,T4,T5,T6,T7,T8,T9> (*this, a1, a2), false);
1356  return Callback<R,T3,T4,T5,T6,T7,T8,T9> (impl);
1357  }
1358 
1370  template <typename TX1, typename TX2, typename TX3>
1371  Callback<R,T4,T5,T6,T7,T8,T9> ThreeBind (TX1 a1, TX2 a2, TX3 a3)
1372  {
1377  R,T1,T2,T3,T4,T5,T6,T7,T8,T9> (*this, a1, a2, a3), false);
1378  return Callback<R,T4,T5,T6,T7,T8,T9> (impl);
1379  }
1380 
1386  bool IsNull (void) const
1387  {
1388  return (DoPeekImpl () == 0) ? true : false;
1389  }
1391  void Nullify (void)
1392  {
1393  m_impl = 0;
1394  }
1395 
1401  R operator() (void) const
1402  {
1403  return (*(DoPeekImpl ()))();
1404  }
1409  R operator() (T1 a1) const
1410  {
1411  return (*(DoPeekImpl ()))(a1);
1412  }
1418  R operator() (T1 a1, T2 a2) const
1419  {
1420  return (*(DoPeekImpl ()))(a1,a2);
1421  }
1428  R operator() (T1 a1, T2 a2, T3 a3) const
1429  {
1430  return (*(DoPeekImpl ()))(a1,a2,a3);
1431  }
1439  R operator() (T1 a1, T2 a2, T3 a3, T4 a4) const
1440  {
1441  return (*(DoPeekImpl ()))(a1,a2,a3,a4);
1442  }
1451  R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5) const
1452  {
1453  return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5);
1454  }
1464  R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6) const
1465  {
1466  return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6);
1467  }
1478  R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7) const
1479  {
1480  return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6,a7);
1481  }
1493  R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) const
1494  {
1495  return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6,a7,a8);
1496  }
1509  R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, T9 a9) const
1510  {
1511  return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6,a7,a8,a9);
1512  }
1521  bool IsEqual (const CallbackBase &other) const
1522  {
1523  return m_impl->IsEqual (other.GetImpl ());
1524  }
1525 
1532  bool CheckType (const CallbackBase & other) const
1533  {
1534  return DoCheckType (other.GetImpl ());
1535  }
1542  bool Assign (const CallbackBase &other)
1543  {
1544  return DoAssign (other.GetImpl ());
1545  }
1546 
1547 private:
1550  {
1552  }
1560  {
1561  if (other != 0
1562  && dynamic_cast<const CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9> *> (PeekPointer (other)) != 0)
1563  {
1564  return true;
1565  }
1566  else if (other == 0)
1567  {
1568  return true;
1569  }
1570  else
1571  {
1572  return false;
1573  }
1574  }
1577  {
1578  if (!DoCheckType (other))
1579  {
1580  std::string othTid = other->GetTypeid ();
1582  NS_FATAL_ERROR_CONT ("Incompatible types. (feed to \"c++filt -t\" if needed)" << std::endl <<
1583  "got=" << othTid << std::endl <<
1584  "expected=" << myTid);
1585  return false;
1586  }
1587  m_impl = const_cast<CallbackImplBase *> (PeekPointer (other));
1588  return true;
1589  }
1590 };
1591 
1592 
1601 template <typename R, typename T1, typename T2,
1602  typename T3, typename T4,
1603  typename T5, typename T6,
1604  typename T7, typename T8,
1605  typename T9>
1607 {
1608  return !a.IsEqual (b);
1609 }
1610 
1641 template <typename T, typename OBJ, typename R, typename... Ts>
1642 Callback<R,Ts...> MakeCallback (R (T::*memPtr)(Ts...), OBJ objPtr)
1643 {
1644  return Callback<R,Ts...> (objPtr, memPtr);
1645 }
1646 template <typename T, typename OBJ, typename R, typename... Ts>
1647 Callback<R,Ts...> MakeCallback (R (T::*memPtr)(Ts...) const, OBJ objPtr)
1648 {
1649  return Callback<R,Ts...> (objPtr, memPtr);
1650 }
1664 template <typename R, typename... Ts>
1665 Callback<R,Ts...> MakeCallback (R (*fnPtr)(Ts...))
1666 {
1667  return Callback<R,Ts...> (fnPtr, true, true);
1668 }
1669 
1681 template <typename R, typename... Ts>
1683 {
1684  return Callback<R,Ts...> ();
1685 }
1686 
1687 
1702 template <typename R, typename TX, typename ARG>
1703 Callback<R> MakeBoundCallback (R (*fnPtr)(TX), ARG a1)
1704 {
1706  Create<BoundFunctorCallbackImpl<R (*)(TX),R,TX,empty,empty,empty,empty,empty,empty,empty,empty> > (fnPtr, a1);
1707  return Callback<R> (impl);
1708 }
1709 template <typename R, typename TX, typename ARG,
1710  typename T1>
1711 Callback<R,T1> MakeBoundCallback (R (*fnPtr)(TX,T1), ARG a1)
1712 {
1714  Create<BoundFunctorCallbackImpl<R (*)(TX,T1),R,TX,T1,empty,empty,empty,empty,empty,empty,empty> > (fnPtr, a1);
1715  return Callback<R,T1> (impl);
1716 }
1717 template <typename R, typename TX, typename ARG,
1718  typename T1, typename T2>
1719 Callback<R,T1,T2> MakeBoundCallback (R (*fnPtr)(TX,T1,T2), ARG a1)
1720 {
1722  Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2),R,TX,T1,T2,empty,empty,empty,empty,empty,empty> > (fnPtr, a1);
1723  return Callback<R,T1,T2> (impl);
1724 }
1725 template <typename R, typename TX, typename ARG,
1726  typename T1, typename T2,typename T3>
1727 Callback<R,T1,T2,T3> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3), ARG a1)
1728 {
1730  Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3),R,TX,T1,T2,T3,empty,empty,empty,empty,empty> > (fnPtr, a1);
1731  return Callback<R,T1,T2,T3> (impl);
1732 }
1733 template <typename R, typename TX, typename ARG,
1734  typename T1, typename T2,typename T3,typename T4>
1735 Callback<R,T1,T2,T3,T4> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4), ARG a1)
1736 {
1738  Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4),R,TX,T1,T2,T3,T4,empty,empty,empty,empty> > (fnPtr, a1);
1739  return Callback<R,T1,T2,T3,T4> (impl);
1740 }
1741 template <typename R, typename TX, typename ARG,
1742  typename T1, typename T2,typename T3,typename T4,typename T5>
1743 Callback<R,T1,T2,T3,T4,T5> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5), ARG a1)
1744 {
1746  Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5),R,TX,T1,T2,T3,T4,T5,empty,empty,empty> > (fnPtr, a1);
1747  return Callback<R,T1,T2,T3,T4,T5> (impl);
1748 }
1749 template <typename R, typename TX, typename ARG,
1750  typename T1, typename T2,typename T3,typename T4,typename T5, typename T6>
1751 Callback<R,T1,T2,T3,T4,T5,T6> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6), ARG a1)
1752 {
1754  Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5,T6),R,TX,T1,T2,T3,T4,T5,T6,empty,empty> > (fnPtr, a1);
1755  return Callback<R,T1,T2,T3,T4,T5,T6> (impl);
1756 }
1757 template <typename R, typename TX, typename ARG,
1758  typename T1, typename T2,typename T3,typename T4,typename T5, typename T6, typename T7>
1759 Callback<R,T1,T2,T3,T4,T5,T6,T7> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7), ARG a1)
1760 {
1762  Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5,T6,T7),R,TX,T1,T2,T3,T4,T5,T6,T7,empty> > (fnPtr, a1);
1763  return Callback<R,T1,T2,T3,T4,T5,T6,T7> (impl);
1764 }
1765 template <typename R, typename TX, typename ARG,
1766  typename T1, typename T2,typename T3,typename T4,typename T5, typename T6, typename T7, typename T8>
1767 Callback<R,T1,T2,T3,T4,T5,T6,T7,T8> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7,T8), ARG a1)
1768 {
1770  Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5,T6,T7,T8),R,TX,T1,T2,T3,T4,T5,T6,T7,T8> > (fnPtr, a1);
1772 }
1791 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2>
1792 Callback<R> MakeBoundCallback (R (*fnPtr)(TX1,TX2), ARG1 a1, ARG2 a2)
1793 {
1795  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2),R,TX1,TX2,empty,empty,empty,empty,empty,empty,empty> > (fnPtr, a1, a2);
1796  return Callback<R> (impl);
1797 }
1798 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1799  typename T1>
1800 Callback<R,T1> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1), ARG1 a1, ARG2 a2)
1801 {
1803  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1),R,TX1,TX2,T1,empty,empty,empty,empty,empty,empty> > (fnPtr, a1, a2);
1804  return Callback<R,T1> (impl);
1805 }
1806 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1807  typename T1, typename T2>
1808 Callback<R,T1,T2> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2), ARG1 a1, ARG2 a2)
1809 {
1811  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2),R,TX1,TX2,T1,T2,empty,empty,empty,empty,empty> > (fnPtr, a1, a2);
1812  return Callback<R,T1,T2> (impl);
1813 }
1814 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1815  typename T1, typename T2,typename T3>
1816 Callback<R,T1,T2,T3> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3), ARG1 a1, ARG2 a2)
1817 {
1819  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3),R,TX1,TX2,T1,T2,T3,empty,empty,empty,empty> > (fnPtr, a1, a2);
1820  return Callback<R,T1,T2,T3> (impl);
1821 }
1822 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1823  typename T1, typename T2,typename T3,typename T4>
1824 Callback<R,T1,T2,T3,T4> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4), ARG1 a1, ARG2 a2)
1825 {
1827  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3,T4),R,TX1,TX2,T1,T2,T3,T4,empty,empty,empty> > (fnPtr, a1, a2);
1828  return Callback<R,T1,T2,T3,T4> (impl);
1829 }
1830 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1831  typename T1, typename T2,typename T3,typename T4,typename T5>
1832 Callback<R,T1,T2,T3,T4,T5> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2)
1833 {
1835  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3,T4,T5),R,TX1,TX2,T1,T2,T3,T4,T5,empty,empty> > (fnPtr, a1, a2);
1836  return Callback<R,T1,T2,T3,T4,T5> (impl);
1837 }
1838 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1839  typename T1, typename T2,typename T3,typename T4,typename T5, typename T6>
1840 Callback<R,T1,T2,T3,T4,T5,T6> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6), ARG1 a1, ARG2 a2)
1841 {
1843  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3,T4,T5,T6),R,TX1,TX2,T1,T2,T3,T4,T5,T6,empty> > (fnPtr, a1, a2);
1844  return Callback<R,T1,T2,T3,T4,T5,T6> (impl);
1845 }
1846 template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1847  typename T1, typename T2,typename T3,typename T4,typename T5, typename T6, typename T7>
1848 Callback<R,T1,T2,T3,T4,T5,T6,T7> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6,T7), ARG1 a1, ARG2 a2)
1849 {
1851  Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3,T4,T5,T6,T7),R,TX1,TX2,T1,T2,T3,T4,T5,T6,T7> > (fnPtr, a1, a2);
1852  return Callback<R,T1,T2,T3,T4,T5,T6,T7> (impl);
1853 }
1875 template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3>
1876 Callback<R> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3), ARG1 a1, ARG2 a2, ARG3 a3)
1877 {
1879  Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3),R,TX1,TX2,TX3,empty,empty,empty,empty,empty,empty> > (fnPtr, a1, a2, a3);
1880  return Callback<R> (impl);
1881 }
1882 template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1883  typename T1>
1884 Callback<R,T1> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1), ARG1 a1, ARG2 a2, ARG3 a3)
1885 {
1887  Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1),R,TX1,TX2,TX3,T1,empty,empty,empty,empty,empty> > (fnPtr, a1, a2, a3);
1888  return Callback<R,T1> (impl);
1889 }
1890 template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1891  typename T1, typename T2>
1892 Callback<R,T1,T2> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2), ARG1 a1, ARG2 a2, ARG3 a3)
1893 {
1895  Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2),R,TX1,TX2,TX3,T1,T2,empty,empty,empty,empty> > (fnPtr, a1, a2, a3);
1896  return Callback<R,T1,T2> (impl);
1897 }
1898 template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1899  typename T1, typename T2,typename T3>
1900 Callback<R,T1,T2,T3> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3), ARG1 a1, ARG2 a2, ARG3 a3)
1901 {
1903  Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2,T3),R,TX1,TX2,TX3,T1,T2,T3,empty,empty,empty> > (fnPtr, a1, a2, a3);
1904  return Callback<R,T1,T2,T3> (impl);
1905 }
1906 template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1907  typename T1, typename T2,typename T3,typename T4>
1908 Callback<R,T1,T2,T3,T4> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4), ARG1 a1, ARG2 a2, ARG3 a3)
1909 {
1911  Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2,T3,T4),R,TX1,TX2,TX3,T1,T2,T3,T4,empty,empty> > (fnPtr, a1, a2, a3);
1912  return Callback<R,T1,T2,T3,T4> (impl);
1913 }
1914 template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1915  typename T1, typename T2,typename T3,typename T4,typename T5>
1916 Callback<R,T1,T2,T3,T4,T5> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2, ARG3 a3)
1917 {
1919  Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2,T3,T4,T5),R,TX1,TX2,TX3,T1,T2,T3,T4,T5,empty> > (fnPtr, a1, a2, a3);
1920  return Callback<R,T1,T2,T3,T4,T5> (impl);
1921 }
1922 template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1923  typename T1, typename T2,typename T3,typename T4,typename T5, typename T6>
1924 Callback<R,T1,T2,T3,T4,T5,T6> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4,T5,T6), ARG1 a1, ARG2 a2, ARG3 a3)
1925 {
1927  Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2,T3,T4,T5,T6),R,TX1,TX2,TX3,T1,T2,T3,T4,T5,T6> > (fnPtr, a1, a2, a3);
1928  return Callback<R,T1,T2,T3,T4,T5,T6> (impl);
1929 }
1933 } // namespace ns3
1934 
1935 namespace ns3 {
1936 
1938 {
1939 public:
1941  CallbackValue ();
1946  CallbackValue (const CallbackBase &base);
1948  virtual ~CallbackValue ();
1950  void Set (CallbackBase base);
1958  template <typename T>
1959  bool GetAccessor (T &value) const;
1961  virtual Ptr<AttributeValue> Copy (void) const;
1967  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
1975  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
1976 
1977 private:
1979 };
1980 
1983 
1984 } // namespace ns3
1985 
1986 namespace ns3 {
1987 
1988 template <typename T>
1989 bool CallbackValue::GetAccessor (T &value) const
1990 {
1991  if (value.CheckType (m_value))
1992  {
1993  if (!value.Assign (m_value))
1994  {
1996  }
1997  return true;
1998  }
1999  return false;
2000 }
2001 
2002 } // namespace ns3
2003 
2004 
2005 #endif /* CALLBACK_H */
NS_FATAL_x macro definitions.
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:205
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr...
Definition: ptr.h:405
CallbackValue()
Constructor.
Definition: callback.cc:34
static std::string GetCppTypeid(void)
Helper to get the C++ typeid as a string.
Definition: callback.h:139
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_FATAL_ERROR_CONT(msg)
Report a fatal error with a message, deferring termination.
Definition: fatal-error.h:181
virtual ~MemPtrCallbackImpl()
Definition: callback.h:610
Callback template class.
Definition: callback.h:1278
virtual ~BoundFunctorCallbackImpl()
Definition: callback.h:780
virtual ~FunctorCallbackImpl()
Definition: callback.h:446
ns3::Ptr smart pointer declaration and implementation.
Hold a value for an Attribute.
Definition: attribute.h:68
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:1033
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const =0
Equality test.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1703
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Serialize to string.
Definition: callback.cc:60
Callback< R, T3, T4, T5, T6, T7, T8, T9 > TwoBind(TX1 a1, TX2 a2)
Bind the first two arguments.
Definition: callback.h:1349
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:325
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:411
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:787
Callback< R, T2, T3, T4, T5, T6, T7, T8, T9 > Bind(T a)
Bind the first arguments.
Definition: callback.h:1329
Base class for Callback class.
Definition: callback.h:1195
MemPtrCallbackImpl(OBJ_PTR const &objPtr, MEM_PTR memPtr)
Construct from an object pointer and member function pointer.
Definition: callback.h:607
bool CheckType(const CallbackBase &other) const
Check for compatible types.
Definition: callback.h:1532
virtual ~CallbackValue()
Destructor.
Definition: callback.cc:42
bool Assign(const CallbackBase &other)
Adopt the other&#39;s implementation, if type compatible.
Definition: callback.h:1542
CallbackBase m_value
the CallbackBase
Definition: callback.h:1978
Callback< R, Ts... > MakeNullCallback(void)
Definition: callback.h:1682
bool IsEqual(const CallbackBase &other) const
Equality test.
Definition: callback.h:1521
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:572
CallbackImpl for functors with first three arguments bound at construction.
Definition: callback.h:1064
bool DoAssign(Ptr< const CallbackImplBase > other)
Adopt the other&#39;s implementation, if type compatible.
Definition: callback.h:1576
AttributeValue implementation for Callback.
Definition: callback.h:1937
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:1167
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:294
The unqualified CallbackImpl class.
Definition: callback.h:163
#define ATTRIBUTE_CHECKER_DEFINE(type)
Declare the AttributeChecker class typeChecker and the MaketypeChecker function for class type...
virtual std::string GetTypeid(void) const =0
Get the name of this object type.
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:274
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:453
TypeTraits< TX >::ReferencedType m_a
the bound argument
Definition: callback.h:908
make Callback use a separate empty type
Definition: empty.h:33
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:617
FunctorCallbackImpl(T const &functor)
Construct from a functor.
Definition: callback.h:443
Trait class to convert a pointer into a reference, used by MemPtrCallBackImpl.
Definition: callback.h:80
BoundFunctorCallbackImpl(FUNCTOR functor, ARG a)
Construct from functor and a bound argument.
Definition: callback.h:777
OBJ_PTR const m_objPtr
the object pointer
Definition: callback.h:753
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
MEM_PTR m_memPtr
the member function pointer
Definition: callback.h:754
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:352
virtual Ptr< AttributeValue > Copy(void) const
Definition: callback.cc:54
CallbackImpl for pointer to member functions.
Definition: callback.h:598
Callback< R, T4, T5, T6, T7, T8, T9 > ThreeBind(TX1 a1, TX2 a2, TX3 a3)
Bind the first three arguments.
Definition: callback.h:1371
Abstract base class for CallbackImpl Provides reference counting and equality test.
Definition: callback.h:107
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:380
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:245
CallbackImpl for functors with first two arguments bound at construction.
Definition: callback.h:919
R operator()(void) const
Functor with varying numbers of arguments.
Definition: callback.h:1401
Callback(Ptr< CallbackImpl< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > > const &impl)
Construct from a CallbackImpl pointer.
Definition: callback.h:1317
CallbackImpl< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > * DoPeekImpl(void) const
Definition: callback.h:1549
bool DoCheckType(Ptr< const CallbackImplBase > other) const
Check for compatible types.
Definition: callback.h:1559
TypeTraits< TX3 >::ReferencedType m_a3
third bound argument
Definition: callback.h:1187
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition: callback.h:1606
virtual ~CallbackImplBase()
Virtual destructor.
Definition: callback.h:111
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:409
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:347
#define NS_FATAL_ERROR_NO_MSG()
Report a fatal error and terminate.
Definition: fatal-error.h:128
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:179
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:222
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:269
static T & GetReference(T *const p)
Definition: callback.h:96
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:227
TypeTraits< TX1 >::ReferencedType m_a1
first bound argument
Definition: callback.h:1185
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:299
Callback(OBJ_PTR const &objPtr, MEM_PTR memPtr)
Construct a member function pointer call back.
Definition: callback.h:1308
Attribute helper (ATTRIBUTE_ )macros definition.
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:184
T m_functor
the functor
Definition: callback.h:588
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:250
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type.
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:945
virtual ~CallbackImpl()
Definition: callback.h:401
TypeTraits< TX1 >::ReferencedType m_a1
first bound argument
Definition: callback.h:1051
Inspect a type to deduce its features.
Definition: type-traits.h:39
The PHY layer is sending a packet.
Callback(FUNCTOR const &functor, bool, bool)
Construct a functor call back, supporting operator() calls.
Definition: callback.h:1295
CallbackImpl for functors with first argument bound at construction.
Definition: callback.h:764
TwoBoundFunctorCallbackImpl(FUNCTOR functor, ARG1 arg1, ARG2 arg2)
Construct from functor and two arguments.
Definition: callback.h:935
CallbackImpl with functors.
Definition: callback.h:435
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Deserialize from string (not implemented)
Definition: callback.cc:68
virtual R operator()(T1, T2, T3, T4, T5, T6, T7, T8, T9)=0
T m_functor
The functor.
Definition: callback.h:907
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:890
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:736
bool GetAccessor(T &value) const
Give value my callback, if type compatible.
Definition: callback.h:1989
void Nullify(void)
Discard the implementation, set it to null.
Definition: callback.h:1391
ns3::empty declaration, used by callbacks.
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:200
TypeTraits< TX2 >::ReferencedType m_a2
second bound argument
Definition: callback.h:1186
CallbackBase(Ptr< CallbackImplBase > impl)
Construct from a pimpl.
Definition: callback.h:1211
Ptr< CallbackImplBase > GetImpl(void) const
Definition: callback.h:1201
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
A template-based reference counting class.
static std::string Demangle(const std::string &mangled)
Definition: callback.cc:134
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:320
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:375
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
Ptr< CallbackImplBase > m_impl
the pimpl
Definition: callback.h:1213
void Set(CallbackBase base)
Definition: callback.cc:47
ns3::SimpleRefCount declaration and template implementation.
TypeTraits< TX2 >::ReferencedType m_a2
second bound argument
Definition: callback.h:1052
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:404
ns3::TypeTraits introspection declaration and template implementation.
ThreeBoundFunctorCallbackImpl(FUNCTOR functor, ARG1 arg1, ARG2 arg2, ARG3 arg3)
Construct from functor and three arguments.
Definition: callback.h:1083
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:1093