contrib/mul/mbl/mbl_data_collector_base.h
Go to the documentation of this file.
00001 // This is mul/mbl/mbl_data_collector_base.h
00002 #ifndef mbl_data_collector_base_h_
00003 #define mbl_data_collector_base_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Tim Cootes
00010 // \brief Non-templated base class for mbl_data_collector<T>
00011 
00012 #include <vsl/vsl_binary_io.h>
00013 #include <vcl_string.h>
00014 
00015 //: Non-templated base class for mbl_data_collector<T>
00016 // Provided mainly because the Visual C++ compiler can't cope with
00017 // the double template instantiation for the binary IO
00018 class mbl_data_collector_base
00019 {
00020  public:
00021 
00022   //: Dflt ctor
00023   mbl_data_collector_base();
00024 
00025   //: Destructor
00026   virtual ~mbl_data_collector_base();
00027 
00028   //: Name of the class
00029   virtual vcl_string is_a() const;
00030 
00031   //: Does the name of the class match the argument?
00032   virtual bool is_class(vcl_string const& s) const;
00033 
00034   //: Create a copy on the heap and return base class pointer
00035   virtual mbl_data_collector_base* clone() const = 0;
00036 
00037   //: Print class to os
00038   virtual void print_summary(vcl_ostream& os) const = 0;
00039 
00040   //: Save class to binary file stream
00041   virtual void b_write(vsl_b_ostream& bfs) const = 0;
00042 
00043   //: Load class from binary file stream
00044   virtual void b_read(vsl_b_istream& bfs) = 0;
00045 };
00046 
00047   //: Allows derived class to be loaded by base-class pointer
00048   //  A loader object exists which is invoked by calls
00049   //  of the form "vsl_b_read(bfs,base_ptr);".  This loads derived class
00050   //  objects from the disk, places them on the heap and
00051   //  returns a base class pointer.
00052   //  In order to work the loader object requires
00053   //  an instance of each derived class that might be
00054   //  found.  This function gives the model class to
00055   //  the appropriate loader.
00056 void vsl_add_to_binary_loader(const mbl_data_collector_base& b);
00057 
00058   //: Binary file stream output operator for class reference
00059 void vsl_b_write(vsl_b_ostream& bfs, const mbl_data_collector_base& b);
00060 
00061   //: Binary file stream input operator for class reference
00062 void vsl_b_read(vsl_b_istream& bfs, mbl_data_collector_base& b);
00063 
00064   //: Stream output operator for class reference
00065 vcl_ostream& operator<<(vcl_ostream& os,const mbl_data_collector_base& b);
00066 
00067   //: Stream output operator for class pointer
00068 vcl_ostream& operator<<(vcl_ostream& os,const mbl_data_collector_base* b);
00069 
00070 #endif // mbl_data_collector_base_h_