A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
attribute-container-accessor-helper.h
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2018 Caliola Engineering, LLC.
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
* Author: Jared Dulmage <jared.dulmage@caliola.com>
19
*/
20
21
#ifndef ATTRIBUTE_CONTAINER_ACCESSOR_HELPER_H
22
#define ATTRIBUTE_CONTAINER_ACCESSOR_HELPER_H
23
24
#include "
attribute-container.h
"
25
26
#include <ns3/attribute-helper.h>
27
28
29
#include <type_traits>
30
#include <list>
31
32
namespace
ns3
{
33
52
template
<
typename
V,
typename
T,
template
<
typename
...>
class
U,
typename
...I,
53
typename
=
typename
std::enable_if< (
sizeof
...(I) > 1),
void
>::type >
54
inline
55
Ptr<const AttributeAccessor>
56
DoMakeAccessorHelperOne
(U<I...> T::*memberContainer)
57
{
58
/* AttributeAcessor implementation for a class member variable. */
59
class
MemberContainer :
public
AccessorHelper
<T,V>
60
{
61
public
:
62
/*
63
* Construct from a class data member address.
64
* \param [in] memberContainer The class data member address.
65
*/
66
MemberContainer (U<I...> T::*memberContainer)
67
:
AccessorHelper<T,V>
(),
68
m_memberContainer (memberContainer)
69
{}
70
private
:
71
virtual
bool
DoSet (T *
object
,
const
V *v)
const
{
72
// typename AccessorTrait<U<I>::value_type>::Result tmp;
73
// bool ok = v->GetAccessor (tmp);
74
// if (!ok)
75
// {
76
// return false;
77
// }
78
auto
src = v->
Get
();
79
(
object
->*m_memberContainer).clear ();
80
std::copy (src.begin (), src.end (), std::inserter ((object->*m_memberContainer), (object->*m_memberContainer).end ()));
81
return
true
;
82
}
83
virtual
bool
DoGet (
const
T *
object
, V *v)
const
{
84
v->Set (object->*m_memberContainer);
85
return
true
;
86
}
87
virtual
bool
HasGetter (
void
)
const
{
88
return
true
;
89
}
90
virtual
bool
HasSetter (
void
)
const
{
91
return
true
;
92
}
93
94
U<I...> T::*m_memberContainer;
// Address of the class data member.
95
};
96
return
Ptr<const AttributeAccessor>
(
new
MemberContainer (memberContainer),
false
);
97
}
98
99
}
// namespace ns3
100
101
#endif // ATTRIBUTE_CONTAINER_ACCESSOR_HELPER_H
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
attribute-container.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::AccessorHelper
Basic functionality for accessing class attributes via class data members, or get functor/set methods...
Definition:
attribute-accessor-helper.h:160
ns3::DoMakeAccessorHelperOne
Ptr< const AttributeAccessor > DoMakeAccessorHelperOne(U T::*memberVariable)
MakeAccessorHelper implementation for a class data member.
Definition:
attribute-accessor-helper.h:259
ns3::AccessorHelper::Get
virtual bool Get(const ObjectBase *object, AttributeValue &val) const
Get the value of the underlying member into the AttributeValue.
Definition:
attribute-accessor-helper.h:206
src
core
model
attribute-container-accessor-helper.h
Generated on Wed Oct 7 2020 01:18:12 for ns-3 by
1.8.14