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