diff --git a/src/core/object.cc b/src/core/object.cc index 993382bc1..4223d729b 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -45,10 +45,6 @@ Object::AggregateIterator::AggregateIterator () bool Object::AggregateIterator::HasNext (void) const { - if (m_current == 0 && m_first != 0) - { - return true; - } if (m_current != 0 && m_current->m_next != PeekPointer (m_first)) { return true; @@ -58,19 +54,12 @@ Object::AggregateIterator::HasNext (void) const Ptr Object::AggregateIterator::Next (void) { - if (m_current == 0) - { - m_current = m_first; - } - else - { - m_current = m_current->m_next; - } + m_current = m_current->m_next; return m_current; } Object::AggregateIterator::AggregateIterator (Ptr first) : m_first (first), - m_current (0) + m_current (first) {} diff --git a/src/core/object.h b/src/core/object.h index 78c6e65d1..80fe45497 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -47,12 +47,28 @@ class Object : public ObjectBase public: static TypeId GetTypeId (void); + /** + * \brief Iterate over the objects aggregated to an ns3::Object. + * + * This iterator does not allow you to iterate over the initial + * object used to call Object::GetAggregateIterator. + * + * Note: this is a java-style iterator. + */ class AggregateIterator { public: AggregateIterator (); + /** + * \returns true if HasNext can be called and return a non-null + * pointer, false otherwise. + */ bool HasNext (void) const; + + /** + * \returns the next aggregated object. + */ Ptr Next (void); private: friend class Object; @@ -114,6 +130,14 @@ public: */ void AggregateObject (Ptr other); + /** + * \returns an iterator to the first object aggregated to this + * object. + * + * If no objects are aggregated to this object, then, the returned + * iterator will be empty and AggregateIterator::HasNext will + * always return false. + */ AggregateIterator GetAggregateIterator (void) const; protected: