GenericReader module

Module contents

template<typename sequence_object_type>
class GenericReader

Generic reader that exposes an InputIterator.

This reader implements a pattern where new objects can be retrieved one at a time and exposes the resulting sequence as an InputIterator. You must implement the following method:

sequence_object_type* next_item(): Retrieve and return the next item in the sequence (or NULL if the sequence has terminated).

The template takes care of the mechanics of exposing the objects and maintaining references for as long as necessary.

You must also implement whatever machinery you need to set up the input source to the reader.

Public Types

typedef GenericInputIterator iterator

Public Functions

GenericReader()
GenericReader(GenericReader const &other)
virtual ~GenericReader()
GenericInputIterator begin()

Get an iterator pointing to the current sequence.

NOTE: We assume that begin() will usually be called just once in order to iterate over the entire sequence from beginning to end. Since this is an InputIterator, we do not guarantee that calling begin() a second time will yield a new iterator that will reproduce the sequence. (In fact, we can almost guarantee the opposite.)

GenericInputIterator end()

Get an iterator pointing past the end of the sequence.

Protected Functions

virtual sequence_object_ptr next_item() = 0

Private Types

typedef boost::shared_ptr<sequence_object_type> sequence_object_ptr

Private Functions

virtual void advance()
virtual bool sequence_is_finished() const

Private Members

sequence_object_ptr CurrentSequenceObject
sequence_object_ptr PreviousSequenceObject
class GenericInputIterator : public std::iterator<std::input_iterator_tag, sequence_object_type>

Public Types

template<>
typedef std::ptrdiff_t difference_type
template<>
typedef sequence_object_type value_type
template<>
typedef value_type const &reference
template<>
typedef value_type const &const_reference
template<>
typedef value_type const *pointer
template<>
typedef value_type const *const_pointer
template<>
typedef std::input_iterator_tag iterator_category

Public Functions

template<>
GenericInputIterator()
template<>
GenericInputIterator(GenericReader *parent)
template<>
GenericInputIterator(GenericInputIterator const &other)
template<>
virtual ~GenericInputIterator()
template<>
GenericInputIterator &operator=(GenericInputIterator const &other)
template<>
bool operator==(GenericInputIterator const &other) const
template<>
bool operator!=(GenericInputIterator const &other) const
template<>
reference operator*()
template<>
const_reference operator*() const
template<>
pointer operator->()
template<>
const_pointer operator->() const
template<>
GenericInputIterator &operator++()
template<>
GenericInputIterator operator++(int)

Private Types

template<>
typedef boost::shared_ptr<sequence_object_type> sequence_object_ptr

Private Members

template<>
sequence_object_ptr CurrentSequenceObject
template<>
GenericReader *Parent