Kea 2.5.8
isc::dns::RdataIterator Class Referenceabstract

The RdataIterator class is an abstract base class that provides an interface for accessing RDATA objects stored in an RRset. More...

#include <rrset.h>

Constructors and Destructor

Note: The copy constructor and the assignment operator are intentionally defined as private to make it explicit that this is a pure base class.

 RdataIterator ()
 The default constructor.
 
virtual ~RdataIterator ()
 Destructor.
 
virtual void first ()=0
 Move the rdata cursor to the first RDATA in the rdata list (if any).
 
virtual void next ()=0
 Move the rdata cursor to the next RDATA in the rdata list (if any).
 
virtual const rdata::RdatagetCurrent () const =0
 Return the current Rdata corresponding to the rdata cursor.
 
virtual bool isLast () const =0
 Return true iff the rdata cursor has reached the end of the rdata list.
 

Detailed Description

The RdataIterator class is an abstract base class that provides an interface for accessing RDATA objects stored in an RRset.

While different derived classes of AbstractRRset may maintain the RDATA objects in different ways, the RdataIterator class provides a unified interface to iterate over the RDATA objects in a polymorphic manner.

Each derived class of AbstractRRset is expected to provide a concrete derived class of RdataIterator, and each derived RdataIterator class implements the unified interface in a way specific to the implementation of the corresponding derived AbstractRRset class. Using the design pattern terminology, this is a typical example of the Iterator pattern.

The RDATA objects stored in the RRset are considered to form a unidirectional list from the RdataIterator point of view (while the actual implementation in the derived RRset may not use a list). We call this unidirectional list the rdata list.

An RdataIterator object internally (and conceptually) holds a rdata cursor, which points to a specific item of the rdata list.

Note about design choice: as is clear from the interface, RdataIterator is not compatible with the standard iterator classes. Although it would be useful (for example, we could then use STL algorithms) and is not necessarily impossible, it would make the iterator implementation much more complicated. For instance, any standard iterator must be assignable and copy-constructible. So we'd need to implement RdataIterator::operator=() in a polymorphic way. This will require non-trivial implementation tricks. We believe the simplified iterator interface as provided by the RdataIterator class is sufficient in practice: Most applications will simply go through the RDATA objects contained in an RRset, examining (and possibly using) each object, as one path operation.

Definition at line 555 of file rrset.h.

Constructor & Destructor Documentation

◆ RdataIterator()

isc::dns::RdataIterator::RdataIterator ( )
inlineprotected

The default constructor.

This is intentionally defined as protected as this base class should never be instantiated (except as part of a derived class).

Definition at line 567 of file rrset.h.

◆ ~RdataIterator()

virtual isc::dns::RdataIterator::~RdataIterator ( )
inlinevirtual

Destructor.

Definition at line 570 of file rrset.h.

Member Function Documentation

◆ first()

virtual void isc::dns::RdataIterator::first ( )
pure virtual

Move the rdata cursor to the first RDATA in the rdata list (if any).

This method can safely be called multiple times, even after moving the rdata cursor forward by the next() method.

This method should never throw an exception.

◆ getCurrent()

virtual const rdata::Rdata & isc::dns::RdataIterator::getCurrent ( ) const
pure virtual

Return the current Rdata corresponding to the rdata cursor.

Returns
A reference to an rdata::Rdata object corresponding to the rdata cursor.

◆ isLast()

virtual bool isc::dns::RdataIterator::isLast ( ) const
pure virtual

Return true iff the rdata cursor has reached the end of the rdata list.

Once this method returns true, the behavior of any subsequent call to next() or getCurrent() is undefined. Likewise, the result of isLast() call followed by such undefined operations is also undefined.

This method should never throw an exception.

Returns
true if the rdata cursor has reached the end of the rdata list; otherwise false.

◆ next()

virtual void isc::dns::RdataIterator::next ( )
pure virtual

Move the rdata cursor to the next RDATA in the rdata list (if any).

This method should never throw an exception.


The documentation for this class was generated from the following file: