LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiValidator.h

00001 /*
00002  * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 
00024 /*----------------------------------------------------------------
00025  * project ....: LTI Digital Image/Signal Processing Library
00026  * file .......: ltiValidator.h
00027  * authors ....: Jochen Wickel
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 5.12.2001
00030  * revisions ..: $Id: ltiValidator.h,v 1.8 2006/02/08 12:51:55 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_VALIDATOR_H_
00034 #define _LTI_VALIDATOR_H_
00035 
00036 //TODO: include only those files which are needed in this header!!
00037 
00038 // TODO: Check this include to parent class:
00039 #include "ltiFunctor.h"
00040 #include "ltiMatrix.h"
00041 
00042 namespace lti {
00043   //TODO: comment your class
00044   /**
00045    * Checks the validity of a matrix or vector with float or double
00046    * elements. A matrix is invalid, if it contains nan or inf elements.
00047    * Otherwise, it is assumed to be valid.
00048    */
00049   class validator : public functor {
00050   public:
00051 
00052     typedef bool (doubleValidator)(double);
00053 
00054     typedef bool (floatValidator)(float);
00055 
00056     /**
00057      * the parameters for the class validator
00058      */
00059     class parameters : public functor::parameters {
00060     public:
00061       /**
00062        * default constructor
00063        */
00064       parameters();
00065 
00066       /**
00067        * copy constructor
00068        * @param other the parameters object to be copied
00069        */
00070       parameters(const parameters& other);
00071 
00072       /**
00073        * destructor
00074        */
00075       ~parameters();
00076 
00077       /**
00078        * returns name of this type
00079        */
00080       const char* getTypeName() const;
00081 
00082       /**
00083        * copy the contents of a parameters object
00084        * @param other the parameters object to be copied
00085        * @return a reference to this parameters object
00086        */
00087       parameters& copy(const parameters& other);
00088 
00089       /**
00090        * copy the contents of a parameters object
00091        * @param other the parameters object to be copied
00092        * @return a reference to this parameters object
00093        */
00094       parameters& operator=(const parameters& other);
00095 
00096 
00097       /**
00098        * returns a pointer to a clone of the parameters
00099        */
00100       virtual functor::parameters* clone() const;
00101 
00102       /**
00103        * write the parameters in the given ioHandler
00104        * @param handler the ioHandler to be used
00105        * @param complete if true (the default) the enclosing begin/end will
00106        *        be also written, otherwise only the data block will be written.
00107        * @return true if write was successful
00108        */
00109       virtual bool write(ioHandler& handler,const bool complete=true) const;
00110 
00111       /**
00112        * read the parameters from the given ioHandler
00113        * @param handler the ioHandler to be used
00114        * @param complete if true (the default) the enclosing begin/end will
00115        *        be also written, otherwise only the data block will be written.
00116        * @return true if write was successful
00117        */
00118       virtual bool read(ioHandler& handler,const bool complete=true);
00119 
00120 #     ifdef _LTI_MSC_6
00121       /**
00122        * this function is required by MSVC only, as a workaround for a
00123        * very awful bug, which exists since MSVC V.4.0, and still by
00124        * V.6.0 with all bugfixes (so called "service packs") remains
00125        * there...  This method is also public due to another bug, so please
00126        * NEVER EVER call this method directly: use read() instead
00127        */
00128       bool readMS(ioHandler& handler,const bool complete=true);
00129 
00130       /**
00131        * this function is required by MSVC only, as a workaround for a
00132        * very awful bug, which exists since MSVC V.4.0, and still by
00133        * V.6.0 with all bugfixes (so called "service packs") remains
00134        * there...  This method is also public due to another bug, so please
00135        * NEVER EVER call this method directly: use write() instead
00136        */
00137       bool writeMS(ioHandler& handler,const bool complete=true) const;
00138 #     endif
00139 
00140       // ------------------------------------------------
00141       // the parameters
00142       // ------------------------------------------------
00143 
00144       //TODO: comment the parameters of your functor
00145       // If you add more parameters manually, do not forget to do following:
00146       // 1. indicate in the default constructor the default values
00147       // 2. make sure that the copy member also copy your new parameters
00148       // 3. make sure that the read and write members also read and
00149       //    write your parameters
00150 
00151       doubleValidator* isDoubleValid;
00152       floatValidator* isFloatValid;
00153 
00154       static bool defaultValidateDouble(double x);
00155 
00156       static bool defaultValidateFloat(float x);
00157 
00158     };
00159 
00160     /**
00161      * default constructor
00162      */
00163     validator();
00164 
00165     /**
00166      * copy constructor
00167      * @param other the object to be copied
00168      */
00169     validator(const validator& other);
00170 
00171     /**
00172      * destructor
00173      */
00174     virtual ~validator();
00175 
00176     /**
00177      * returns the name of this type ("validator")
00178      */
00179     virtual const char* getTypeName() const;
00180 
00181     //TODO: comment your apply methods!
00182 
00183     /**
00184      * operates on the given %parameter.
00185      * @param src vector<double> with the source data.
00186      * @return true if the vector is valid or false otherwise.
00187      */
00188     bool apply(const vector<double>& src) const;
00189 
00190     /**
00191      * operates on the given %parameter.
00192      * @param src vector<float> with the source data.
00193      * @return true if the vector is valid or false otherwise.
00194      */
00195     bool apply(const vector<float>& src) const;
00196 
00197     /**
00198      * operates on the given %parameter.
00199      * @param src matrix<double> with the source data.
00200      * @return true if the matrix is valid or false otherwise.
00201      */
00202     bool apply(const matrix<double>& src) const;
00203 
00204     /**
00205      * operates on the given %parameter.
00206      * @param src matrix<float> with the source data.
00207      * @return true if the matrix is valid  or false otherwise.
00208      */
00209     bool apply(const matrix<float>& src) const;
00210 
00211     /**
00212      * copy data of "other" functor.
00213      * @param other the functor to be copied
00214      * @return a reference to this functor object
00215      */
00216     validator& copy(const validator& other);
00217 
00218     /**
00219      * alias for copy member
00220      * @param other the functor to be copied
00221      * @return a reference to this functor object
00222      */
00223     validator& operator=(const validator& other);
00224 
00225     /**
00226      * returns a pointer to a clone of this functor.
00227      */
00228     virtual functor* clone() const;
00229 
00230     /**
00231      * returns used parameters
00232      */
00233     const parameters& getParameters() const;
00234 
00235     //TODO: comment the attributes of your functor
00236     // If you add more attributes manually, do not forget to do following:
00237     // 1. indicate in the default constructor the default values
00238     // 2. make sure that the copy member also copy your new attributes, or
00239     //    to ensure there, that these attributes are properly initialized.
00240 
00241   };
00242 }
00243 
00244 #endif

Generated on Sat Apr 10 15:26:21 2010 for LTI-Lib by Doxygen 1.6.1