00001 #ifndef vnl_unary_function_h_ 00002 #define vnl_unary_function_h_ 00003 // This is vxl/vnl/vnl_unary_function.h 00004 00005 //: 00006 // \file 00007 // \brief Abstract 1D map 00008 // \author Andrew W. Fitzgibbon, Oxford RRG, 28 Nov 98 00009 // vnl_unary_function is an abstract map between two types (read spaces). 00010 00011 // 00012 // Modifications 00013 // 981128 AWF Initial version. 00014 // LSB Manchester 19/3/01 Documentation tidied 00015 // 00016 //----------------------------------------------------------------------------- 00017 00018 #include <vnl/vnl_numeric_limits.h> 00019 00020 //: Abstract 1D map 00021 template <class Return, class Argument> 00022 class vnl_unary_function { 00023 public: 00024 typedef vnl_numeric_limits<Return> limits; 00025 00026 //: Apply the function. The name is "f" rather than operator(), as the 00027 // function will generally be called through a pointer. Note that the 00028 // function is NOT const when you subclass. 00029 virtual Return f(Argument const& i) = 0; 00030 00031 // Return bounding cube of domain (inputs) 00032 // removed by awf simply to avoid implementing vnl_numeric_limits<vnl_vector<T> >. 00033 //virtual Argument get_domain_min() const { return vnl_numeric_limits<Argument>::min(); } 00034 //virtual Argument get_domain_max() const { return vnl_numeric_limits<Argument>::max(); } 00035 00036 //: Return bounding cube of range (outputs) 00037 virtual Return get_range_min() const { return vnl_numeric_limits<Return >::min(); } 00038 virtual Return get_range_max() const { return limits::max(); } 00039 00040 //: Copy should allocate a copy of this on the heap and return it. If 00041 // Subclasses do not implement this function, it will return null, but many 00042 // applications will never call it, so this may not be a problem for you. 00043 virtual vnl_unary_function<Return,Argument>* Copy() const { return 0; } 00044 00045 virtual ~vnl_unary_function() {} 00046 }; 00047 00048 #endif // vnl_unary_function_h_