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
ns3::ObjectPtrContainerValue::Copy
virtual Ptr< AttributeValue > Copy(void) const
Definition:
object-ptr-container.cc:64
ns3::ObjectPtrContainerValue::ObjectPtrContainerValue
ObjectPtrContainerValue()
Definition:
object-ptr-container.cc:27
ns3::Ptr< Object >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::ObjectPtrContainerAccessor::HasSetter
virtual bool HasSetter(void) const
Definition:
object-ptr-container.cc:131
ns3::ObjectPtrContainerAccessor::DoGet
virtual Ptr< Object > DoGet(const ObjectBase *object, uint32_t i, uint32_t *index) const =0
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:56
ns3::ObjectBase
implement the ns-3 type and attribute system
Definition:
object-base.h:70
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition:
fatal-error.h:72
ns3::ObjectPtrContainerValue::Iterator
std::map< uint32_t, Ptr< Object > >::const_iterator Iterator
Definition:
object-ptr-container.h:41
ns3::ObjectPtrContainerValue::Get
Ptr< Object > Get(uint32_t i) const
Definition:
object-ptr-container.cc:51
ns3::ObjectPtrContainerAccessor::Set
virtual bool Set(ObjectBase *object, const AttributeValue &value) const
Definition:
object-ptr-container.cc:94
object-ptr-container.h
ns3::ObjectPtrContainerAccessor::HasGetter
virtual bool HasGetter(void) const
Definition:
object-ptr-container.cc:125
ns3::ObjectPtrContainerValue::m_objects
std::map< uint32_t, Ptr< Object > > m_objects
Definition:
object-ptr-container.h:69
ns3::ObjectPtrContainerValue::Begin
Iterator Begin(void) const
Definition:
object-ptr-container.cc:33
ns3::ObjectPtrContainerValue::DeserializeFromString
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
Definition:
object-ptr-container.cc:86
ns3::ObjectPtrContainerValue::End
Iterator End(void) const
Definition:
object-ptr-container.cc:39
ns3::ObjectPtrContainerAccessor::DoGetN
virtual bool DoGetN(const ObjectBase *object, uint32_t *n) const =0
ns3::ObjectPtrContainerValue::GetN
uint32_t GetN(void) const
Definition:
object-ptr-container.cc:45
ns3::ObjectPtrContainerValue
contain a set of ns3::Object pointers.
Definition:
object-ptr-container.h:38
ns3::ObjectPtrContainerAccessor::Get
virtual bool Get(const ObjectBase *object, AttributeValue &value) const
Definition:
object-ptr-container.cc:101
log.h
ns3::ObjectPtrContainerValue::SerializeToString
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
Definition:
object-ptr-container.cc:70
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("ObjectPtrContainer")
src
core
model
object-ptr-container.cc
Generated on Sat Apr 19 2014 14:06:52 for ns-3 by
1.8.6