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
pointer.cc
Go to the documentation of this file.
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 <sstream>
23
24
namespace
ns3 {
25
26
PointerValue::PointerValue
()
27
: m_value ()
28
{
29
}
30
31
PointerValue::PointerValue
(
Ptr<Object>
object
)
32
: m_value (object)
33
{
34
}
35
36
void
37
PointerValue::SetObject
(
Ptr<Object>
object
)
38
{
39
m_value
= object;
40
}
41
42
Ptr<Object>
43
PointerValue::GetObject
(
void
)
const
44
{
45
return
m_value
;
46
}
47
48
Ptr<AttributeValue>
49
PointerValue::Copy
(
void
)
const
50
{
51
return
Create<PointerValue> (*this);
52
}
53
std::string
54
PointerValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
55
{
56
std::ostringstream oss;
57
oss <<
m_value
;
58
return
oss.str ();
59
}
60
61
bool
62
PointerValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
63
{
64
// We assume that the string you want to deserialize contains
65
// a description for an ObjectFactory to create an object and then assign it to the
66
// member variable.
67
ObjectFactory
factory;
68
std::istringstream iss;
69
iss.str(value);
70
iss >> factory;
71
if
(iss.fail())
72
{
73
return
false
;
74
}
75
m_value
= factory.Create<
Object
> ();
76
return
true
;
77
}
78
79
}
// namespace ns3
src
core
model
pointer.cc
Generated on Tue Nov 13 2012 10:32:10 for ns-3 by
1.8.1.2