contrib/gel/gevd/gevd_param_mixin.h
Go to the documentation of this file.
00001 #ifndef gevd_param_mixin_h_
00002 #define gevd_param_mixin_h_
00003 //=======================================================================
00004 //:
00005 // \file
00006 // \brief A mixin to package algorithm parameters
00007 //
00008 //   The base class for blocks of algorithm parameters. Algorithms,
00009 //   such as edge detection, would inherit specializations of this mixin
00010 //   which contain the actual parameters and methods to validate the
00011 //   parameters.
00012 //
00013 // \author J.L. Mundy
00014 // \date   November 28, 1997
00015 //
00016 // \verbatim
00017 //  Modifications:
00018 //   Rupert Curwen -  February 3, 1998
00019 //      Added the ParamModifier class as an abstract base class which
00020 //      will allow parameter blocks to support generic "modifier"
00021 //      classes.  A parameter class defines the virtual method
00022 //      DescribeParams, which takes a ParamModifier as an argument.
00023 //      The parameter block calls AddParam on this ParamModifier for
00024 //      each of the parameters in the block.  For example, the
00025 //      particular ParamModifier passed into the method might be one
00026 //      which builds a dialog which will then modify the parameter
00027 //      class.  Or it might just print the values to a stream.  See
00028 //      Segmentation/Detection/DetectorParams for an example of use.
00029 // \endverbatim
00030 //======================================================================
00031 
00032 #include <vcl_string.h>
00033 
00034 #if 0 // not implemented
00035 class ParamModifier;
00036 #endif
00037 
00038 class gevd_param_mixin
00039 {
00040   bool valid_;
00041   vcl_string error_msg_;
00042  public:
00043   //=====================================================
00044   //: Constructor.  By default a constructed parameter block is valid.
00045   gevd_param_mixin() : valid_(true) {}
00046   // Destructor
00047   virtual ~gevd_param_mixin() {}
00048   //=====================================================
00049   virtual bool SanityCheck();
00050   bool Valid() const { return valid_; }
00051   const char* GetErrorMsg() const { return error_msg_.c_str(); }
00052   void SetErrorMsg(const char* msg);
00053 #if 0// not implemented in vxl
00054   virtual void Describe(ParamModifier&) {}
00055 #endif
00056 };
00057 
00058 #if 0 // not implemented in vxl
00059 class ParamModifier
00060 {
00061  virtual ~ParamModifier() {}
00062 
00063  public:
00064   //------------------------------------------------------------
00065   //: These are some standard boolean choice styles defined for convenience.
00066   enum BoolChoiceStyle { TrueFalse, OnOff, YesNo };
00067 
00068   //------------------------------------------------------------
00069   //: Name those parameters which follow.
00070   virtual void Name(const vcl_string& name) = 0;
00071 
00072   //------------------------------------------------------------
00073   //: Add a float parameter.
00074   virtual void AddParam(const vcl_string& name, float& value) = 0;
00075 
00076   //------------------------------------------------------------
00077   //: Add a double parameter.
00078   virtual void AddParam(const vcl_string& name, double& value) = 0;
00079 
00080   //------------------------------------------------------------
00081   //: Add an integer parameter.
00082   virtual void AddParam(const vcl_string& name, int& value) = 0;
00083 
00084   //------------------------------------------------------------
00085   //: Add a boolean parameter.
00086   virtual void AddParam(const vcl_string& name, bool& value) = 0;
00087 
00088   //------------------------------------------------------------
00089   //: Add a choice parameter.
00090   //  virtual void AddParam(const vcl_string& name, int& value, UIChoice* choices) = 0;
00091 
00092   //------------------------------------------------------------
00093   //: Add a boolean choice parameter, using one of the convenient standard styles.
00094   virtual void AddParam(const vcl_string& name, bool& value,
00095                         BoolChoiceStyle style = TrueFalse) = 0;
00096 };
00097 #endif
00098 #endif // gevd_param_mixin_h_