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
pointer.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
#include "
pointer.h
"
9
10
#include "
log.h
"
11
#include "
object-factory.h
"
12
13
#include <sstream>
14
15
/**
16
* @file
17
* @ingroup attribute_Pointer
18
* ns3::PointerValue attribute value implementations.
19
*/
20
21
namespace
ns3
22
{
23
24
NS_LOG_COMPONENT_DEFINE
(
"Pointer"
);
25
26
PointerValue::PointerValue
()
27
: m_value()
28
{
29
NS_LOG_FUNCTION
(
this
);
30
}
31
32
PointerValue::PointerValue
(
const
Ptr<Object>
&
object
)
33
: m_value(
object
)
34
{
35
NS_LOG_FUNCTION
(
object
);
36
}
37
38
void
39
PointerValue::SetObject
(
Ptr<Object>
object
)
40
{
41
NS_LOG_FUNCTION
(
object
);
42
m_value
=
object
;
43
}
44
45
Ptr<Object>
46
PointerValue::GetObject
()
const
47
{
48
NS_LOG_FUNCTION
(
this
);
49
return
m_value
;
50
}
51
52
Ptr<AttributeValue>
53
PointerValue::Copy
()
const
54
{
55
NS_LOG_FUNCTION
(
this
);
56
return
Create<PointerValue>
(*
this
);
57
}
58
59
std::string
60
PointerValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
61
{
62
NS_LOG_FUNCTION
(
this
<< checker);
63
std::ostringstream oss;
64
oss <<
m_value
;
65
return
oss.str();
66
}
67
68
bool
69
PointerValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
70
{
71
// We assume that the string you want to deserialize contains
72
// a description for an ObjectFactory to create an object and then assign it to the
73
// member variable.
74
NS_LOG_FUNCTION
(
this
<< value << checker);
75
ObjectFactory
factory;
76
std::istringstream iss;
77
iss.str(value);
78
iss >> factory;
79
if
(iss.fail())
80
{
81
return
false
;
82
}
83
m_value
= factory.
Create
<
Object
>();
84
return
true
;
85
}
86
87
}
// namespace ns3
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition
object-factory.h:37
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition
object-factory.cc:82
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::PointerValue::SerializeToString
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Definition
pointer.cc:60
ns3::PointerValue::Copy
Ptr< AttributeValue > Copy() const override
Definition
pointer.cc:53
ns3::PointerValue::GetObject
Ptr< Object > GetObject() const
Get the Object referenced by the PointerValue.
Definition
pointer.cc:46
ns3::PointerValue::m_value
Ptr< Object > m_value
The stored Pointer instance.
Definition
pointer.h:105
ns3::PointerValue::DeserializeFromString
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Definition
pointer.cc:69
ns3::PointerValue::PointerValue
PointerValue()
Definition
pointer.cc:26
ns3::PointerValue::SetObject
void SetObject(Ptr< Object > object)
Set the value from by reference an Object.
Definition
pointer.cc:39
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
object
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
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 Thu Dec 12 2024 18:40:36 for ns-3 by
1.11.0