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
/* -*- 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
}
43
CallbackValue::~CallbackValue
()
44
{
45
NS_LOG_FUNCTION
(
this
);
46
}
47
void
48
CallbackValue::Set
(
CallbackBase
base)
49
{
50
NS_LOG_FUNCTION
(&base);
51
52
m_value
= base;
53
}
54
Ptr<AttributeValue>
55
CallbackValue::Copy
(
void
)
const
56
{
57
NS_LOG_FUNCTION
(
this
);
58
return
Create<CallbackValue> (
m_value
);
59
}
60
std::string
61
CallbackValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
62
{
63
NS_LOG_FUNCTION
(
this
<< checker);
64
std::ostringstream oss;
65
oss <<
PeekPointer
(
m_value
.
GetImpl
());
66
return
oss.str ();
67
}
68
bool
69
CallbackValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
70
{
71
NS_LOG_FUNCTION
(
this
<< value << checker);
72
return
false
;
73
}
74
75
ATTRIBUTE_CHECKER_IMPLEMENT
(
Callback
);
76
77
}
// namespace ns3
78
79
#if (__GNUC__ >= 3)
80
81
#include <cstdlib>
82
#include <cxxabi.h>
83
#include "
log.h
"
84
85
namespace
ns3 {
86
87
std::string
88
CallbackImplBase::Demangle
(
const
std::string& mangled)
89
{
90
NS_LOG_FUNCTION
(mangled);
91
92
int
status;
93
char
* demangled = abi::__cxa_demangle (mangled.c_str (),
94
NULL, NULL, &status);
95
96
std::string ret;
97
if
(status == 0) {
98
NS_ASSERT
(demangled);
99
ret = demangled;
100
}
101
else
if
(status == -1) {
102
NS_LOG_UNCOND
(
"Callback demangling failed: Memory allocation failure occured."
);
103
ret = mangled;
104
}
105
else
if
(status == -2) {
106
NS_LOG_UNCOND
(
"Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules."
);
107
ret = mangled;
108
}
109
else
if
(status == -3) {
110
NS_LOG_UNCOND
(
"Callback demangling failed: One of the arguments is invalid."
);
111
ret = mangled;
112
}
113
else
{
114
NS_LOG_UNCOND
(
"Callback demangling failed: status "
<< status);
115
ret = mangled;
116
}
117
118
if
(demangled) {
119
std::free (demangled);
120
}
121
return
ret;
122
}
123
124
}
// namespace ns3
125
126
#else
127
128
std::string
129
ns3::CallbackBase::Demangle (
const
std::string& mangled)
130
{
131
NS_LOG_FUNCTION
(
this
<< mangled);
132
return
mangled;
133
}
134
135
#endif
136
ns3::CallbackValue::CallbackValue
CallbackValue()
Constructor.
Definition:
callback.cc:34
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
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:213
ns3::Callback
Callback template class.
Definition:
callback.h:1176
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
ns3::PeekPointer
U * PeekPointer(const Ptr< U > &p)
Definition:
ptr.h:562
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::CallbackBase
Base class for Callback class.
Definition:
callback.h:1104
ns3::CallbackValue::~CallbackValue
virtual ~CallbackValue()
Destructor.
Definition:
callback.cc:43
ns3::CallbackValue::m_value
CallbackBase m_value
the CallbackBase
Definition:
callback.h:1919
ns3::CallbackImplBase::Demangle
static std::string Demangle(const std::string &mangled)
callback.h
Declaration of the various callback functions.
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
Definition:
log-macros-enabled.h:238
ATTRIBUTE_CHECKER_IMPLEMENT
#define ATTRIBUTE_CHECKER_IMPLEMENT(type)
Define the MakeTypeChecker function for class type.
Definition:
attribute-helper.h:331
ns3::CallbackValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Deserialize from string (not implemented)
Definition:
callback.cc:69
ns3::CallbackValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Serialize to string.
Definition:
callback.cc:61
log.h
Debug message logging.
ns3::CallbackValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
callback.cc:55
ns3::CallbackValue::Set
void Set(CallbackBase base)
Definition:
callback.cc:48
ns3::CallbackBase::GetImpl
Ptr< CallbackImplBase > GetImpl(void) const
Definition:
callback.h:1108
src
core
model
callback.cc
Generated on Wed Jul 6 2016 17:11:25 for ns-3 by
1.8.6