contrib/mul/mbl/mbl_data_wrapper_mixer.h
Go to the documentation of this file.
00001 // This is mul/mbl/mbl_data_wrapper_mixer.h
00002 #ifndef mbl_data_wrapper_mixer_h
00003 #define mbl_data_wrapper_mixer_h
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Tim Cootes
00010 // \brief Concatenate together data in two or more mbl_data_wrapper objects
00011 
00012 #include <mbl/mbl_data_wrapper.h>
00013 #include <vcl_vector.h>
00014 
00015 //: Concatenate together data in two or more mbl_data_wrapper objects
00016 template<class T>
00017 class mbl_data_wrapper_mixer : public mbl_data_wrapper<T>
00018 {
00019   vcl_vector<mbl_data_wrapper<T> *> wrapper_;
00020   unsigned long n_;
00021   unsigned long index_;
00022   unsigned long current_wrapper_;
00023  public:
00024   //: Default constructor
00025   mbl_data_wrapper_mixer();
00026 
00027   //: Constructor
00028   // Sets up object to return examples from wrapper[i] (i=0..n-1) in turn
00029   // The wrappers must be kept in scope, this does not take a copy.
00030   mbl_data_wrapper_mixer(mbl_data_wrapper<T> **wrapper, unsigned long n_wrappers);
00031 
00032   //: Constructor
00033   // Sets up object to return examples from wrapper[i] (i=0..n-1) in turn
00034   // The wrappers must be kept in scope, this does not take a copy.
00035   mbl_data_wrapper_mixer(vcl_vector<mbl_data_wrapper<T> *> wrapper);
00036 
00037   //: Construct to mix two data wrappers
00038   // Sets up object to return examples from wrapper1 then wrapper2
00039   // The wrappers must be kept in scope, this does not take a copy
00040   // (Pointers are retained).
00041   mbl_data_wrapper_mixer(mbl_data_wrapper<T>& wrapper1,
00042                          mbl_data_wrapper<T>& wrapper2);
00043 
00044   //: Sets up object to return examples from wrapper[i] (i=0..n-1) in turn
00045   // The wrappers must be kept in scope, this does not take a copy.
00046   void set(mbl_data_wrapper<T> **wrapper, unsigned long n_wrappers);
00047 
00048   //: Default destructor
00049   virtual ~mbl_data_wrapper_mixer();
00050 
00051   //: Number of objects available
00052   virtual unsigned long size() const;
00053 
00054   //: Reset so that current() returns first object
00055   virtual void reset();
00056 
00057   //: Return current object
00058   virtual const T& current();
00059 
00060   //: Move to next object, returning true if is valid
00061   virtual bool next();
00062 
00063   //: Return current index
00064   //  First example has index 0
00065   virtual unsigned long index() const;
00066 
00067   //: Move to element n
00068   //  First example has index 0
00069   virtual void set_index(unsigned long n);
00070 
00071   //: Create copy on heap and return base pointer
00072   virtual mbl_data_wrapper< T >* clone() const;
00073 
00074   //: Name of the class
00075   virtual vcl_string is_a() const;
00076 
00077   //: True if this is (or is derived from) class named s
00078   virtual bool is_class(vcl_string const& s) const;
00079 };
00080 
00081 #endif // mbl_data_wrapper_mixer_h