CVR-Lib last update 20 Sep 2009

cvrFunctor.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1998-2005
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  *
00006  * This file is part of the Computer Vision and Robotics Library (CVR-Lib)
00007  *
00008  * The CVR-Lib is free software; you can redistribute it and/or
00009  * modify it under the terms of the BSD License.
00010  *
00011  * All rights reserved.
00012  *
00013  * Redistribution and use in source and binary forms, with or without
00014  * modification, are permitted provided that the following conditions are met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright notice,
00017  *    this list of conditions and the following disclaimer.
00018  *
00019  * 2. Redistributions in binary form must reproduce the above copyright notice,
00020  *    this list of conditions and the following disclaimer in the documentation
00021  *    and/or other materials provided with the distribution.
00022  *
00023  * 3. Neither the name of the authors nor the names of its contributors may be
00024  *    used to endorse or promote products derived from this software without
00025  *    specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038  */
00039 
00040 
00041 /**
00042  * \file   cvrFunctor.h
00043  *         Contains the class cvr::functor, which is the parent class for all
00044  *         functionality classes that work on images, matrices, etc.
00045  * \author Thomas Rusert
00046  * \date   14.04.1999
00047  *
00048  * $Id: cvrFunctor.h,v 1.14 2006/08/29 12:27:42 doerfler Exp $
00049  */
00050 
00051 #ifndef _CVR_FUNCTOR_H_
00052 #define _CVR_FUNCTOR_H_
00053 
00054 #include "cvrParametersManager.h"
00055 #include "cvrIoHandler.h"
00056 
00057 namespace cvr  {
00058 
00059   /**
00060    * Base class for all lti functors.
00061    *
00062    * Every lti fuctor must have at least the member <em>apply()</em>,
00063    * which "applies" the functor's functionality on the data given through the
00064    * arguments of the apply method.
00065    *
00066    * There are two kinds of apply methods:
00067    *  - the "on-copy"-apply returns the result in a new
00068    *    object, and the original data will not be modified.
00069    *  - the "on-place"-apply returns the result on the same input object and
00070    *    therefore the original data will be destroyed.
00071    *
00072    * The operation of the functor can be controled with some parameters,
00073    * which will can be set with the "setParameters" member-function.
00074    *
00075    * Each functor may have also other setABC() members, to allow the
00076    * change of just one parameter-item at the time.
00077    */
00078   class functor : public ioObject,
00079                   public status,
00080                   public parametersManager {
00081 
00082   public:
00083     /**
00084      * Parameters class of functor is empty and abstract
00085      */
00086     class parameters : public parametersManager::parameters {
00087     public:
00088       /**
00089        * Default constructor
00090        */
00091       parameters();
00092 
00093       /**
00094        * Copy constructor
00095        */
00096       parameters(const parameters& other);
00097 
00098       /**
00099        * Destructor
00100        */
00101       virtual ~parameters();
00102 
00103       /**
00104        * Returns the name of this class
00105        */
00106       virtual const std::string& name() const = 0;
00107 
00108       /**
00109        * Returns a pointer to a clone of the parameters.
00110        */
00111       virtual parameters* clone() const = 0;
00112 
00113       /**
00114        * Returns a pointer to a clone of the parameters.
00115        */
00116       virtual parameters* newInstance() const = 0;
00117     };
00118 
00119     /**
00120      * Default constructor
00121      */
00122     functor();
00123 
00124     /**
00125      * Copy constructor
00126      */
00127     functor(const functor& other);
00128 
00129     /**
00130      * Destructor
00131      */
00132     virtual ~functor();
00133 
00134     /**
00135      * Copy data of "other" functor.
00136      * Please note that the status string will _NOT_ be copied!
00137      */
00138     functor& copy(const functor& other);
00139 
00140     /**
00141      * Returns the name of this class.
00142      */
00143     virtual const std::string& name() const = 0;
00144 
00145     /**
00146      * Clone member
00147      */
00148     virtual functor* clone() const = 0;
00149 
00150     /**
00151      * Create new instance
00152      */
00153     virtual functor* newInstance() const = 0;
00154 
00155     /**
00156      * Write the parametersManager in the given ioHandler. The default
00157      * implementation is to write just the parameters object.
00158      *
00159      * @param handler the ioHandler to be used
00160      * @param complete if true (the default) the enclosing begin/end will
00161      *        be also written, otherwise only the data block will be written.
00162      * @return true if write was successful
00163      */
00164     virtual bool write(ioHandler& handler,
00165                        const bool complete=true) const;
00166 
00167     /**
00168      * Read the parametersManager from the given ioHandler.
00169      *
00170      * The default implementation is to read just the parameters object.
00171      *
00172      * Since this virtual method needs to know the exact type of the
00173      * parameters to call the proper read method, it will just assume
00174      * that the current parametersManager instance has a valid, consistent
00175      * parameter set.  If this is not the case, you need to
00176      * reimplement the read method to set first a dummy parameter
00177      * object or the correct type.
00178      *
00179      * @param handler the ioHandler to be used
00180      * @param complete if true (the default) the enclosing begin/end will
00181      *        be also written, otherwise only the data block will be written.
00182      * @return true if write was successful
00183      */
00184     virtual bool read(ioHandler& handler,const bool complete=true);
00185 
00186   };
00187 } // namespace cvr
00188 
00189 #endif
00190 

Generated on Sun Sep 20 22:07:59 2009 for CVR-Lib by Doxygen 1.5.8