8#ifndef OBJECT_PTR_CONTAINER_H
9#define OBJECT_PTR_CONTAINER_H
49 typedef std::map<std::size_t, Ptr<Object>>::const_iterator
Iterator;
71 std::size_t
GetN()
const;
126template <
typename T,
typename U,
typename INDEX>
128 INDEX (T::*getN)() const);
145template <
typename T,
typename U,
typename INDEX>
147 Ptr<U> (T::*get)(INDEX) const);
193 return T::GetTypeId();
203 return "ns3::ObjectPtrContainerValue";
213 return "ns3::Ptr< " + T::GetTypeId().GetName() +
" >";
225 if (src ==
nullptr || dst ==
nullptr)
267 std::size_t* index)
const = 0;
270template <
typename T,
typename U,
typename INDEX>
276 bool DoGetN(
const ObjectBase*
object, std::size_t* n)
const override
278 const T* obj =
dynamic_cast<const T*
>(
object);
283 *n = (obj->*m_getN)();
289 std::size_t* index)
const override
291 const T* obj =
static_cast<const T*
>(
object);
293 return (obj->*m_get)(i);
296 Ptr<U> (T::*m_get)(INDEX)
const;
297 INDEX (T::*m_getN)()
const;
298 }* spec =
new MemberGetters();
305template <
typename T,
typename U,
typename INDEX>
306Ptr<const AttributeAccessor>
313Ptr<const AttributeChecker>
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 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.
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
bool HasSetter() const override
AttributeChecker implementation for ObjectPtrContainerValue.
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.
Smart pointer class similar to boost::intrusive_ptr.
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
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
Ptr< AttributeValue > Create() const override
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()
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.
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::Ptr smart pointer declaration and implementation.