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