A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
callback.cc
Go to the documentation of this file.
1 #include "callback.h"
2 
3 namespace ns3 {
4 
6  : m_value ()
7 {
8 }
10  : m_value (base)
11 {
12 }
14 {
15 }
16 void
18 {
19  m_value = base;
20 }
22 CallbackValue::Copy (void) const
23 {
24  return Create<CallbackValue> (m_value);
25 }
26 std::string
28 {
29  std::ostringstream oss;
30  oss << PeekPointer (m_value.GetImpl ());
31  return oss.str ();
32 }
33 bool
35 {
36  return false;
37 }
38 
40 
41 } // namespace ns3
42 
43 #if (__GNUC__ >= 3)
44 
45 #include <stdlib.h>
46 #include <cxxabi.h>
47 #include "log.h"
48 
49 namespace ns3 {
50 
51 std::string
52 CallbackBase::Demangle (const std::string& mangled)
53 {
54  int status;
55  char* demangled = abi::__cxa_demangle (mangled.c_str (),
56  NULL, NULL, &status);
57 
58  std::string ret;
59  if (status == 0) {
60  NS_ASSERT (demangled);
61  ret = demangled;
62  }
63  else if (status == -1) {
64  NS_LOG_UNCOND ("Callback demangling failed: Memory allocation failure occured.");
65  ret = mangled;
66  }
67  else if (status == -2) {
68  NS_LOG_UNCOND ("Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules.");
69  ret = mangled;
70  }
71  else if (status == -3) {
72  NS_LOG_UNCOND ("Callback demangling failed: One of the arguments is invalid.");
73  ret = mangled;
74  }
75  else {
76  NS_LOG_UNCOND ("Callback demangling failed: status " << status);
77  ret = mangled;
78  }
79 
80  if (demangled) {
81  free (demangled);
82  }
83  return ret;
84 }
85 
86 } // namespace ns3
87 
88 #else
89 
90 std::string
91 ns3::CallbackBase::Demangle (const std::string& mangled)
92 {
93  return mangled;
94 }
95 
96 #endif
97