20#ifndef ATTRIBUTE_CONTAINER_H
21#define ATTRIBUTE_CONTAINER_H
43class AttributeChecker;
59template <
class A,
char Sep =
',',
template <
class...>
class C = std::list>
72 typedef typename container_type::iterator
iterator;
74 typedef typename container_type::size_type
size_type;
80 typedef typename std::invoke_result_t<
decltype(&A::Get), A>
item_type;
94 template <
class CONTAINER>
103 template <
class ITER>
129 void Set(
const T& c);
138 template <
typename T>
196 template <
class ITER>
234template <
class A,
char Sep,
template <
class...>
class C>
248template <
class A,
char Sep =
',',
template <
class...>
class C = std::list>
260template <
class A,
char Sep =
',',
template <
class...>
class C = std::list>
276template <
typename A,
char Sep =
',',
template <
typename...>
class C = std::list,
typename T1>
297 template <
typename...>
class C = std::list,
323template <
class A,
char Sep,
template <
class...>
class C>
340template <
class A,
char Sep,
template <
class...>
class C>
342 : m_itemchecker(nullptr)
346template <
class A,
char Sep,
template <
class...>
class C>
349 : m_itemchecker(itemchecker)
353template <
class A,
char Sep,
template <
class...>
class C>
357 m_itemchecker = itemchecker;
360template <
class A,
char Sep,
template <
class...>
class C>
364 return m_itemchecker;
369template <
class A,
char Sep,
template <
class...>
class C>
373 return MakeAttributeContainerChecker<A, Sep, C>();
376template <
class A,
char Sep,
template <
class...>
class C>
377Ptr<const AttributeChecker>
380 auto checker = MakeAttributeContainerChecker<A, Sep, C>();
381 auto acchecker = DynamicCast<AttributeContainerChecker>(checker);
382 acchecker->SetItemChecker(itemchecker);
386template <
class A,
char Sep,
template <
class...>
class C>
390 std::string containerType;
391 std::string underlyingType;
394 std::ostringstream oss;
395 oss <<
"ns3::AttributeContainerValue<" <<
typeid(
typename T::attribute_type).name() <<
", "
396 <<
typeid(
typename T::container_type).name() <<
">";
397 containerType = oss.str();
401 std::ostringstream oss;
402 oss <<
"ns3::Ptr<" <<
typeid(
typename T::attribute_type).name() <<
">";
403 underlyingType = oss.str();
406 return MakeSimpleAttributeChecker<T, internal::AttributeContainerChecker<A, Sep, C>>(
411template <
class A,
char Sep,
template <
class...>
class C>
416template <
class A,
char Sep,
template <
class...>
class C>
417template <
class CONTAINER>
423template <
class A,
char Sep,
template <
class...>
class C>
431template <
class A,
char Sep,
template <
class...>
class C>
437template <
class A,
char Sep,
template <
class...>
class C>
441 auto c = Create<AttributeContainerValue<A, Sep, C>>();
442 c->m_container = m_container;
446template <
class A,
char Sep,
template <
class...>
class C>
451 auto acchecker = DynamicCast<const AttributeContainerChecker>(checker);
457 std::istringstream iss(value);
458 while (std::getline(iss, value, Sep))
460 auto avalue = acchecker->GetItemChecker()->CreateValidValue(
StringValue(value));
466 auto attr = DynamicCast<A>(avalue);
473 m_container.push_back(attr);
478template <
class A,
char Sep,
template <
class...>
class C>
482 std::ostringstream oss;
484 for (
auto attr : *
this)
490 oss << attr->SerializeToString(checker);
496template <
class A,
char Sep,
template <
class...>
class C>
503 c.insert(c.end(), a->Get());
508template <
class A,
char Sep,
template <
class...>
class C>
515 std::copy(src.begin(), src.end(), std::inserter(value, value.end()));
519template <
class A,
char Sep,
template <
class...>
class C>
525 CopyFrom(c.begin(), c.end());
528template <
class A,
char Sep,
template <
class...>
class C>
535template <
class A,
char Sep,
template <
class...>
class C>
542template <
class A,
char Sep,
template <
class...>
class C>
549template <
class A,
char Sep,
template <
class...>
class C>
553 return m_container.size();
556template <
class A,
char Sep,
template <
class...>
class C>
560 return m_container.begin();
563template <
class A,
char Sep,
template <
class...>
class C>
567 return m_container.end();
570template <
class A,
char Sep,
template <
class...>
class C>
574 return m_container.cbegin();
577template <
class A,
char Sep,
template <
class...>
class C>
581 return m_container.cend();
584template <
class A,
char Sep,
template <
class...>
class C>
589 for (ITER iter = begin; iter != end; ++iter)
591 m_container.push_back(Create<A>(*iter));
596template <
typename A,
char Sep,
template <
typename...>
class C,
typename T1>
600 return MakeAccessorHelper<AttributeContainerValue<A, Sep, C>>(a1);
603template <
typename A,
char Sep,
template <
typename...>
class C,
typename T1,
typename T2>
604Ptr<const AttributeAccessor>
607 return MakeAccessorHelper<AttributeContainerValue<A, Sep, C>>(a1, a2);
Attribute helper (ATTRIBUTE_ )macros definition.
Represent the type of an attribute.
AttributeChecker implementation for AttributeContainerValue.
virtual Ptr< const AttributeChecker > GetItemChecker() const =0
Get the item checker.
virtual void SetItemChecker(Ptr< const AttributeChecker > itemchecker)=0
Set the item checker.
A container for one type of attribute.
AttributeContainerValue::const_iterator Iterator
NS3 style iterator type.
container_type::size_type size_type
Size type for container.
container_type::iterator iterator
stl-style Non-const iterator type.
std::list< value_type > container_type
Internal container type.
bool GetAccessor(T &value) const
Set the given variable to the values stored by this TupleValue object.
Iterator End()
NS3-style ending of container.
size_type GetN() const
NS3-style Number of items.
Ptr< AttributeContainerValue< A, Sep, C > > CopyFrom(const ITER begin, const ITER end)
Copy items from begin to end.
iterator end()
STL-style end of container.
container_type::const_iterator const_iterator
stl-style Const iterator type.
Ptr< A > value_type
Type actually stored within the container.
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
C< item_type > result_type
Type of container returned.
container_type m_container
Internal container.
AttributeContainerValue()
Default constructor.
result_type Get() const
Return a container of items.
A attribute_type
AttributeValue (element) type.
void Set(const T &c)
Copy items from container c.
Iterator Begin()
NS3-style beginning of container.
Ptr< AttributeValue > Copy() const override
std::invoke_result_t< decltype(&A::Get), A > item_type
Item type of container returned by Get.
size_type size() const
STL-style number of items in container.
iterator begin()
STL-style beginning of container.
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
~AttributeContainerValue() override
Destructor.
Hold a value for an Attribute.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
Ptr< const AttributeChecker > GetItemChecker() const override
Get the item checker.
AttributeContainerChecker()
Ptr< const AttributeChecker > m_itemchecker
The AttributeChecker.
void SetItemChecker(Ptr< const AttributeChecker > itemchecker) override
Set the item checker.
Ptr< AttributeChecker > MakeAttributeContainerChecker()
Make uninitialized AttributeContainerChecker using explicit types.
Ptr< const AttributeAccessor > MakeAttributeContainerAccessor(T1 a1)
Make AttributeContainerAccessor using explicit types.
constexpr double C
speed of light in vacuum, in m/s
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::StringValue attribute value declarations.