A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
#include "
log.h
"
3
4
NS_LOG_COMPONENT_DEFINE
(
"Callback"
);
5
6
namespace
ns3 {
7
8
CallbackValue::CallbackValue
()
9
: m_value ()
10
{
11
NS_LOG_FUNCTION
(
this
);
12
}
13
CallbackValue::CallbackValue
(
const
CallbackBase
&base)
14
: m_value (base)
15
{
16
}
17
CallbackValue::~CallbackValue
()
18
{
19
NS_LOG_FUNCTION
(
this
);
20
}
21
void
22
CallbackValue::Set
(
CallbackBase
base)
23
{
24
NS_LOG_FUNCTION
(&base);
25
26
m_value
= base;
27
}
28
Ptr<AttributeValue>
29
CallbackValue::Copy
(
void
)
const
30
{
31
NS_LOG_FUNCTION
(
this
);
32
return
Create<CallbackValue> (
m_value
);
33
}
34
std::string
35
CallbackValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
36
{
37
NS_LOG_FUNCTION
(
this
<< checker);
38
std::ostringstream oss;
39
oss <<
PeekPointer
(
m_value
.
GetImpl
());
40
return
oss.str ();
41
}
42
bool
43
CallbackValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
44
{
45
NS_LOG_FUNCTION
(
this
<< value << checker);
46
return
false
;
47
}
48
50
ATTRIBUTE_CHECKER_IMPLEMENT
(
Callback
);
51
52
}
// namespace ns3
53
54
#if (__GNUC__ >= 3)
55
56
#include <cstdlib>
57
#include <cxxabi.h>
58
#include "
log.h
"
59
60
namespace
ns3 {
61
62
std::string
63
CallbackBase::Demangle
(
const
std::string& mangled)
64
{
65
NS_LOG_FUNCTION
(mangled);
66
67
int
status;
68
char
* demangled = abi::__cxa_demangle (mangled.c_str (),
69
NULL, NULL, &status);
70
71
std::string ret;
72
if
(status == 0) {
73
NS_ASSERT
(demangled);
74
ret = demangled;
75
}
76
else
if
(status == -1) {
77
NS_LOG_UNCOND
(
"Callback demangling failed: Memory allocation failure occured."
);
78
ret = mangled;
79
}
80
else
if
(status == -2) {
81
NS_LOG_UNCOND
(
"Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules."
);
82
ret = mangled;
83
}
84
else
if
(status == -3) {
85
NS_LOG_UNCOND
(
"Callback demangling failed: One of the arguments is invalid."
);
86
ret = mangled;
87
}
88
else
{
89
NS_LOG_UNCOND
(
"Callback demangling failed: status "
<< status);
90
ret = mangled;
91
}
92
93
if
(demangled) {
94
std::free (demangled);
95
}
96
return
ret;
97
}
98
99
}
// namespace ns3
100
101
#else
102
103
std::string
104
ns3::CallbackBase::Demangle
(
const
std::string& mangled)
105
{
106
NS_LOG_FUNCTION
(
this
<< mangled);
107
return
mangled;
108
}
109
110
#endif
111
ns3::CallbackValue::CallbackValue
CallbackValue()
Definition:
callback.cc:8
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::Callback
Callback template class.
Definition:
callback.h:920
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::CallbackBase
Base class for Callback class.
Definition:
callback.h:844
ns3::CallbackValue::~CallbackValue
virtual ~CallbackValue()
Definition:
callback.cc:17
ns3::ATTRIBUTE_CHECKER_IMPLEMENT
ATTRIBUTE_CHECKER_IMPLEMENT(Callback)
Attribute checker.
callback.h
ns3::CallbackValue::m_value
CallbackBase m_value
the CallbackBase
Definition:
callback.h:1695
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("Callback")
ns3::PeekPointer
T * PeekPointer(const Ptr< T > &p)
Definition:
ptr.h:279
ns3::CallbackBase::Demangle
static std::string Demangle(const std::string &mangled)
Definition:
callback.cc:104
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Definition:
log.h:377
ns3::CallbackValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Deserialize from string (not implemented)
Definition:
callback.cc:43
ns3::CallbackValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Serialize to string.
Definition:
callback.cc:35
log.h
ns3::CallbackValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
callback.cc:29
ns3::CallbackValue::Set
void Set(CallbackBase base)
Definition:
callback.cc:22
ns3::CallbackBase::GetImpl
Ptr< CallbackImplBase > GetImpl(void) const
Definition:
callback.h:848
src
core
model
callback.cc
Generated on Sat Apr 19 2014 14:06:51 for ns-3 by
1.8.6