Base class for objects which can return a set of objects, one at a time. More...
#include <mbl_data_wrapper.h>
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. |
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.
mbl_data_wrapper< T >::mbl_data_wrapper | ( | ) |
Default constructor.
Definition at line 16 of file mbl_data_wrapper.txx.
mbl_data_wrapper< T >::~mbl_data_wrapper | ( | ) | [virtual] |
Default destructor.
Definition at line 22 of file mbl_data_wrapper.txx.
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 >.
virtual const T& mbl_data_wrapper< T >::current | ( | ) | [pure virtual] |
Return current object.
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 >.
virtual unsigned long mbl_data_wrapper< T >::index | ( | ) | const [pure virtual] |
Return current index.
First example has index 0
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 >.
virtual vcl_string mbl_data_wrapper< T >::is_a | ( | ) | const [pure virtual] |
Name of the class.
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 >.
virtual bool mbl_data_wrapper< T >::is_class | ( | vcl_string const & | s | ) | const [pure virtual] |
True if this is (or is derived from) class named s.
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 >.
virtual bool mbl_data_wrapper< T >::next | ( | ) | [pure virtual] |
Move to next object, returning true if is valid.
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 >.
virtual void mbl_data_wrapper< T >::reset | ( | ) | [pure virtual] |
Reset so that current() returns first object.
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 >.
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.
virtual unsigned long mbl_data_wrapper< T >::size | ( | ) | const [pure virtual] |
Number of objects available.
Implemented in mbl_file_data_wrapper< T >, mbl_selected_data_wrapper< T >, mbl_data_wrapper_mixer< T >, mbl_data_array_wrapper< T >, and mbl_data_array_ptr_wrapper< T >.