9#ifndef ATTRIBUTE_CONTAINER_H
10#define ATTRIBUTE_CONTAINER_H
32class AttributeChecker;
48template <
class A,
char Sep =
',',
template <
class...>
class C = std::list>
61 typedef typename container_type::iterator
iterator;
63 typedef typename container_type::size_type
size_type;
69 typedef typename std::invoke_result_t<
decltype(&A::Get), A>
item_type;
83 template <
class CONTAINER>
118 void Set(
const T& c);
127 template <
typename T>
184 template <
class ITER>
222template <
class A,
char Sep,
template <
class...>
class C>
236template <
class A,
char Sep =
',',
template <
class...>
class C = std::list>
248template <
class A,
char Sep =
',',
template <
class...>
class C = std::list>
264template <
typename A,
char Sep =
',',
template <
typename...>
class C = std::list,
typename T1>
285 template <
typename...>
class C = std::list,
311template <
class A,
char Sep,
template <
class...>
class C>
328template <
class A,
char Sep,
template <
class...>
class C>
330 : m_itemchecker(nullptr)
334template <
class A,
char Sep,
template <
class...>
class C>
337 : m_itemchecker(itemchecker)
341template <
class A,
char Sep,
template <
class...>
class C>
345 m_itemchecker = itemchecker;
348template <
class A,
char Sep,
template <
class...>
class C>
352 return m_itemchecker;
357template <
class A,
char Sep,
template <
class...>
class C>
364template <
class A,
char Sep,
template <
class...>
class C>
365Ptr<const AttributeChecker>
370 acchecker->SetItemChecker(itemchecker);
374template <
class A,
char Sep,
template <
class...>
class C>
378 std::string containerType;
379 std::string underlyingType;
382 std::ostringstream oss;
383 oss <<
"ns3::AttributeContainerValue<" <<
typeid(
typename T::attribute_type).name() <<
", "
384 <<
typeid(
typename T::container_type).name() <<
">";
385 containerType = oss.str();
389 std::ostringstream oss;
390 oss <<
"ns3::Ptr<" <<
typeid(
typename T::attribute_type).name() <<
">";
391 underlyingType = oss.str();
399template <
class A,
char Sep,
template <
class...>
class C>
404template <
class A,
char Sep,
template <
class...>
class C>
405template <
class CONTAINER>
411template <
class A,
char Sep,
template <
class...>
class C>
419template <
class A,
char Sep,
template <
class...>
class C>
425template <
class A,
char Sep,
template <
class...>
class C>
430 c->m_container = m_container;
434template <
class A,
char Sep,
template <
class...>
class C>
445 std::istringstream iss(value);
446 while (std::getline(iss, value, Sep))
448 auto avalue = acchecker->GetItemChecker()->CreateValidValue(
StringValue(value));
461 m_container.push_back(attr);
466template <
class A,
char Sep,
template <
class...>
class C>
470 std::ostringstream oss;
472 for (
auto attr : *
this)
478 oss << attr->SerializeToString(checker);
484template <
class A,
char Sep,
template <
class...>
class C>
491 c.insert(c.end(), a->Get());
496template <
class A,
char Sep,
template <
class...>
class C>
503 std::copy(src.begin(), src.end(), std::inserter(value, value.end()));
507template <
class A,
char Sep,
template <
class...>
class C>
513 CopyFrom(c.begin(), c.end());
516template <
class A,
char Sep,
template <
class...>
class C>
523template <
class A,
char Sep,
template <
class...>
class C>
530template <
class A,
char Sep,
template <
class...>
class C>
537template <
class A,
char Sep,
template <
class...>
class C>
541 return m_container.size();
544template <
class A,
char Sep,
template <
class...>
class C>
548 return m_container.begin();
551template <
class A,
char Sep,
template <
class...>
class C>
555 return m_container.end();
558template <
class A,
char Sep,
template <
class...>
class C>
562 return m_container.cbegin();
565template <
class A,
char Sep,
template <
class...>
class C>
569 return m_container.cend();
572template <
class A,
char Sep,
template <
class...>
class C>
577 for (ITER iter = begin; iter != end; ++iter)
583template <
typename A,
char Sep,
template <
typename...>
class C,
typename T1>
590template <
typename A,
char Sep,
template <
typename...>
class C,
typename T1,
typename T2>
591Ptr<const AttributeAccessor>
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.
void CopyFrom(const ITER begin, const ITER end)
Copy items from begin to end.
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.
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.
Ptr< const AttributeAccessor > MakeAccessorHelper(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakeSimpleAttributeChecker(std::string name, std::string underlying)
A simple string-based attribute checker.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
constexpr double C
speed of light in vacuum, in m/s
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
ns3::StringValue attribute value declarations.