A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
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
24
/**
25
* \file
26
* \ingroup callback
27
* ns3::CallbackValue implementation.
28
*/
29
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
& value)
42
: m_value(value)
43
{
44
}
45
46
CallbackValue::~CallbackValue
()
47
{
48
NS_LOG_FUNCTION
(
this
);
49
}
50
51
void
52
CallbackValue::Set
(
const
CallbackBase
& value)
53
{
54
NS_LOG_FUNCTION
(&value);
55
m_value
= value;
56
}
57
58
CallbackBase
59
CallbackValue::Get
()
60
{
61
NS_LOG_FUNCTION
(
this
);
62
return
m_value
;
63
}
64
65
Ptr<AttributeValue>
66
CallbackValue::Copy
()
const
67
{
68
NS_LOG_FUNCTION
(
this
);
69
return
Create<CallbackValue>(
m_value
);
70
}
71
72
std::string
73
CallbackValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
74
{
75
NS_LOG_FUNCTION
(
this
<< checker);
76
std::ostringstream oss;
77
oss <<
PeekPointer
(
m_value
.
GetImpl
());
78
return
oss.str();
79
}
80
81
bool
82
CallbackValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
83
{
84
NS_LOG_FUNCTION
(
this
<< value << checker);
85
return
false
;
86
}
87
88
ATTRIBUTE_CHECKER_IMPLEMENT
(
Callback
);
89
90
}
// namespace ns3
91
92
#if (__GNUC__ >= 3)
93
94
#include <cstdlib>
95
#include <cxxabi.h>
96
97
namespace
ns3
98
{
99
100
std::string
101
CallbackImplBase::Demangle
(
const
std::string& mangled)
102
{
103
NS_LOG_FUNCTION
(mangled);
104
105
int
status;
106
char
* demangled = abi::__cxa_demangle(mangled.c_str(),
nullptr
,
nullptr
, &status);
107
108
std::string ret;
109
if
(status == 0)
110
{
111
NS_ASSERT
(demangled);
112
ret = demangled;
113
}
114
else
if
(status == -1)
115
{
116
NS_LOG_UNCOND
(
"Callback demangling failed: Memory allocation failure occurred."
);
117
ret = mangled;
118
}
119
else
if
(status == -2)
120
{
121
NS_LOG_UNCOND
(
"Callback demangling failed: Mangled name is not a valid under the C++ ABI "
122
"mangling rules."
);
123
ret = mangled;
124
}
125
else
if
(status == -3)
126
{
127
NS_LOG_UNCOND
(
"Callback demangling failed: One of the arguments is invalid."
);
128
ret = mangled;
129
}
130
else
131
{
132
NS_LOG_UNCOND
(
"Callback demangling failed: status "
<< status);
133
ret = mangled;
134
}
135
136
if
(demangled)
137
{
138
std::free(demangled);
139
}
140
return
ret;
141
}
142
143
}
// namespace ns3
144
145
#else
146
147
std::string
148
ns3::CallbackImplBase::Demangle
(
const
std::string& mangled)
149
{
150
NS_LOG_FUNCTION
(
this
<< mangled);
151
return
mangled;
152
}
153
154
#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:148
ns3::CallbackValue::DeserializeFromString
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Deserialize from string (not implemented)
Definition:
callback.cc:82
ns3::CallbackValue::Get
CallbackBase Get()
Definition:
callback.cc:59
ns3::CallbackValue::SerializeToString
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Serialize to string.
Definition:
callback.cc:73
ns3::CallbackValue::Set
void Set(const CallbackBase &value)
Set the value.
Definition:
callback.cc:52
ns3::CallbackValue::CallbackValue
CallbackValue()
Definition:
callback.cc:35
ns3::CallbackValue::m_value
CallbackBase m_value
The stored Callback instance.
Definition:
callback.h:831
ns3::CallbackValue::Copy
Ptr< AttributeValue > Copy() const override
Definition:
callback.cc:66
ns3::CallbackValue::~CallbackValue
~CallbackValue() override
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:454
src
core
model
callback.cc
Generated on Tue May 28 2024 23:34:26 for ns-3 by
1.9.6