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
39namespace ns3 {
40
41// Define the doxygen subgroups all at once,
42// since the implementations are interleaved.
43
79template <typename T>
81
89template <typename T>
90struct CallbackTraits<T *>
91{
96 static T & GetReference (T * const p)
97 {
98 return *p;
99 }
100};
101
107class CallbackImplBase : public SimpleRefCount<CallbackImplBase>
108{
109public:
112 {}
119 virtual bool IsEqual (Ptr<const CallbackImplBase> other) const = 0;
124 virtual std::string GetTypeid (void) const = 0;
125
126protected:
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
162template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
163class CallbackImpl;
164
172template <typename R>
174{
175public:
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};
193template <typename R, typename T1>
195{
196public:
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};
215template <typename R, typename T1, typename T2>
217{
218public:
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};
238template <typename R, typename T1, typename T2, typename T3>
240{
241public:
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};
262template <typename R, typename T1, typename T2, typename T3, typename T4>
264{
265public:
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};
287template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5>
288class CallbackImpl<R,T1,T2,T3,T4,T5,empty,empty,empty,empty> : public CallbackImplBase
289{
290public:
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};
313template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
314class CallbackImpl<R,T1,T2,T3,T4,T5,T6,empty,empty,empty> : public CallbackImplBase
315{
316public:
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};
340template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
341class CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,empty,empty> : public CallbackImplBase
342{
343public:
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};
368template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
369class CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,empty> : public CallbackImplBase
370{
371public:
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};
397template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
399{
400public:
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};
434template <typename T, typename R, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6, typename T7, typename T8, typename T9>
435class FunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9>
436{
437public:
443 FunctorCallbackImpl (T const &functor)
444 : m_functor (functor)
445 {}
447 {}
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
587private:
589};
590
597template <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>
598class MemPtrCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9>
599{
600public:
607 MemPtrCallbackImpl (OBJ_PTR const&objPtr, MEM_PTR memPtr)
608 : m_objPtr (objPtr), m_memPtr (memPtr)
609 {}
611 {}
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 {
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
752private:
753 OBJ_PTR const m_objPtr;
754 MEM_PTR m_memPtr;
755};
756
763template <typename T, typename R, typename TX, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6, typename T7, typename T8>
764class BoundFunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,empty>
765{
766public:
776 template <typename FUNCTOR, typename ARG>
777 BoundFunctorCallbackImpl (FUNCTOR functor, ARG a)
778 : m_functor (functor), m_a (a)
779 {}
781 {}
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
906private:
909};
910
918template <typename T, typename R, typename TX1, typename TX2, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6, typename T7>
919class TwoBoundFunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,empty,empty>
920{
921public:
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 {}
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
1049private:
1053};
1054
1063template <typename T, typename R, typename TX1, typename TX2, typename TX3, typename T1, typename T2, typename T3, typename T4,typename T5, typename T6>
1064class ThreeBoundFunctorCallbackImpl : public CallbackImpl<R,T1,T2,T3,T4,T5,T6,empty,empty,empty>
1065{
1066public:
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 {}
1094 {
1095 return m_functor (m_a1,m_a2,m_a3);
1096 }
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
1183private:
1188};
1189
1196{
1197public:
1199 {}
1202 {
1203 return m_impl;
1204 }
1205
1206protected:
1212 {}
1214};
1215
1272template<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>
1279{
1280public:
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);
1357 }
1358
1370 template <typename TX1, typename TX2, typename TX3>
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);
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
1547private:
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 }
1575 /* Broken: \copydoc Callback::Assign() */
1583 {
1584 if (!DoCheckType (other))
1585 {
1586 std::string othTid = other->GetTypeid ();
1588 NS_FATAL_ERROR_CONT ("Incompatible types. (feed to \"c++filt -t\" if needed)" << std::endl <<
1589 "got=" << othTid << std::endl <<
1590 "expected=" << myTid);
1591 return false;
1592 }
1593 m_impl = const_cast<CallbackImplBase *> (PeekPointer (other));
1594 return true;
1595 }
1596};
1597
1598
1607template <typename R, typename T1, typename T2,
1608 typename T3, typename T4,
1609 typename T5, typename T6,
1610 typename T7, typename T8,
1611 typename T9>
1613{
1614 return !a.IsEqual (b);
1615}
1616
1647template <typename T, typename OBJ, typename R, typename... Ts>
1648Callback<R,Ts...> MakeCallback (R (T::*memPtr)(Ts...), OBJ objPtr)
1649{
1650 return Callback<R,Ts...> (objPtr, memPtr);
1651}
1652template <typename T, typename OBJ, typename R, typename... Ts>
1653Callback<R,Ts...> MakeCallback (R (T::*memPtr)(Ts...) const, OBJ objPtr)
1654{
1655 return Callback<R,Ts...> (objPtr, memPtr);
1656}
1670template <typename R, typename... Ts>
1671Callback<R,Ts...> MakeCallback (R (*fnPtr)(Ts...))
1672{
1673 return Callback<R,Ts...> (fnPtr, true, true);
1674}
1675
1687template <typename R, typename... Ts>
1689{
1690 return Callback<R,Ts...> ();
1691}
1692
1693
1708template <typename R, typename TX, typename ARG>
1709Callback<R> MakeBoundCallback (R (*fnPtr)(TX), ARG a1)
1710{
1713 return Callback<R> (impl);
1714}
1715template <typename R, typename TX, typename ARG,
1716 typename T1>
1717Callback<R,T1> MakeBoundCallback (R (*fnPtr)(TX,T1), ARG a1)
1718{
1720 Create<BoundFunctorCallbackImpl<R (*)(TX,T1),R,TX,T1,empty,empty,empty,empty,empty,empty,empty> > (fnPtr, a1);
1721 return Callback<R,T1> (impl);
1722}
1723template <typename R, typename TX, typename ARG,
1724 typename T1, typename T2>
1725Callback<R,T1,T2> MakeBoundCallback (R (*fnPtr)(TX,T1,T2), ARG a1)
1726{
1728 Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2),R,TX,T1,T2,empty,empty,empty,empty,empty,empty> > (fnPtr, a1);
1729 return Callback<R,T1,T2> (impl);
1730}
1731template <typename R, typename TX, typename ARG,
1732 typename T1, typename T2,typename T3>
1733Callback<R,T1,T2,T3> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3), ARG a1)
1734{
1736 Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3),R,TX,T1,T2,T3,empty,empty,empty,empty,empty> > (fnPtr, a1);
1737 return Callback<R,T1,T2,T3> (impl);
1738}
1739template <typename R, typename TX, typename ARG,
1740 typename T1, typename T2,typename T3,typename T4>
1741Callback<R,T1,T2,T3,T4> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4), ARG a1)
1742{
1744 Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4),R,TX,T1,T2,T3,T4,empty,empty,empty,empty> > (fnPtr, a1);
1745 return Callback<R,T1,T2,T3,T4> (impl);
1746}
1747template <typename R, typename TX, typename ARG,
1748 typename T1, typename T2,typename T3,typename T4,typename T5>
1749Callback<R,T1,T2,T3,T4,T5> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5), ARG a1)
1750{
1752 Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5),R,TX,T1,T2,T3,T4,T5,empty,empty,empty> > (fnPtr, a1);
1753 return Callback<R,T1,T2,T3,T4,T5> (impl);
1754}
1755template <typename R, typename TX, typename ARG,
1756 typename T1, typename T2,typename T3,typename T4,typename T5, typename T6>
1757Callback<R,T1,T2,T3,T4,T5,T6> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6), ARG a1)
1758{
1760 Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5,T6),R,TX,T1,T2,T3,T4,T5,T6,empty,empty> > (fnPtr, a1);
1761 return Callback<R,T1,T2,T3,T4,T5,T6> (impl);
1762}
1763template <typename R, typename TX, typename ARG,
1764 typename T1, typename T2,typename T3,typename T4,typename T5, typename T6, typename T7>
1765Callback<R,T1,T2,T3,T4,T5,T6,T7> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7), ARG a1)
1766{
1768 Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5,T6,T7),R,TX,T1,T2,T3,T4,T5,T6,T7,empty> > (fnPtr, a1);
1770}
1771template <typename R, typename TX, typename ARG,
1772 typename T1, typename T2,typename T3,typename T4,typename T5, typename T6, typename T7, typename T8>
1773Callback<R,T1,T2,T3,T4,T5,T6,T7,T8> MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7,T8), ARG a1)
1774{
1776 Create<BoundFunctorCallbackImpl<R (*)(TX,T1,T2,T3,T4,T5,T6,T7,T8),R,TX,T1,T2,T3,T4,T5,T6,T7,T8> > (fnPtr, a1);
1778}
1797template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2>
1798Callback<R> MakeBoundCallback (R (*fnPtr)(TX1,TX2), ARG1 a1, ARG2 a2)
1799{
1801 Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2),R,TX1,TX2,empty,empty,empty,empty,empty,empty,empty> > (fnPtr, a1, a2);
1802 return Callback<R> (impl);
1803}
1804template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1805 typename T1>
1806Callback<R,T1> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1), ARG1 a1, ARG2 a2)
1807{
1809 Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1),R,TX1,TX2,T1,empty,empty,empty,empty,empty,empty> > (fnPtr, a1, a2);
1810 return Callback<R,T1> (impl);
1811}
1812template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1813 typename T1, typename T2>
1814Callback<R,T1,T2> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2), ARG1 a1, ARG2 a2)
1815{
1817 Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2),R,TX1,TX2,T1,T2,empty,empty,empty,empty,empty> > (fnPtr, a1, a2);
1818 return Callback<R,T1,T2> (impl);
1819}
1820template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1821 typename T1, typename T2,typename T3>
1822Callback<R,T1,T2,T3> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3), ARG1 a1, ARG2 a2)
1823{
1825 Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3),R,TX1,TX2,T1,T2,T3,empty,empty,empty,empty> > (fnPtr, a1, a2);
1826 return Callback<R,T1,T2,T3> (impl);
1827}
1828template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1829 typename T1, typename T2,typename T3,typename T4>
1830Callback<R,T1,T2,T3,T4> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4), ARG1 a1, ARG2 a2)
1831{
1833 Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3,T4),R,TX1,TX2,T1,T2,T3,T4,empty,empty,empty> > (fnPtr, a1, a2);
1834 return Callback<R,T1,T2,T3,T4> (impl);
1835}
1836template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1837 typename T1, typename T2,typename T3,typename T4,typename T5>
1838Callback<R,T1,T2,T3,T4,T5> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2)
1839{
1841 Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3,T4,T5),R,TX1,TX2,T1,T2,T3,T4,T5,empty,empty> > (fnPtr, a1, a2);
1842 return Callback<R,T1,T2,T3,T4,T5> (impl);
1843}
1844template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1845 typename T1, typename T2,typename T3,typename T4,typename T5, typename T6>
1846Callback<R,T1,T2,T3,T4,T5,T6> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6), ARG1 a1, ARG2 a2)
1847{
1849 Create<TwoBoundFunctorCallbackImpl<R (*)(TX1,TX2,T1,T2,T3,T4,T5,T6),R,TX1,TX2,T1,T2,T3,T4,T5,T6,empty> > (fnPtr, a1, a2);
1850 return Callback<R,T1,T2,T3,T4,T5,T6> (impl);
1851}
1852template <typename R, typename TX1, typename TX2, typename ARG1, typename ARG2,
1853 typename T1, typename T2,typename T3,typename T4,typename T5, typename T6, typename T7>
1854Callback<R,T1,T2,T3,T4,T5,T6,T7> MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6,T7), ARG1 a1, ARG2 a2)
1855{
1857 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);
1859}
1881template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3>
1882Callback<R> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3), ARG1 a1, ARG2 a2, ARG3 a3)
1883{
1885 Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3),R,TX1,TX2,TX3,empty,empty,empty,empty,empty,empty> > (fnPtr, a1, a2, a3);
1886 return Callback<R> (impl);
1887}
1888template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1889 typename T1>
1890Callback<R,T1> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1), ARG1 a1, ARG2 a2, ARG3 a3)
1891{
1893 Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1),R,TX1,TX2,TX3,T1,empty,empty,empty,empty,empty> > (fnPtr, a1, a2, a3);
1894 return Callback<R,T1> (impl);
1895}
1896template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1897 typename T1, typename T2>
1898Callback<R,T1,T2> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2), ARG1 a1, ARG2 a2, ARG3 a3)
1899{
1901 Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2),R,TX1,TX2,TX3,T1,T2,empty,empty,empty,empty> > (fnPtr, a1, a2, a3);
1902 return Callback<R,T1,T2> (impl);
1903}
1904template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1905 typename T1, typename T2,typename T3>
1906Callback<R,T1,T2,T3> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3), ARG1 a1, ARG2 a2, ARG3 a3)
1907{
1909 Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2,T3),R,TX1,TX2,TX3,T1,T2,T3,empty,empty,empty> > (fnPtr, a1, a2, a3);
1910 return Callback<R,T1,T2,T3> (impl);
1911}
1912template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1913 typename T1, typename T2,typename T3,typename T4>
1914Callback<R,T1,T2,T3,T4> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4), ARG1 a1, ARG2 a2, ARG3 a3)
1915{
1917 Create<ThreeBoundFunctorCallbackImpl<R (*)(TX1,TX2,TX3,T1,T2,T3,T4),R,TX1,TX2,TX3,T1,T2,T3,T4,empty,empty> > (fnPtr, a1, a2, a3);
1918 return Callback<R,T1,T2,T3,T4> (impl);
1919}
1920template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1921 typename T1, typename T2,typename T3,typename T4,typename T5>
1922Callback<R,T1,T2,T3,T4,T5> MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2, ARG3 a3)
1923{
1925 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);
1926 return Callback<R,T1,T2,T3,T4,T5> (impl);
1927}
1928template <typename R, typename TX1, typename TX2, typename TX3, typename ARG1, typename ARG2, typename ARG3,
1929 typename T1, typename T2,typename T3,typename T4,typename T5, typename T6>
1930Callback<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)
1931{
1933 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);
1934 return Callback<R,T1,T2,T3,T4,T5,T6> (impl);
1935}
1939} // namespace ns3
1940
1941namespace ns3 {
1942
1944{
1945public:
1947 CallbackValue ();
1952 CallbackValue (const CallbackBase &base);
1954 virtual ~CallbackValue ();
1956 void Set (CallbackBase base);
1957 /* Documented by print-introspected-doxygen.cc */
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
1977private:
1978 /* Documented by print-introspected-doxygen.cc */
1980};
1981
1984
1985} // namespace ns3
1986
1987namespace ns3 {
1988
1989template <typename T>
1990bool CallbackValue::GetAccessor (T &value) const
1991{
1992 if (value.CheckType (m_value))
1993 {
1994 if (!value.Assign (m_value))
1995 {
1997 }
1998 return true;
1999 }
2000 return false;
2001}
2002
2003} // namespace ns3
2004
2005
2006#endif /* CALLBACK_H */
Attribute helper (ATTRIBUTE_ )macros definition.
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Hold a value for an Attribute.
Definition: attribute.h:69
CallbackImpl for functors with first argument bound at construction.
Definition: callback.h:765
virtual ~BoundFunctorCallbackImpl()
Definition: callback.h:780
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:787
TypeTraits< TX >::ReferencedType m_a
the bound argument
Definition: callback.h:908
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:890
BoundFunctorCallbackImpl(FUNCTOR functor, ARG a)
Construct from functor and a bound argument.
Definition: callback.h:777
Base class for Callback class.
Definition: callback.h:1196
CallbackBase(Ptr< CallbackImplBase > impl)
Construct from a pimpl.
Definition: callback.h:1211
Ptr< CallbackImplBase > GetImpl(void) const
Definition: callback.h:1201
Ptr< CallbackImplBase > m_impl
the pimpl
Definition: callback.h:1213
Callback template class.
Definition: callback.h:1279
Callback(Ptr< CallbackImpl< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > > const &impl)
Construct from a CallbackImpl pointer.
Definition: callback.h:1317
R operator()(void) const
Functor with varying numbers of arguments.
Definition: callback.h:1401
bool Assign(const CallbackBase &other)
Adopt the other's implementation, if type compatible.
Definition: callback.h:1542
bool DoAssign(Ptr< const CallbackImplBase > other)
Adopt the other's implementation, if type compatible.
Definition: callback.h:1582
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
Callback(OBJ_PTR const &objPtr, MEM_PTR memPtr)
Construct a member function pointer call back.
Definition: callback.h:1308
Callback< R, T2, T3, T4, T5, T6, T7, T8, T9 > Bind(T a)
Bind the first arguments.
Definition: callback.h:1329
Callback< R, T3, T4, T5, T6, T7, T8, T9 > TwoBind(TX1 a1, TX2 a2)
Bind the first two arguments.
Definition: callback.h:1349
bool DoCheckType(Ptr< const CallbackImplBase > other) const
Check for compatible types.
Definition: callback.h:1559
CallbackImpl< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > * DoPeekImpl(void) const
Definition: callback.h:1549
Callback(FUNCTOR const &functor, bool, bool)
Construct a functor call back, supporting operator() calls.
Definition: callback.h:1295
bool CheckType(const CallbackBase &other) const
Check for compatible types.
Definition: callback.h:1532
void Nullify(void)
Discard the implementation, set it to null.
Definition: callback.h:1391
Callback< R, T4, T5, T6, T7, T8, T9 > ThreeBind(TX1 a1, TX2 a2, TX3 a3)
Bind the first three arguments.
Definition: callback.h:1371
bool IsEqual(const CallbackBase &other) const
Equality test.
Definition: callback.h:1521
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:375
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:347
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:352
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:320
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:325
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:294
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:299
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:274
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:269
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:245
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:250
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:227
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:200
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:205
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:179
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:184
Abstract base class for CallbackImpl Provides reference counting and equality test.
Definition: callback.h:108
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const =0
Equality test.
static std::string GetCppTypeid(void)
Helper to get the C++ typeid as a string.
Definition: callback.h:139
virtual ~CallbackImplBase()
Virtual destructor.
Definition: callback.h:111
virtual std::string GetTypeid(void) const =0
Get the name of this object type.
static std::string Demangle(const std::string &mangled)
Definition: callback.cc:134
The unqualified CallbackImpl class.
Definition: callback.h:399
virtual R operator()(T1, T2, T3, T4, T5, T6, T7, T8, T9)=0
virtual std::string GetTypeid(void) const
Get the name of this object type.
Definition: callback.h:404
virtual ~CallbackImpl()
Definition: callback.h:401
static std::string DoGetTypeid(void)
Get the name of this object type.
Definition: callback.h:409
AttributeValue implementation for Callback.
Definition: callback.h:1944
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Serialize to string.
Definition: callback.cc:60
void Set(CallbackBase base)
Definition: callback.cc:47
CallbackValue()
Constructor.
Definition: callback.cc:34
bool GetAccessor(T &value) const
Access the Callback value as type T.
Definition: callback.h:1990
virtual Ptr< AttributeValue > Copy(void) const
Definition: callback.cc:54
virtual ~CallbackValue()
Destructor.
Definition: callback.cc:42
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Deserialize from string (not implemented)
Definition: callback.cc:68
CallbackBase m_value
The stored Callback instance.
Definition: callback.h:1979
CallbackImpl with functors.
Definition: callback.h:436
T m_functor
the functor
Definition: callback.h:588
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:453
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:572
virtual ~FunctorCallbackImpl()
Definition: callback.h:446
FunctorCallbackImpl(T const &functor)
Construct from a functor.
Definition: callback.h:443
CallbackImpl for pointer to member functions.
Definition: callback.h:599
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:617
MEM_PTR m_memPtr
the member function pointer
Definition: callback.h:754
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:736
OBJ_PTR const m_objPtr
the object pointer
Definition: callback.h:753
MemPtrCallbackImpl(OBJ_PTR const &objPtr, MEM_PTR memPtr)
Construct from an object pointer and member function pointer.
Definition: callback.h:607
virtual ~MemPtrCallbackImpl()
Definition: callback.h:610
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
A template-based reference counting class.
CallbackImpl for functors with first three arguments bound at construction.
Definition: callback.h:1065
TypeTraits< TX1 >::ReferencedType m_a1
first bound argument
Definition: callback.h:1185
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:1093
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:1167
TypeTraits< TX3 >::ReferencedType m_a3
third bound argument
Definition: callback.h:1187
TypeTraits< TX2 >::ReferencedType m_a2
second bound argument
Definition: callback.h:1186
ThreeBoundFunctorCallbackImpl(FUNCTOR functor, ARG1 arg1, ARG2 arg2, ARG3 arg3)
Construct from functor and three arguments.
Definition: callback.h:1083
CallbackImpl for functors with first two arguments bound at construction.
Definition: callback.h:920
TwoBoundFunctorCallbackImpl(FUNCTOR functor, ARG1 arg1, ARG2 arg2)
Construct from functor and two arguments.
Definition: callback.h:935
virtual bool IsEqual(Ptr< const CallbackImplBase > other) const
Equality test.
Definition: callback.h:1033
TypeTraits< TX2 >::ReferencedType m_a2
second bound argument
Definition: callback.h:1052
TypeTraits< TX1 >::ReferencedType m_a1
first bound argument
Definition: callback.h:1051
R operator()(void)
Functor with varying numbers of arguments.
Definition: callback.h:945
make Callback use a separate empty type
Definition: empty.h:34
ns3::empty declaration, used by callbacks.
NS_FATAL_x macro definitions.
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type.
#define ATTRIBUTE_CHECKER_DEFINE(type)
Declare the AttributeChecker class typeChecker and the MaketypeChecker function for class type.
Callback< R, Ts... > MakeNullCallback(void)
Definition: callback.h:1688
#define NS_FATAL_ERROR_CONT(msg)
Report a fatal error with a message, deferring termination.
Definition: fatal-error.h:181
#define NS_FATAL_ERROR_NO_MSG()
Report a fatal error and terminate.
Definition: fatal-error.h:128
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1709
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition: ptr.h:409
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:415
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:1612
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:1648
ns3::Ptr smart pointer declaration and implementation.
ns3::SimpleRefCount declaration and template implementation.
static T & GetReference(T *const p)
Definition: callback.h:96
Trait class to convert a pointer into a reference, used by MemPtrCallBackImpl.
Definition: callback.h:80
Inspect a type to deduce its features.
Definition: type-traits.h:40
ns3::TypeTraits introspection declaration and template implementation.
@ TX
The PHY layer is sending a packet.