contrib/mul/mfpf/mfpf_vec_cost_builder.h
Go to the documentation of this file.
00001 #ifndef mfpf_vec_cost_builder_h_
00002 #define mfpf_vec_cost_builder_h_
00003 //:
00004 // \file
00005 // \brief Base for classes which build mfpf_vec_cost objects.
00006 // \author Tim Cootes
00007 
00008 #include <mfpf/mfpf_vec_cost.h>
00009 
00010 #include <vsl/vsl_binary_io.h>
00011 #include <vcl_string.h>
00012 #include <vcl_memory.h>
00013 #include <vcl_iosfwd.h>
00014 
00015 //: Base for classes which build mfpf_vec_cost objects.
00016 class mfpf_vec_cost_builder
00017 {
00018 
00019  public:
00020 
00021   //: Dflt ctor
00022   mfpf_vec_cost_builder();
00023 
00024   //: Destructor
00025   virtual ~mfpf_vec_cost_builder();
00026 
00027 
00028   //: Create new vec_cost of appropriate type on heap
00029   virtual mfpf_vec_cost* new_cost() const =0;
00030 
00031   //: Initialise building
00032   // Must be called before any calls to add_example(...)
00033   virtual void clear(unsigned n_egs)=0;
00034 
00035   //: Add one example to the model
00036   virtual void add_example(const vnl_vector<double>& v)=0;
00037 
00038   //: Build object from the data supplied in add_example()
00039   virtual void build(mfpf_vec_cost&)=0;
00040 
00041   //: Initialise from a string stream
00042   virtual bool set_from_stream(vcl_istream &is);
00043 
00044   //: Version number for I/O
00045   short version_no() const;
00046 
00047   //: Name of the class
00048   virtual vcl_string is_a() const;
00049 
00050   //: Create a copy on the heap and return base class pointer
00051   virtual mfpf_vec_cost_builder* clone() const = 0;
00052 
00053   //: Print class to os
00054   virtual void print_summary(vcl_ostream& os) const =0;
00055 
00056   //: Save class to binary file stream
00057   virtual void b_write(vsl_b_ostream& bfs) const=0;
00058 
00059   //: Load class from binary file stream
00060   virtual void b_read(vsl_b_istream& bfs)=0;
00061 
00062   //: Create a concrete object, from a text specification.
00063   static vcl_auto_ptr<mfpf_vec_cost_builder> create_from_stream(vcl_istream &is);
00064 };
00065 
00066 //: Allows derived class to be loaded by base-class pointer
00067 void vsl_add_to_binary_loader(const mfpf_vec_cost_builder& b);
00068 
00069 //: Binary file stream output operator for class reference
00070 void vsl_b_write(vsl_b_ostream& bfs, const mfpf_vec_cost_builder& b);
00071 
00072 //: Binary file stream input operator for class reference
00073 void vsl_b_read(vsl_b_istream& bfs, mfpf_vec_cost_builder& b);
00074 
00075 //: Stream output operator for class reference
00076 vcl_ostream& operator<<(vcl_ostream& os,const mfpf_vec_cost_builder& b);
00077 
00078 //: Stream output operator for class pointer
00079 vcl_ostream& operator<<(vcl_ostream& os,const mfpf_vec_cost_builder* b);
00080 
00081 #endif // mfpf_vec_cost_builder_h_