Kea 2.7.6
|
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::Rdata & | getCurrent () 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. | |
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.
|
inlineprotected |
|
inlinevirtual |
|
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.
|
pure virtual |
Return the current Rdata
corresponding to the rdata cursor.
rdata::Rdata
object corresponding to the rdata cursor.
|
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.
true
if the rdata cursor has reached the end of the rdata list; otherwise false
.
|
pure virtual |
Move the rdata cursor to the next RDATA in the rdata list (if any).
This method should never throw an exception.