A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
pointer.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 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
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
#include "
pointer.h
"
20
21
#include "
log.h
"
22
#include "
object-factory.h
"
23
24
#include <sstream>
25
32
namespace
ns3
33
{
34
35
NS_LOG_COMPONENT_DEFINE
(
"Pointer"
);
36
37
PointerValue::PointerValue
()
38
: m_value()
39
{
40
NS_LOG_FUNCTION
(
this
);
41
}
42
43
PointerValue::PointerValue
(
Ptr<Object>
object
)
44
: m_value(
object
)
45
{
46
NS_LOG_FUNCTION
(
object
);
47
}
48
49
void
50
PointerValue::SetObject
(
Ptr<Object>
object
)
51
{
52
NS_LOG_FUNCTION
(
object
);
53
m_value
=
object
;
54
}
55
56
Ptr<Object>
57
PointerValue::GetObject
()
const
58
{
59
NS_LOG_FUNCTION
(
this
);
60
return
m_value
;
61
}
62
63
Ptr<AttributeValue>
64
PointerValue::Copy
()
const
65
{
66
NS_LOG_FUNCTION
(
this
);
67
return
Create<PointerValue>(*
this
);
68
}
69
70
std::string
71
PointerValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
72
{
73
NS_LOG_FUNCTION
(
this
<< checker);
74
std::ostringstream oss;
75
oss <<
m_value
;
76
return
oss.str();
77
}
78
79
bool
80
PointerValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
81
{
82
// We assume that the string you want to deserialize contains
83
// a description for an ObjectFactory to create an object and then assign it to the
84
// member variable.
85
NS_LOG_FUNCTION
(
this
<< value << checker);
86
ObjectFactory
factory;
87
std::istringstream iss;
88
iss.str(value);
89
iss >> factory;
90
if
(iss.fail())
91
{
92
return
false
;
93
}
94
m_value
= factory.
Create
<
Object
>();
95
return
true
;
96
}
97
98
}
// namespace ns3
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition:
object-factory.h:48
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition:
object-factory.cc:93
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::PointerValue::SerializeToString
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Definition:
pointer.cc:71
ns3::PointerValue::Copy
Ptr< AttributeValue > Copy() const override
Definition:
pointer.cc:64
ns3::PointerValue::GetObject
Ptr< Object > GetObject() const
Get the Object referenced by the PointerValue.
Definition:
pointer.cc:57
ns3::PointerValue::m_value
Ptr< Object > m_value
Definition:
pointer.h:93
ns3::PointerValue::DeserializeFromString
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Definition:
pointer.cc:80
ns3::PointerValue::PointerValue
PointerValue()
Definition:
pointer.cc:37
ns3::PointerValue::SetObject
void SetObject(Ptr< Object > object)
Set the value from by reference an Object.
Definition:
pointer.cc:50
ns3::Ptr< Object >
object
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.
object-factory.h
ns3::ObjectFactory class declaration.
pointer.h
ns3::PointerValue attribute value declarations and template implementations.
src
core
model
pointer.cc
Generated on Sun Mar 3 2024 17:10:55 for ns-3 by
1.9.1