CVR-Lib last update 20 Sep 2009

cvrChannelProcessingInterface.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007
00003  * ITCR, Pablo Alvarado
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   cvrChannelProcessingInterface.h
00043  *         Simple interface from which all functors that process a matrix<T>
00044  *         to produce another matrix can be inherited.
00045  *
00046  * \author Pablo Alvarado
00047  * \date   23.09.2007
00048  *
00049  * revisions ..: $Id: cvrChannelProcessingInterface.h,v 1.1 2007/10/14 02:45:37 alvarado Exp $
00050  */
00051 
00052 #ifndef _CVR_CHANNEL_PROCESSING_INTERFACE_H_
00053 #define _CVR_CHANNEL_PROCESSING_INTERFACE_H_
00054 
00055 #include "cvrGenericChannel.h"
00056 
00057 namespace cvr {
00058 
00059   /**
00060    * Class channelProcessingInterface
00061    *
00062    * Very simple interface to allow virtualization of classes that transform a
00063    * channel into another one of the same type.
00064    *
00065    * Note that it is required that the apply methods do not alter the internal
00066    * state of the class.
00067    *
00068    * \ingroup gInterfaces
00069    */
00070   template<typename T>
00071   class channelProcessingInterface {
00072   public:
00073 
00074     typedef typename genericChannel<T>::type channel_type;
00075 
00076     /**
00077      * Virtual destructor
00078      */
00079     virtual ~channelProcessingInterface() {};
00080 
00081     /**
00082      * On-place processing apply.
00083      *
00084      * The inherited methods should take the \a srcdest channel, process it in
00085      * some way, and on the same channel leave the result.  No restrictions are
00086      * imposed on whether the memory block of the resulting channel will be the
00087      * same that the one in the original channel.  As a matter of fact, it
00088      * usually won't be.
00089      *
00090      * If you need to ensure the memory constancy, and assuming the resulting
00091      * channel will always have the same size than the original one, then you
00092      * can use the following code:
00093      * \code
00094      * channelProcessingInterfaceInheritedClass<T> theFunctor;
00095      * channel<T> tmp;
00096      * theFunctor.apply(srcdest,tmp);
00097      * srcdest.fill(tmp)
00098      * \endcode
00099      *
00100      * which of course will be slower as it requires to copy all the data of
00101      * the result in the original channel.
00102      *
00103      * @param srcdest channel with the source data. The result
00104      *                will be left here too.
00105      * @return true if apply successful or false otherwise.
00106      */
00107     virtual bool apply(channel_type& srcdest) const = 0;
00108 
00109     /**
00110      * On-copy processing apply.
00111      *
00112      * The inherited methods take the \a src channel and process it leaving the
00113      * result in the \a dest channel.
00114      *
00115      * @param src channel with the source data.
00116      * @param dest channel where the result will be left.
00117      * @return true if apply successful or false otherwise.
00118      */
00119     virtual bool apply(const channel_type& src, channel_type& dest) const = 0;
00120   };
00121 }
00122 
00123 #endif
00124 

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