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-map.h
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
#ifndef OBJECT_MAP_H
21
#define OBJECT_MAP_H
22
23
#include "
object.h
"
24
#include "
ptr.h
"
25
#include "
attribute.h
"
26
#include "
object-ptr-container.h
"
27
28
namespace
ns3 {
29
30
typedef
ObjectPtrContainerValue
ObjectMapValue
;
31
32
template
<
typename
T,
typename
U>
33
Ptr<const AttributeAccessor>
34
MakeObjectMapAccessor
(U T::*memberContainer);
35
36
template
<
typename
T>
37
Ptr<const AttributeChecker>
MakeObjectMapChecker
(
void
);
38
39
template
<
typename
T,
typename
U,
typename
INDEX>
40
Ptr<const AttributeAccessor>
41
MakeObjectMapAccessor
(
Ptr<U>
(T::*
get
)(INDEX)
const
,
42
INDEX (T::*getN)(
void
)
const
);
43
44
template
<
typename
T,
typename
U,
typename
INDEX>
45
Ptr<const AttributeAccessor>
46
MakeObjectMapAccessor
(INDEX (T::*getN)(
void
)
const
,
47
Ptr<U>
(T::*
get
)(INDEX)
const
);
48
49
template
<
typename
T,
typename
U>
50
Ptr<const AttributeAccessor>
51
MakeObjectMapAccessor
(U T::*memberVector)
52
{
53
struct
MemberStdContainer :
public
ObjectPtrContainerAccessor
54
{
55
virtual
bool
DoGetN (
const
ObjectBase
*
object
, uint32_t *n)
const
{
56
const
T *obj =
dynamic_cast<
const
T *
>
(object);
57
if
(obj == 0)
58
{
59
return
false
;
60
}
61
*n = (obj->*m_memberVector).size ();
62
return
true
;
63
}
64
virtual
Ptr<Object>
DoGet (
const
ObjectBase
*
object
, uint32_t i, uint32_t *index)
const
{
65
const
T *obj =
static_cast<
const
T *
>
(object);
66
typename
U::const_iterator begin = (obj->*m_memberVector).begin ();
67
typename
U::const_iterator end = (obj->*m_memberVector).end ();
68
uint32_t k = 0;
69
for
(
typename
U::const_iterator j = begin; j != end; j++, k++)
70
{
71
if
(k == i)
72
{
73
*index = (*j).first;
74
return
(*j).second;
75
break
;
76
}
77
}
78
NS_ASSERT
(
false
);
79
// quiet compiler.
80
return
0;
81
}
82
U T::*m_memberVector;
83
} *spec =
new
MemberStdContainer ();
84
spec->m_memberVector = memberVector;
85
return
Ptr<const AttributeAccessor>
(spec,
false
);
86
}
87
88
template
<
typename
T>
89
Ptr<const AttributeChecker>
MakeObjectMapChecker
(
void
)
90
{
91
return
MakeObjectPtrContainerChecker<T> ();
92
}
93
94
template
<
typename
T,
typename
U,
typename
INDEX>
95
Ptr<const AttributeAccessor>
96
MakeObjectMapAccessor
(
Ptr<U>
(T::*
get
)(INDEX)
const
,
97
INDEX (T::*getN)(
void
)
const
)
98
{
99
return
MakeObjectPtrContainerAccessor<T,U,INDEX>(
get
, getN);
100
}
101
102
template
<
typename
T,
typename
U,
typename
INDEX>
103
Ptr<const AttributeAccessor>
104
MakeObjectMapAccessor
(INDEX (T::*getN)(
void
)
const
,
105
Ptr<U>
(T::*
get
)(INDEX)
const
)
106
{
107
return
MakeObjectPtrContainerAccessor<T,U,INDEX>(
get
, getN);
108
}
109
110
}
// namespace ns3
111
112
#endif
/* OBJECT_MAP_H */
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ptr.h
ns3::MakeObjectMapChecker
Ptr< const AttributeChecker > MakeObjectMapChecker(void)
Definition:
object-map.h:89
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::MakeObjectMapAccessor
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberContainer)
Definition:
object-map.h:51
ns3::ObjectBase
implement the ns-3 type and attribute system
Definition:
object-base.h:70
object-ptr-container.h
ns3::ObjectPtrContainerAccessor
Definition:
object-ptr-container.h:135
attribute.h
object.h
ns3::ObjectPtrContainerValue
contain a set of ns3::Object pointers.
Definition:
object-ptr-container.h:38
ns3::ObjectMapValue
ObjectPtrContainerValue ObjectMapValue
Definition:
object-map.h:30
src
core
model
object-map.h
Generated on Sat Apr 19 2014 14:06:52 for ns-3 by
1.8.6