19 #ifndef OBJECT_PTR_CONTAINER_H
20 #define OBJECT_PTR_CONTAINER_H
49 typedef std::map<std::size_t, Ptr<Object>>::const_iterator
Iterator;
71 std::size_t
GetN()
const;
126 template <
typename T,
typename U,
typename INDEX>
128 INDEX (T::*getN)()
const);
145 template <
typename T,
typename U,
typename INDEX>
159 template <
typename T>
175 template <
typename T>
181 return T::GetTypeId();
191 return "ns3::ObjectPtrContainerValue";
201 return "ns3::Ptr< " + T::GetTypeId().GetName() +
" >";
206 return ns3::Create<ObjectPtrContainerValue>();
213 if (src ==
nullptr || dst ==
nullptr)
255 std::size_t* index)
const = 0;
258 template <
typename T,
typename U,
typename INDEX>
264 bool DoGetN(
const ObjectBase*
object, std::size_t* n)
const override
266 const T* obj =
dynamic_cast<const T*
>(
object);
271 *n = (obj->*m_getN)();
277 std::size_t* index)
const override
279 const T* obj =
static_cast<const T*
>(
object);
281 return (obj->*m_get)(i);
284 Ptr<U> (T::*m_get)(INDEX)
const;
285 INDEX (T::*m_getN)()
const;
286 }* spec =
new MemberGetters();
293 template <
typename T,
typename U,
typename INDEX>
294 Ptr<const AttributeAccessor>
300 template <
typename T>
301 Ptr<const AttributeChecker>
304 return Create<internal::ObjectPtrContainerChecker<T>>();
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
allow setting and getting the value of an attribute.
Represent the type of an attribute.
Hold a value for an Attribute.
Anchor the ns-3 type and attribute system.
AttributeAccessor implementation for ObjectPtrContainerValue.
virtual bool DoGetN(const ObjectBase *object, std::size_t *n) const =0
Get the number of instances in the container.
bool Set(ObjectBase *object, const AttributeValue &value) const override
bool HasGetter() const override
bool Get(const ObjectBase *object, AttributeValue &value) const override
virtual Ptr< Object > DoGet(const ObjectBase *object, std::size_t i, std::size_t *index) const =0
Get an instance from the container, identified by index.
bool HasSetter() const override
virtual TypeId GetItemTypeId() const =0
Get the TypeId of the container class type.
Container for a set of ns3::Object pointers.
std::map< std::size_t, Ptr< Object > > m_objects
The container implementation.
std::size_t GetN() const
Get the number of Objects.
Iterator End() const
Get an iterator to the past-the-end Object.
Iterator Begin() const
Get an iterator to the first Object.
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Deserialize from a string.
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
Ptr< Object > Get(std::size_t i) const
Get a specific Object.
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Serialize each of the Object pointers to a string.
Ptr< AttributeValue > Copy() const override
Get a copy of this container.
ObjectPtrContainerValue()
Default constructor.
a unique identifier for an interface.
ObjectPtrContainerChecker implementation class.
TypeId GetItemTypeId() const override
Get the TypeId of the container class type.
bool HasUnderlyingTypeInformation() const override
Ptr< AttributeValue > Create() const override
bool Copy(const AttributeValue &source, AttributeValue &destination) const override
Copy the source to the destination.
bool Check(const AttributeValue &value) const override
std::string GetValueTypeName() const override
std::string GetUnderlyingTypeInformation() const override
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeObjectPtrContainerAccessor(Ptr< U >(T::*get)(INDEX) const, INDEX(T::*getN)() const)
Create an AttributeAccessor using a container class indexed get method.
Ptr< const AttributeChecker > MakeObjectPtrContainerChecker()
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::Ptr smart pointer declaration and implementation.