Public Member Functions
mbl_data_wrapper< T > Class Template Reference

Base class for objects which can return a set of objects, one at a time. More...

#include <mbl_data_wrapper.h>

Inheritance diagram for mbl_data_wrapper< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 mbl_data_wrapper ()
 Default constructor.
virtual ~mbl_data_wrapper ()
 Default destructor.
virtual unsigned long size () const =0
 Number of objects available.
virtual void reset ()=0
 Reset so that current() returns first object.
virtual const T & current ()=0
 Return current object.
virtual bool next ()=0
 Move to next object, returning true if is valid.
virtual unsigned long index () const =0
 Return current index.
virtual void set_index (unsigned long n)
 Move to element n.
virtual mbl_data_wrapper< T > * clone () const =0
 Create copy on heap and return base pointer.
virtual vcl_string is_a () const =0
 Name of the class.
virtual bool is_class (vcl_string const &s) const =0
 True if this is (or is derived from) class named s.

Detailed Description

template<class T>
class mbl_data_wrapper< T >

Base class for objects which can return a set of objects, one at a time.

This is an iterator-like object. However, unlike STL, generality is obtained by deriving from the class rather than providing a similar interface.

In particular one can query the object to find out how many examples to expect.

A typical use is to allow clients to build models from sets of data without having to hold all the data in memory at once.

Example:

  vnl_vector<double> my_sum(mbl_data_wrapper<vnl_vector<double> >& data)
  {
    data.reset();
    vnl_vector<double> sum = data.current();
    while (data.next())
      sum += data.current();
  }

Note: It should be fairly simple to provide an iterator type object which steps through the examples in a standard STL way by using this class.

Definition at line 41 of file mbl_data_wrapper.h.


Constructor & Destructor Documentation

template<class T >
mbl_data_wrapper< T >::mbl_data_wrapper ( )

Default constructor.

Definition at line 16 of file mbl_data_wrapper.txx.

template<class T >
mbl_data_wrapper< T >::~mbl_data_wrapper ( ) [virtual]

Default destructor.

Definition at line 22 of file mbl_data_wrapper.txx.


Member Function Documentation

template<class T>
virtual mbl_data_wrapper< T >* mbl_data_wrapper< T >::clone ( ) const [pure virtual]

Create copy on heap and return base pointer.

This will create an independent iterator on the underlying data. The original data is not copied. Be careful of destruction of underlying data.

Implemented in mbl_file_data_wrapper< T >, mbl_selected_data_wrapper< T >, mbl_data_array_wrapper< T >, mbl_data_wrapper_mixer< T >, and mbl_data_array_ptr_wrapper< T >.

template<class T>
virtual const T& mbl_data_wrapper< T >::current ( ) [pure virtual]
template<class T>
virtual unsigned long mbl_data_wrapper< T >::index ( ) const [pure virtual]
template<class T>
virtual vcl_string mbl_data_wrapper< T >::is_a ( ) const [pure virtual]
template<class T>
virtual bool mbl_data_wrapper< T >::is_class ( vcl_string const &  s) const [pure virtual]
template<class T>
virtual bool mbl_data_wrapper< T >::next ( ) [pure virtual]
template<class T>
virtual void mbl_data_wrapper< T >::reset ( ) [pure virtual]
template<class T >
void mbl_data_wrapper< T >::set_index ( unsigned long  n) [virtual]

Move to element n.

First example has index 0

Reimplemented in mbl_selected_data_wrapper< T >, mbl_data_array_wrapper< T >, mbl_data_wrapper_mixer< T >, and mbl_data_array_ptr_wrapper< T >.

Definition at line 29 of file mbl_data_wrapper.txx.

template<class T>
virtual unsigned long mbl_data_wrapper< T >::size ( ) const [pure virtual]

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