A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
callback.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005,2006 INRIA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
20
#include "
callback.h
"
21
22
#include "
log.h
"
23
30
namespace
ns3
31
{
32
33
NS_LOG_COMPONENT_DEFINE
(
"Callback"
);
34
35
CallbackValue::CallbackValue
()
36
: m_value()
37
{
38
NS_LOG_FUNCTION
(
this
);
39
}
40
41
CallbackValue::CallbackValue
(
const
CallbackBase
& base)
42
: m_value(base)
43
{
44
}
45
46
CallbackValue::~CallbackValue
()
47
{
48
NS_LOG_FUNCTION
(
this
);
49
}
50
51
void
52
CallbackValue::Set
(
CallbackBase
base)
53
{
54
NS_LOG_FUNCTION
(&base);
55
56
m_value
= base;
57
}
58
59
Ptr<AttributeValue>
60
CallbackValue::Copy
()
const
61
{
62
NS_LOG_FUNCTION
(
this
);
63
return
Create<CallbackValue>(
m_value
);
64
}
65
66
std::string
67
CallbackValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
68
{
69
NS_LOG_FUNCTION
(
this
<< checker);
70
std::ostringstream oss;
71
oss <<
PeekPointer
(
m_value
.
GetImpl
());
72
return
oss.str();
73
}
74
75
bool
76
CallbackValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
77
{
78
NS_LOG_FUNCTION
(
this
<< value << checker);
79
return
false
;
80
}
81
82
ATTRIBUTE_CHECKER_IMPLEMENT
(
Callback
);
83
84
}
// namespace ns3
85
86
#if (__GNUC__ >= 3)
87
88
#include <cstdlib>
89
#include <cxxabi.h>
90
91
namespace
ns3
92
{
93
94
std::string
95
CallbackImplBase::Demangle
(
const
std::string& mangled)
96
{
97
NS_LOG_FUNCTION
(mangled);
98
99
int
status;
100
char
* demangled = abi::__cxa_demangle(mangled.c_str(),
nullptr
,
nullptr
, &status);
101
102
std::string ret;
103
if
(status == 0)
104
{
105
NS_ASSERT
(demangled);
106
ret = demangled;
107
}
108
else
if
(status == -1)
109
{
110
NS_LOG_UNCOND
(
"Callback demangling failed: Memory allocation failure occurred."
);
111
ret = mangled;
112
}
113
else
if
(status == -2)
114
{
115
NS_LOG_UNCOND
(
"Callback demangling failed: Mangled name is not a valid under the C++ ABI "
116
"mangling rules."
);
117
ret = mangled;
118
}
119
else
if
(status == -3)
120
{
121
NS_LOG_UNCOND
(
"Callback demangling failed: One of the arguments is invalid."
);
122
ret = mangled;
123
}
124
else
125
{
126
NS_LOG_UNCOND
(
"Callback demangling failed: status "
<< status);
127
ret = mangled;
128
}
129
130
if
(demangled)
131
{
132
std::free(demangled);
133
}
134
return
ret;
135
}
136
137
}
// namespace ns3
138
139
#else
140
141
std::string
142
ns3::CallbackImplBase::Demangle
(
const
std::string& mangled)
143
{
144
NS_LOG_FUNCTION
(
this
<< mangled);
145
return
mangled;
146
}
147
148
#endif
callback.h
Declaration of the various callback functions.
ns3::CallbackBase
Base class for Callback class.
Definition:
callback.h:360
ns3::CallbackBase::GetImpl
Ptr< CallbackImplBase > GetImpl() const
Definition:
callback.h:368
ns3::Callback
Callback template class.
Definition:
callback.h:438
ns3::CallbackImplBase::Demangle
static std::string Demangle(const std::string &mangled)
Definition:
callback.cc:142
ns3::CallbackValue::DeserializeFromString
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Deserialize from string (not implemented)
Definition:
callback.cc:76
ns3::CallbackValue::SerializeToString
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Serialize to string.
Definition:
callback.cc:67
ns3::CallbackValue::Set
void Set(CallbackBase base)
Definition:
callback.cc:52
ns3::CallbackValue::CallbackValue
CallbackValue()
Constructor.
Definition:
callback.cc:35
ns3::CallbackValue::m_value
CallbackBase m_value
Definition:
callback.h:841
ns3::CallbackValue::Copy
Ptr< AttributeValue > Copy() const override
Definition:
callback.cc:60
ns3::CallbackValue::~CallbackValue
~CallbackValue() override
Destructor.
Definition:
callback.cc:46
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
ATTRIBUTE_CHECKER_IMPLEMENT
#define ATTRIBUTE_CHECKER_IMPLEMENT(type)
Define the MaketypeChecker function for class type.
Definition:
attribute-helper.h:361
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Definition:
log-macros-enabled.h:264
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:240
log.h
Debug message logging.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::PeekPointer
U * PeekPointer(const Ptr< U > &p)
Definition:
ptr.h:449
src
core
model
callback.cc
Generated on Sun Mar 3 2024 17:10:55 for ns-3 by
1.9.1