21 #ifndef ATTRIBUTE_CONTAINER_ACCESSOR_HELPER_H
22 #define ATTRIBUTE_CONTAINER_ACCESSOR_HELPER_H
26 #include <ns3/attribute-helper.h>
29 #include <type_traits>
42 typedef struct {
char array[2]; }
no;
44 template<
typename C>
static yes test(
typename C::const_iterator*);
45 template<
typename C>
static no test(...);
47 static const bool value =
sizeof(test<T>(0)) ==
sizeof(
yes);
57 template<
typename C>
static char (&
f(
typename std::enable_if<
58 std::is_same<decltype(
static_cast<typename C::const_iterator (C::*)() const
>(&C::begin)),
59 typename C::const_iterator(C::*)()
const>::value,
void>::type*))[1];
61 template<
typename C>
static char (&
f(...))[2];
63 template<
typename C>
static char (&
g(
typename std::enable_if<
64 std::is_same<decltype(
static_cast<typename C::const_iterator (C::*)() const
>(&C::end)),
65 typename C::const_iterator(C::*)()
const>::value,
void>::type*))[1];
67 template<
typename C>
static char (&
g(...))[2];
83 struct is_container : std::integral_constant<bool, has_const_iterator<T>::value && has_begin_end<T>::beg_value && has_begin_end<T>::end_value>
104 template <
typename V,
typename T,
template <
typename...>
class U,
typename ...I,
105 typename =
typename std::enable_if< (
is_container< U<I...> >::value ),
void>::type >
118 MemberContainer (U<I...> T::*memberContainer)
120 m_memberContainer (memberContainer)
123 virtual bool DoSet (T *
object,
const V *v)
const {
130 auto src = v->
Get ();
131 (
object->*m_memberContainer).clear ();
132 std::copy (src.begin (), src.end (), std::inserter ((object->*m_memberContainer), (object->*m_memberContainer).end ()));
135 virtual bool DoGet (
const T *
object, V *v)
const {
136 v->Set (object->*m_memberContainer);
139 virtual bool HasGetter (
void)
const {
142 virtual bool HasSetter (
void)
const {
146 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.
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]
static bool const beg_value
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]
static bool const end_value
Compile time check if type T has const iterator.
static yes test(typename C::const_iterator *)
Compile time check if type T is a container.