mbl_file_data_wrapper< T > Class Template Reference

#include <mbl_file_data_wrapper.h>

Inheritance diagram for mbl_file_data_wrapper< T >:

mbl_data_wrapper< T > List of all members.

Detailed Description

template<class T>
class mbl_file_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_file_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 43 of file mbl_file_data_wrapper.h.


Public Member Functions

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

Private Attributes

vsl_b_ifstream bfs_
vcl_string path_
d_
unsigned long index_
unsigned long size_

Constructor & Destructor Documentation

template<class T>
mbl_file_data_wrapper< T >::mbl_file_data_wrapper ( const vcl_string  path  ) 

Default constructor.

mbl_file_data_wrapper();

Definition at line 15 of file mbl_file_data_wrapper.txx.

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

Default destructor.

Definition at line 72 of file mbl_file_data_wrapper.txx.


Member Function Documentation

template<class T>
void mbl_file_data_wrapper< T >::calc_data_size (  ) 

count number of data items.

Definition at line 34 of file mbl_file_data_wrapper.txx.

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

Number of objects available.

Implements mbl_data_wrapper< T >.

Definition at line 78 of file mbl_file_data_wrapper.txx.

template<class T>
void mbl_file_data_wrapper< T >::reset (  )  [virtual]

Reset so that current() returns first object.

Implements mbl_data_wrapper< T >.

Definition at line 86 of file mbl_file_data_wrapper.txx.

template<class T>
const T & mbl_file_data_wrapper< T >::current (  )  [virtual]

Return current object.

Implements mbl_data_wrapper< T >.

Definition at line 121 of file mbl_file_data_wrapper.txx.

template<class T>
bool mbl_file_data_wrapper< T >::next (  )  [virtual]

Move to next object, returning true if is valid.

Implements mbl_data_wrapper< T >.

Definition at line 129 of file mbl_file_data_wrapper.txx.

template<class T>
unsigned long mbl_file_data_wrapper< T >::index (  )  const [virtual]

Return current index.

First example has index 0

Implements mbl_data_wrapper< T >.

Definition at line 157 of file mbl_file_data_wrapper.txx.

template<class T>
mbl_data_wrapper< T > * mbl_file_data_wrapper< T >::clone (  )  const [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.

Implements mbl_data_wrapper< T >.

Definition at line 182 of file mbl_file_data_wrapper.txx.

template<class T>
virtual vcl_string mbl_file_data_wrapper< T >::is_a (  )  const [virtual]

Name of the class.

Implements mbl_data_wrapper< T >.

template<class T>
bool mbl_file_data_wrapper< T >::is_class ( vcl_string const &  s  )  const [virtual]

True if this is (or is derived from) class named s.

Implements mbl_data_wrapper< T >.

Definition at line 188 of file mbl_file_data_wrapper.txx.

template<class T>
void mbl_data_wrapper< T >::set_index ( unsigned long  n  )  [virtual, inherited]

Move to element n.

First example has index 0

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

Definition at line 29 of file mbl_data_wrapper.txx.


Member Data Documentation

template<class T>
vsl_b_ifstream mbl_file_data_wrapper< T >::bfs_ [private]

Definition at line 46 of file mbl_file_data_wrapper.h.

template<class T>
vcl_string mbl_file_data_wrapper< T >::path_ [private]

Definition at line 49 of file mbl_file_data_wrapper.h.

template<class T>
T mbl_file_data_wrapper< T >::d_ [private]

Definition at line 52 of file mbl_file_data_wrapper.h.

template<class T>
unsigned long mbl_file_data_wrapper< T >::index_ [private]

Definition at line 55 of file mbl_file_data_wrapper.h.

template<class T>
unsigned long mbl_file_data_wrapper< T >::size_ [private]

Definition at line 58 of file mbl_file_data_wrapper.h.


The documentation for this class was generated from the following files:
Generated on Sun Sep 7 05:10:48 2008 for contrib/mul/mbl by  doxygen 1.5.1