21 #ifndef ATTRIBUTE_CONTAINER_ACCESSOR_HELPER_H
22 #define ATTRIBUTE_CONTAINER_ACCESSOR_HELPER_H
26 #include <ns3/attribute-helper.h>
29 #include <type_traits>
53 template <
typename C>
static yes test (
typename C::const_iterator *);
58 template <
typename C>
static no test (...);
62 static const bool value =
sizeof (test<T> (0)) ==
sizeof (
yes);
77 template <
typename C>
static char (&
f (
typename std::enable_if<
78 std::is_same<decltype (
static_cast<typename C::const_iterator (C::*) () const
> (&C::begin)),
79 typename C::const_iterator (C::*) ()
const>::value,
void>::type *))[1];
85 template <
typename C>
static char (&
f (...))[2];
91 template <
typename C>
static char (&
g (
typename std::enable_if<
92 std::is_same<decltype (
static_cast<typename C::const_iterator (C::*) () const
> (&C::end)),
93 typename C::const_iterator (C::*) ()
const>::value,
void>::type *))[1];
99 template <
typename C>
static char (&
g (...))[2];
117 struct is_container : std::integral_constant<bool, has_const_iterator<T>::value && has_begin_end<T>::beg_value && has_begin_end<T>::end_value>
138 template <
typename V,
typename T,
template <
typename...>
class U,
typename ...I,
139 typename =
typename std::enable_if< (
is_container< U<I...> >::value ),
void>::type >
152 MemberContainer (U<I...> T::*memberContainer)
154 m_memberContainer (memberContainer)
157 virtual bool DoSet (T *
object,
const V *v)
const {
164 auto src = v->
Get ();
165 (
object->*m_memberContainer).clear ();
166 std::copy (src.begin (), src.end (), std::inserter ((
object->*m_memberContainer), (
object->*m_memberContainer).end ()));
169 virtual bool DoGet (
const T *
object, V *v)
const {
170 v->Set (
object->*m_memberContainer);
173 virtual bool HasGetter (
void)
const {
176 virtual bool HasSetter (
void)
const {
180 U<I...> T::*m_memberContainer;
Basic functionality for accessing class attributes via class data members, or get functor/set methods...
virtual bool Get(const ObjectBase *object, AttributeValue &val) const
Get the value of the underlying member into the AttributeValue.
Smart pointer class similar to boost::intrusive_ptr.
Ptr< const AttributeAccessor > DoMakeAccessorHelperOne(U T::*memberVariable)
MakeAccessorHelper implementation for a class data member.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
SFINAE compile time check if type T has begin() and end() methods.
static char(& g(typename std::enable_if< std::is_same< decltype(static_cast< typename C::const_iterator(C::*)() const >(&C::end)), typename C::const_iterator(C::*)() const >::value, void >::type *))[1]
Compiled if type T has an end() method.
static bool const beg_value
True if type T has a begin() method.
static char(& f(typename std::enable_if< std::is_same< decltype(static_cast< typename C::const_iterator(C::*)() const >(&C::begin)), typename C::const_iterator(C::*)() const >::value, void >::type *))[1]
Compiled if type T has a begin() method.
static bool const end_value
True if type T has an end() method.
SFINAE compile time check if type T has const iterator.
static const bool value
Value of the test - true if type has a const_iterator.
static yes test(typename C::const_iterator *)
Test function, compiled if type has a const_iterator.
static no test(...)
Test function, compiled if type does not have a const_iterator.
T type
Equivalent name of the type T.
Compile time check if type T is a container.