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
object-ptr-container.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 INRIA, Mathieu Lacage
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@gmail.com>
19
*/
20
#include "
object-ptr-container.h
"
21
22
namespace
ns3 {
23
24
ObjectPtrContainerValue::ObjectPtrContainerValue
()
25
{
26
}
27
28
ObjectPtrContainerValue::Iterator
29
ObjectPtrContainerValue::Begin
(
void
)
const
30
{
31
return
m_objects
.begin ();
32
}
33
ObjectPtrContainerValue::Iterator
34
ObjectPtrContainerValue::End
(
void
)
const
35
{
36
return
m_objects
.end ();
37
}
38
uint32_t
39
ObjectPtrContainerValue::GetN
(
void
)
const
40
{
41
return
m_objects
.size ();
42
}
43
Ptr<Object>
44
ObjectPtrContainerValue::Get
(uint32_t i)
const
45
{
46
Iterator
it =
m_objects
.find (i);
47
Ptr<Object>
value = 0;
48
if
( it !=
m_objects
.end () )
49
{
50
value =
m_objects
.find (i)->second;
51
}
52
return
value;
53
}
54
55
Ptr<AttributeValue>
56
ObjectPtrContainerValue::Copy
(
void
)
const
57
{
58
return
ns3::Create<ObjectPtrContainerValue> (*this);
59
}
60
std::string
61
ObjectPtrContainerValue::SerializeToString
(
Ptr<const AttributeChecker>
checker)
const
62
{
63
std::ostringstream oss;
64
Iterator
it;
65
for
(it =
Begin
(); it !=
End
(); ++it)
66
{
67
oss << (*it).second;
68
if
(it !=
End
())
69
{
70
oss <<
" "
;
71
}
72
}
73
return
oss.str ();
74
}
75
bool
76
ObjectPtrContainerValue::DeserializeFromString
(std::string value,
Ptr<const AttributeChecker>
checker)
77
{
78
NS_FATAL_ERROR
(
"cannot deserialize a set of object pointers."
);
79
return
true
;
80
}
81
82
bool
83
ObjectPtrContainerAccessor::Set
(
ObjectBase
*
object
,
const
AttributeValue
& value)
const
84
{
85
// not allowed.
86
return
false
;
87
}
88
bool
89
ObjectPtrContainerAccessor::Get
(
const
ObjectBase
*
object
,
AttributeValue
&value)
const
90
{
91
ObjectPtrContainerValue
*v =
dynamic_cast<
ObjectPtrContainerValue
*
>
(&value);
92
if
(v == 0)
93
{
94
return
false
;
95
}
96
v->
m_objects
.clear ();
97
uint32_t n;
98
bool
ok =
DoGetN
(
object
, &n);
99
if
(!ok)
100
{
101
return
false
;
102
}
103
for
(uint32_t i = 0; i < n; i++)
104
{
105
uint32_t index;
106
Ptr<Object>
o =
DoGet
(
object
, i, &index);
107
v->
m_objects
.insert (std::pair <uint32_t,
Ptr<Object>
> (index, o));
108
}
109
return
true
;
110
}
111
bool
112
ObjectPtrContainerAccessor::HasGetter
(
void
)
const
113
{
114
return
true
;
115
}
116
bool
117
ObjectPtrContainerAccessor::HasSetter
(
void
)
const
118
{
119
return
false
;
120
}
121
122
}
// name
src
core
model
object-ptr-container.cc
Generated on Tue Oct 9 2012 16:45:34 for ns-3 by
1.8.1.2