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>
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());
285 std::istringstream iss(value);
286 std::vector<Ptr<AttributeValue>> values;
289 for (std::string elem; std::getline(iss, elem,
',');)
292 std::istringstream tmp{elem};
293 std::getline(tmp >> std::ws, value);
299 values.push_back(tupleChecker->GetCheckers().at(i++)->CreateValidValue(
StringValue(value)));
311 return SetValueImpl(std::index_sequence_for<Args...>{}, values);
314template <
class... Args>
318 std::ostringstream oss;
319 oss <<
"{" <<
Get() <<
"}";
323template <
class... Args>
327 return std::apply([](Args... values) { return std::make_tuple(values.Get()...); },
m_value);
330template <
class... Args>
334 m_value = std::apply([](
auto&&... args) {
return std::make_tuple(Args(args)...); }, value);
337template <
class... Args>
344template <
class... Args>
365template <
class... Args>
374 template <
class... Ts>
380 const std::vector<Ptr<const AttributeChecker>>&
GetCheckers()
const override
387 const auto v =
dynamic_cast<const TupleValue<Args...
>*>(&value);
393 [
this](Args... values) {
402 return "ns3::TupleValue";
422 const auto src =
dynamic_cast<const TupleValue<Args...
>*>(&source);
423 auto dst =
dynamic_cast<TupleValue<Args...
>*>(&destination);
424 if (src ==
nullptr || dst ==
nullptr)
443template <
class... Args>
449 template <
class... Ts>
467 template <
class T1,
class T2>
482template <
class... Args>
496 template <
class... Ts>
514 template <
class T1,
class T2>
523template <
class T1,
class T2>
530template <
class... Args,
class... Ts>
531Ptr<const AttributeChecker>
537template <
class... Args,
class T1>
538Ptr<const AttributeAccessor>
544template <
class... Args,
class T1,
class T2>
545Ptr<const AttributeAccessor>
Attribute helper (ATTRIBUTE_ )macros definition.
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
TupleValue(const result_type &value)
Construct this TupleValue from a std::tuple.
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.
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.
Namespace for implementation details.
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.