36template <
class... Args>
38operator<<(std::ostream& os,
const std::tuple<Args...>& t)
41 [&os](
auto&&... args) {
43 ((os << args << (++n !=
sizeof...(Args) ?
", " :
"")), ...);
65template <
class... Args>
72 typedef std::tuple<std::invoke_result_t<
decltype(&Args::Get), Args>...>
result_type;
116 template <
typename T>
128 template <std::size_t... Is>
151template <
class T1,
class T2>
167 virtual const std::vector<Ptr<const AttributeChecker>>&
GetCheckers()
const = 0;
180template <
class... Args,
class... Ts>
196template <
class... Args,
class T1>
213template <
class... Args,
class T1,
class T2>
225template <
class... Args>
227 : m_value(
std::make_tuple(Args()...))
231template <
class... Args>
237template <
class... Args>
244template <
class... Args>
245template <std::size_t... Is>
252 bool ok = ((std::get<Is>(valueTuple) !=
nullptr) && ...);
256 m_value = std::make_tuple(Args(*std::get<Is>(valueTuple))...);
261template <
class... Args>
271 auto count = tupleChecker->GetCheckers().size();
272 if (count !=
sizeof...(Args))
277 if (value.empty() || value.front() !=
'{' || value.back() !=
'}')
282 value.erase(value.begin());
284 std::replace(value.data(), value.data() + value.size(),
',',
' ');
286 std::istringstream iss(value);
287 std::vector<Ptr<AttributeValue>> values;
296 values.push_back(tupleChecker->GetCheckers().at(i++)->CreateValidValue(
StringValue(value)));
308 return SetValueImpl(std::index_sequence_for<Args...>{}, values);
311template <
class... Args>
315 std::ostringstream oss;
316 oss <<
"{" << Get() <<
"}";
320template <
class... Args>
324 return std::apply([](Args... values) { return std::make_tuple(values.Get()...); }, m_value);
327template <
class... Args>
331 m_value = std::apply([](
auto&&... args) {
return std::make_tuple(Args(args)...); }, value);
334template <
class... Args>
341template <
class... Args>
362template <
class... Args>
371 template <
class... Ts>
377 const std::vector<Ptr<const AttributeChecker>>&
GetCheckers()
const override
384 const auto v =
dynamic_cast<const TupleValue<Args...
>*>(&value);
390 [
this](Args... values) {
399 return "ns3::TupleValue";
419 const auto src =
dynamic_cast<const TupleValue<Args...
>*>(&source);
420 auto dst =
dynamic_cast<TupleValue<Args...
>*>(&destination);
421 if (src ==
nullptr || dst ==
nullptr)
440template <
class... Args>
446 template <
class... Ts>
464 template <
class T1,
class T2>
479template <
class... Args>
493 template <
class... Ts>
511 template <
class T1,
class T2>
520template <
class T1,
class T2>
527template <
class... Args,
class... Ts>
528Ptr<const AttributeChecker>
534template <
class... Args,
class T1>
535Ptr<const AttributeAccessor>
541template <
class... Args,
class T1,
class T2>
542Ptr<const AttributeAccessor>
Attribute helper (ATTRIBUTE_ )macros definition.
Represent the type of an attribute.
Hold a value for an Attribute.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
Checker for attribute values storing tuples.
virtual const std::vector< Ptr< const AttributeChecker > > & GetCheckers() const =0
Get the checkers for all tuple elements.
AttributeValue implementation for Tuple.
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
void Set(const result_type &value)
Set the stored values.
bool GetAccessor(T &value) const
Set the given variable to the values stored by this TupleValue object.
std::tuple< Args... > value_type
Type of value stored in the TupleValue.
result_type Get() const
Get the stored values as a std::tuple.
Ptr< AttributeValue > Copy() const override
bool SetValueImpl(std::index_sequence< Is... >, const std::vector< Ptr< AttributeValue > > &values)
Set the attribute values starting from the given values.
std::tuple< std::invoke_result_t< decltype(&Args::Get), Args >... > result_type
Type returned by Get or passed in Set.
value_type GetValue() const
Get the attribute values as a tuple.
value_type m_value
Tuple of attribute values.
Internal checker class templated to each AttributeChecker for each entry in the tuple.
std::string GetUnderlyingTypeInformation() const override
bool HasUnderlyingTypeInformation() const override
std::string GetValueTypeName() const override
std::vector< Ptr< const AttributeChecker > > m_checkers
attribute checkers
TupleChecker(Ts... checkers)
Constructor.
const std::vector< Ptr< const AttributeChecker > > & GetCheckers() const override
Get the checkers for all tuple elements.
bool Check(const AttributeValue &value) const override
Ptr< AttributeValue > Create() const override
bool Copy(const AttributeValue &source, AttributeValue &destination) const override
Copy the source to the destination.
Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1)
Create an AttributeAccessor for a class data member of type tuple, or a lone class get functor or set...
auto MakeTupleValue(T2 t)
Create a TupleValue object.
Ptr< const AttributeAccessor > MakeAccessorHelper(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
ns3::StringValue attribute value declarations.
static Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
static Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1)
Create an AttributeAccessor for a class data member of type tuple, or a lone class get functor or set...
static Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1, T2 a2)
Create an AttributeAccessor using a pair of get functor and set methods from a class.
static TupleValue< Args... > MakeTupleValue(const typename TupleValue< Args... >::result_type &t)
Create a TupleValue object.
Helper class defining static methods for MakeTupleChecker and MakeTupleAccessor that are called when ...
static Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
static Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1)
Create an AttributeAccessor for a class data member of type tuple, or a lone class get functor or set...
static Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1, T2 a2)
Create an AttributeAccessor using a pair of get functor and set methods from a class.