A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
callback.cc
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
#include "
callback.h
"
22
#include "
log.h
"
23
30
namespace
ns3
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"Callback"
);
33
34
CallbackValue::CallbackValue
()
35
: m_value ()
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
CallbackValue::CallbackValue
(
const
CallbackBase
&base)
40
: m_value (base)
41
{}
42
CallbackValue::~CallbackValue
()
43
{
44
NS_LOG_FUNCTION
(
this
);
45
}
46
void
47
CallbackValue::Set
(
CallbackBase
base)
48
{
49
NS_LOG_FUNCTION
(&base);
50
51
m_value
= base;
52
}
53
Ptr<AttributeValue>
54
CallbackValue::Copy
(
void
)
const
55
{
56
NS_LOG_FUNCTION
(
this
);
57
return
Create<CallbackValue> (
m_value
);
58
}
59
std::string
60
CallbackValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
61
{
62
NS_LOG_FUNCTION
(
this
<< checker);
63
std::ostringstream oss;
64
oss <<
PeekPointer
(
m_value
.
GetImpl
());
65
return
oss.str ();
66
}
67
bool
68
CallbackValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
69
{
70
NS_LOG_FUNCTION
(
this
<< value << checker);
71
return
false
;
72
}
73
74
ATTRIBUTE_CHECKER_IMPLEMENT
(
Callback
);
75
76
}
// namespace ns3
77
78
#if (__GNUC__ >= 3)
79
80
#include <cstdlib>
81
#include <cxxabi.h>
82
#include "
log.h
"
83
84
namespace
ns3
{
85
86
std::string
87
CallbackImplBase::Demangle
(
const
std::string& mangled)
88
{
89
NS_LOG_FUNCTION
(mangled);
90
91
int
status;
92
char
* demangled = abi::__cxa_demangle (mangled.c_str (),
93
NULL, NULL, &status);
94
95
std::string ret;
96
if
(status == 0)
97
{
98
NS_ASSERT
(demangled);
99
ret = demangled;
100
}
101
else
if
(status == -1)
102
{
103
NS_LOG_UNCOND
(
"Callback demangling failed: Memory allocation failure occurred."
);
104
ret = mangled;
105
}
106
else
if
(status == -2)
107
{
108
NS_LOG_UNCOND
(
"Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules."
);
109
ret = mangled;
110
}
111
else
if
(status == -3)
112
{
113
NS_LOG_UNCOND
(
"Callback demangling failed: One of the arguments is invalid."
);
114
ret = mangled;
115
}
116
else
117
{
118
NS_LOG_UNCOND
(
"Callback demangling failed: status "
<< status);
119
ret = mangled;
120
}
121
122
if
(demangled)
123
{
124
std::free (demangled);
125
}
126
return
ret;
127
}
128
129
}
// namespace ns3
130
131
#else
132
133
std::string
134
ns3::CallbackImplBase::Demangle
(
const
std::string& mangled)
135
{
136
NS_LOG_FUNCTION
(
this
<< mangled);
137
return
mangled;
138
}
139
140
#endif
141
callback.h
Declaration of the various callback functions.
ns3::CallbackBase
Base class for Callback class.
Definition:
callback.h:1196
ns3::CallbackBase::GetImpl
Ptr< CallbackImplBase > GetImpl(void) const
Definition:
callback.h:1201
ns3::Callback
Callback template class.
Definition:
callback.h:1279
ns3::CallbackImplBase::Demangle
static std::string Demangle(const std::string &mangled)
Definition:
callback.cc:134
ns3::CallbackValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Serialize to string.
Definition:
callback.cc:60
ns3::CallbackValue::Set
void Set(CallbackBase base)
Definition:
callback.cc:47
ns3::CallbackValue::CallbackValue
CallbackValue()
Constructor.
Definition:
callback.cc:34
ns3::CallbackValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
callback.cc:54
ns3::CallbackValue::~CallbackValue
virtual ~CallbackValue()
Destructor.
Definition:
callback.cc:42
ns3::CallbackValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Deserialize from string (not implemented)
Definition:
callback.cc:68
ns3::CallbackValue::m_value
CallbackBase m_value
The stored Callback instance.
Definition:
callback.h:1979
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
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:67
ATTRIBUTE_CHECKER_IMPLEMENT
#define ATTRIBUTE_CHECKER_IMPLEMENT(type)
Define the MaketypeChecker function for class type.
Definition:
attribute-helper.h:344
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Definition:
log-macros-enabled.h:269
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
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:244
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:415
src
core
model
callback.cc
Generated on Tue Feb 6 2024 19:21:16 for ns-3 by
1.9.1