00001 #ifndef rgrl_scale_estimator_h_ 00002 #define rgrl_scale_estimator_h_ 00003 00004 //: 00005 // \file 00006 // \author Amitha Perera 00007 // \date Feb 2003 00008 // 00009 00010 #include "rgrl_scale_sptr.h" 00011 #include "rgrl_object.h" 00012 00013 class rgrl_scale; 00014 class rgrl_match_set; 00015 00016 #include "rgrl_scale_estimator_sptr.h" 00017 00018 // We want to have smart pointers to the scale the weighted and 00019 // unweighted scale estimators, and so they should be reference 00020 // counted. However, derived classes may implement both interfaces, so 00021 // we must make sure that the having a smart pointer via either type 00022 // of base doesn't mess up the reference count. The solution: a the 00023 // reference counter is a virtual base class. Since it doesn't require 00024 // any special construction, the derived classes are not any more 00025 // complicated. 00026 00027 //: Interface for unweighted scale estimator. 00028 // 00029 // Actual estimators will probably inherit from (provide the interface 00030 // for) both this and for rgrl_scale_estimator_wgted 00031 // 00032 class rgrl_scale_estimator_unwgted 00033 : virtual public rgrl_object 00034 { 00035 public: 00036 rgrl_scale_estimator_unwgted(); 00037 00038 virtual 00039 ~rgrl_scale_estimator_unwgted(); 00040 00041 //: Estimated an unweighted scale. 00042 // 00043 // \a match_set stores the current matches, and, if not null, \a 00044 // current_scales has the current scale estimates. (Perhaps from the 00045 // previous iteration.) 00046 // 00047 virtual 00048 rgrl_scale_sptr 00049 estimate_unweighted( rgrl_match_set const& match_set, 00050 rgrl_scale_sptr const& current_scales, 00051 bool penalize_scaling = false) const = 0; 00052 00053 // Defines type-related functions 00054 rgrl_type_macro( rgrl_scale_estimator_unwgted, rgrl_object ); 00055 }; 00056 00057 00058 //: Interface for weighted scale estimator. 00059 // 00060 // Actual estimators will probably inherit from (provide the interface 00061 // for) both this and for rgrl_scale_estimator_wgted 00062 // 00063 class rgrl_scale_estimator_wgted 00064 : virtual public rgrl_object 00065 { 00066 public: 00067 rgrl_scale_estimator_wgted(); 00068 00069 virtual 00070 ~rgrl_scale_estimator_wgted(); 00071 00072 //: Estimated a weighted scale. 00073 // 00074 // \a match_set stores the current matches, and, if not null, \a 00075 // current_scales has the current scale estimates. (Perhaps from the 00076 // previous iteration.) 00077 // 00078 virtual 00079 rgrl_scale_sptr 00080 estimate_weighted( rgrl_match_set const& match_set, 00081 rgrl_scale_sptr const& current_scales, 00082 bool use_signature_only = false, 00083 bool penalize_scaling = false) const = 0; 00084 00085 // Defines type-related functions 00086 rgrl_type_macro( rgrl_scale_estimator_wgted, rgrl_object ); 00087 }; 00088 00089 00090 //: Interface for scale estimator that can estimate with and without weights. 00091 // 00092 class rgrl_scale_estimator 00093 : public rgrl_scale_estimator_unwgted, 00094 public rgrl_scale_estimator_wgted 00095 { 00096 public: 00097 static const vcl_type_info& type_id() 00098 { return typeid(rgrl_scale_estimator); } 00099 00100 virtual bool is_type( const vcl_type_info& type ) const 00101 { return (typeid(rgrl_scale_estimator) == type)!=0 || 00102 this->rgrl_scale_estimator_unwgted::is_type(type) || 00103 this->rgrl_scale_estimator_wgted::is_type(type); 00104 } 00105 }; 00106 00107 #endif // rgrl_scale_estimator_h_