A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
object-vector.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 INRIA, Mathieu Lacage
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Mathieu Lacage <mathieu.lacage@gmail.com>
7
*/
8
#ifndef OBJECT_VECTOR_H
9
#define OBJECT_VECTOR_H
10
11
#include "
attribute.h
"
12
#include "
object-ptr-container.h
"
13
#include "
object.h
"
14
#include "
ptr.h
"
15
16
/**
17
* @file
18
* @ingroup attribute_ObjectVector
19
* ns3::ObjectVectorValue attribute value declarations and template implementations.
20
*/
21
22
namespace
ns3
23
{
24
25
/**
26
* @ingroup attribute_ObjectVector
27
* ObjectVectorValue is an alias for ObjectPtrContainerValue
28
*/
29
typedef
ObjectPtrContainerValue
ObjectVectorValue
;
30
31
/**
32
* @ingroup attribute_ObjectVector
33
* MakeAccessorHelper implementation for ObjectVector.
34
* @copydetails ns3::DoMakeAccessorHelperOne(U T::*)
35
*/
36
template
<
typename
T,
typename
U>
37
Ptr<const AttributeAccessor>
MakeObjectVectorAccessor
(U T::*memberVariable);
38
39
// Documentation generated by print-introspected-doxygen.cc
40
template
<
typename
T>
41
Ptr<const AttributeChecker>
MakeObjectVectorChecker
();
42
43
/**
44
* @ingroup attribute_ObjectVector
45
* @copydoc ns3::MakeObjectPtrContainerAccessor()
46
*/
47
template
<
typename
T,
typename
U,
typename
INDEX>
48
Ptr<const AttributeAccessor>
MakeObjectVectorAccessor
(
Ptr<U>
(T::*get)(INDEX) const,
49
INDEX (T::*getN)() const);
50
51
/**
52
* @ingroup attribute_ObjectVector
53
* @copydoc ns3::MakeObjectPtrContainerAccessor()
54
*/
55
template
<
typename
T,
typename
U,
typename
INDEX>
56
Ptr<const AttributeAccessor>
MakeObjectVectorAccessor
(INDEX (T::*getN)() const,
57
Ptr
<U> (T::*get)(INDEX) const);
58
59
/***************************************************************
60
* Implementation of the templates declared above.
61
***************************************************************/
62
63
template
<
typename
T,
typename
U>
64
Ptr<const AttributeAccessor>
65
MakeObjectVectorAccessor
(U T::*memberVector)
66
{
67
struct
MemberStdContainer :
public
ObjectPtrContainerAccessor
68
{
69
bool
DoGetN(
const
ObjectBase
*
object
, std::size_t* n)
const override
70
{
71
const
T* obj =
dynamic_cast<
const
T*
>
(
object
);
72
if
(obj ==
nullptr
)
73
{
74
return
false
;
75
}
76
*n = (obj->*m_memberVector).size();
77
return
true
;
78
}
79
80
Ptr<Object>
DoGet(
const
ObjectBase
*
object
,
81
std::size_t i,
82
std::size_t* index)
const override
83
{
84
const
T* obj =
static_cast<
const
T*
>
(
object
);
85
auto
begin = (obj->*m_memberVector).begin();
86
auto
end = (obj->*m_memberVector).end();
87
std::size_t k = 0;
88
for
(
auto
j = begin; j != end; j++, k++)
89
{
90
if
(k == i)
91
{
92
*index = k;
93
return
*j;
94
}
95
}
96
NS_ASSERT
(
false
);
97
// quiet compiler.
98
return
nullptr
;
99
}
100
101
U T::*m_memberVector;
102
}* spec =
new
MemberStdContainer();
103
104
spec->m_memberVector = memberVector;
105
return
Ptr<const AttributeAccessor>
(spec,
false
);
106
}
107
108
template
<
typename
T>
109
Ptr<const AttributeChecker>
110
MakeObjectVectorChecker
()
111
{
112
return
MakeObjectPtrContainerChecker<T>
();
113
}
114
115
template
<
typename
T,
typename
U,
typename
INDEX>
116
Ptr<const AttributeAccessor>
117
MakeObjectVectorAccessor
(
Ptr<U>
(T::*get)(INDEX) const, INDEX (T::*getN)() const)
118
{
119
return
MakeObjectPtrContainerAccessor<T, U, INDEX>
(get, getN);
120
}
121
122
template
<
typename
T,
typename
U,
typename
INDEX>
123
Ptr<const AttributeAccessor>
124
MakeObjectVectorAccessor
(INDEX (T::*getN)() const,
Ptr
<U> (T::*get)(INDEX) const)
125
{
126
return
MakeObjectPtrContainerAccessor<T, U, INDEX>
(get, getN);
127
}
128
129
}
// namespace ns3
130
131
#endif
/* OBJECT_VECTOR_H */
attribute.h
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
ns3::ObjectBase
Anchor the ns-3 type and attribute system.
Definition
object-base.h:162
ns3::ObjectPtrContainerAccessor
AttributeAccessor implementation for ObjectPtrContainerValue.
Definition
object-ptr-container.h:241
ns3::ObjectPtrContainerValue
Container for a set of ns3::Object pointers.
Definition
object-ptr-container.h:46
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
object
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
ns3::MakeObjectPtrContainerAccessor
Ptr< const AttributeAccessor > MakeObjectPtrContainerAccessor(Ptr< U >(T::*get)(INDEX) const, INDEX(T::*getN)() const)
Create an AttributeAccessor using a container class indexed get method.
Definition
object-ptr-container.h:272
ns3::MakeObjectPtrContainerChecker
Ptr< const AttributeChecker > MakeObjectPtrContainerChecker()
Definition
object-ptr-container.h:314
ns3::MakeObjectVectorChecker
Ptr< const AttributeChecker > MakeObjectVectorChecker()
Definition
object-vector.h:110
ns3::ObjectVectorValue
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Definition
object-vector.h:29
ns3::MakeObjectVectorAccessor
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition
object-vector.h:65
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
object-ptr-container.h
ns3::ObjectPtrContainerValue attribute value declarations and template implementations.
object.h
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ptr.h
ns3::Ptr smart pointer declaration and implementation.
src
core
model
object-vector.h
Generated on Sun Dec 1 2024 18:20:36 for ns-3 by
1.11.0