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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
pointer.cc
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 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
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#include "pointer.h"
21
#include "object-factory.h"
22
#include "log.h"
23
#include <sstream>
24
25
NS_LOG_COMPONENT_DEFINE
(
"Pointer"
);
26
27
namespace
ns3 {
28
29
PointerValue::PointerValue ()
30
: m_value ()
31
{
32
NS_LOG_FUNCTION
(
this
);
33
}
34
35
PointerValue::PointerValue (Ptr<Object>
object
)
36
: m_value (object)
37
{
38
NS_LOG_FUNCTION
(
object
);
39
}
40
41
void
42
PointerValue::SetObject (Ptr<Object>
object
)
43
{
44
NS_LOG_FUNCTION
(
object
);
45
m_value = object;
46
}
47
48
Ptr<Object>
49
PointerValue::GetObject (
void
)
const
50
{
51
NS_LOG_FUNCTION
(
this
);
52
return
m_value;
53
}
54
55
Ptr<AttributeValue>
56
PointerValue::Copy (
void
)
const
57
{
58
NS_LOG_FUNCTION
(
this
);
59
return
Create<PointerValue> (*this);
60
}
61
std::string
62
PointerValue::SerializeToString (
Ptr<const AttributeChecker>
checker)
const
63
{
64
NS_LOG_FUNCTION
(
this
<< checker);
65
std::ostringstream oss;
66
oss << m_value;
67
return
oss.str ();
68
}
69
70
bool
71
PointerValue::DeserializeFromString (std::string value,
Ptr<const AttributeChecker>
checker)
72
{
73
// We assume that the string you want to deserialize contains
74
// a description for an ObjectFactory to create an object and then assign it to the
75
// member variable.
76
NS_LOG_FUNCTION
(
this
<< value << checker);
77
ObjectFactory
factory;
78
std::istringstream iss;
79
iss.str(value);
80
iss >> factory;
81
if
(iss.fail())
82
{
83
return
false
;
84
}
85
m_value = factory.
Create
<
Object
> ();
86
return
true
;
87
}
88
89
}
// namespace ns3
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Definition:
object-factory.cc:89
ns3::ObjectFactory
instantiate subclasses of ns3::Object.
Definition:
object-factory.h:39
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
src
core
model
pointer.cc
Generated on Sun Mar 16 2014 11:25:02 for ns-3 by
1.8.6