/* -*- mode: c++ -*- 
*/
/* 

    GIFT, a flexible content based image retrieval system.
    Copyright (C) 1998, 1999, 2000 CUI, University of Geneva

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/
#ifndef _CCUTOFFFUNCTION
#define _CCUTOFFFUNCTION

#include <functional>

template<class content_type>
class CCutoffFunction:public unary_function<bool,content_type>{
 protected:
  ///
  double mUpperCutoff;
  ///
  double mLowerCutoff;
 public:
  ///
  virtual bool isOnePass(){
    return true;
  }
  ///
  virtual void startFirstPass(){
    assert(!"should never be called");
  }
  ///
  virtual void adjustInnerState(const content_type&){
    assert(!"should never be called");
  }
  ///
  virtual bool operator()(const content_type& i)const{
    return (i.getProbability()>mUpperCutoff)
      ||
      (i.getProbability()<=mLowerCutoff);
  };
  ///
  inline void setUpperCutoff(double inUC){
    mUpperCutoff=inUC;
  }
  ///
  inline void setLowerCutoff(double inLC){
    mLowerCutoff=inLC;
  }
  ///
  virtual CCutoffFunction* clone()const{
    assert(!"should never be called");
  };
};

template<class content_type>
class CCFAbsolute:public CCutoffFunction<content_type>{
 protected:
 public:
  CCFAbsolute(double inMin=0){
  };
  
  ///
  virtual bool isOnePass(){
    return true;
  }
  ///
  virtual void startFirstPass(){
    assert(0);
  }
  ///
  virtual void adjustInnerState(const content_type&){
    assert(0);
  }
  ///
  virtual bool operator()(const content_type& i)const{
/*     cout << "[" << i.getProbability() */
/* 	 << "-" << mUpperCutoff */
/* 	 << "+" << mLowerCutoff << "]"; */
    return (i.getProbability()>mUpperCutoff)
      ||
      (i.getProbability()<=mLowerCutoff);
  };
  ///
  virtual CCutoffFunction<content_type>* clone()const{
    return new CCFAbsolute(*this);
  };
};

#endif

Documentation generated by muellerw@pc7170 on Son Okt 8 16:04:40 CEST 2000