localevaluation.hh

Go to the documentation of this file.
00001 /*************************************************************************
00002 
00003 Copyright Rice University, 2004.
00004 All rights reserved.
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a
00007 copy of this software and associated documentation files (the "Software"),
00008 to deal in the Software without restriction, including without limitation
00009 the rights to use, copy, modify, merge, publish, distribute, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 furnished to do so, provided that the above copyright notice(s) and this
00012 permission notice appear in all copies of the Software and that both the
00013 above copyright notice(s) and this permission notice appear in supporting
00014 documentation.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
00019 RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
00020 NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
00021 DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00022 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00023 ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
00024 THIS SOFTWARE.
00025 
00026 Except as contained in this notice, the name of a copyright holder shall
00027 not be used in advertising or otherwise to promote the sale, use or other
00028 dealings in this Software without prior written authorization of the
00029 copyright holder.
00030 
00031 **************************************************************************/
00032 
00033 #ifndef __RVL_LDCEVAL
00034 #define __RVL_LDCEVAL
00035 
00036 #include "localdata.hh"
00037 
00038 namespace RVL {
00039 
00041   template<class DataType>
00042   class LocalEvaluation {
00043   public:
00044     LocalEvaluation() {}
00045     LocalEvaluation(const LocalEvaluation<DataType> &) {}
00046     virtual ~LocalEvaluation() {}
00048     virtual void operator()(LocalDataContainer<DataType> & target,
00049                 vector<LocalDataContainer<DataType> const *> & sources) = 0;
00050   };
00051 
00056   template<class DataType> 
00057   class LocalFunctionObject
00058     : public FunctionObject, public LocalEvaluation<DataType> {
00059   public:
00060     LocalFunctionObject() {}
00061     LocalFunctionObject(const LocalFunctionObject<DataType> &) {}
00062     virtual ~LocalFunctionObject() {}
00063   };
00064     
00067   template<class DataType>
00068   class UnaryLocalEvaluation: public LocalEvaluation<DataType> {
00069   public:
00070     UnaryLocalEvaluation() {}
00071     UnaryLocalEvaluation(const UnaryLocalEvaluation<DataType> &) {}
00072     virtual ~UnaryLocalEvaluation() {}
00073 
00075     virtual void operator () (LocalDataContainer<DataType> & target) = 0;
00076 
00078     using LocalEvaluation<DataType>::operator();
00079     virtual void operator()(LocalDataContainer<DataType> & target,
00080                 vector<LocalDataContainer<DataType> const *> & sources) {
00081       try {
00082     if (sources.size() != 0) {
00083       RVLException e;
00084       e<<"Error: UnaryLocalEvaluation::operator() (generic)\n";
00085       e<<"vector of sources not of length zero\n";
00086       throw e;
00087     }
00088     (*this)(target);
00089       }
00090       catch (RVLException & e) {
00091     e<<"\ncalled from UnaryLocalEvaluation::operator() (generic)\n";
00092     throw e;
00093       }
00094     }
00095   };
00096 
00100   template<class DataType>
00101   class UnaryLocalFunctionObject
00102     : public FunctionObject, public UnaryLocalEvaluation<DataType> {
00103   public:
00104     UnaryLocalFunctionObject() {}
00105     UnaryLocalFunctionObject(const UnaryLocalFunctionObject<DataType> &) {}
00106     virtual ~UnaryLocalFunctionObject() {}
00107   };
00108 
00111   template<class DataType>
00112   class BinaryLocalEvaluation: public LocalEvaluation<DataType> {
00113   public:
00114     BinaryLocalEvaluation() {}
00115     BinaryLocalEvaluation(const BinaryLocalEvaluation<DataType> &) {}
00116     virtual ~BinaryLocalEvaluation() {}
00118     using LocalEvaluation<DataType>::operator();
00119     virtual void operator () (LocalDataContainer<DataType> & target,
00120                   LocalDataContainer<DataType> const & source) = 0;
00121 
00123     void operator()(LocalDataContainer<DataType> & target,
00124             vector<LocalDataContainer<DataType> const *> & sources) {
00125       try {
00126     if (sources.size() != 1) {
00127       RVLException e;
00128       e<<"Error: BinaryLocalFunctionObject::operator() (generic)\n";
00129       e<<"vector of sources not of length zero\n";
00130       throw e;
00131     }
00132     (*this)(target,*(sources[0]));
00133       }
00134       catch (RVLException & e) {
00135     e<<"\ncalled from BinaryLocalFunctionObject::operator() (generic)\n";
00136     throw e;
00137       }
00138     }
00139   };
00140 
00144   template<class DataType>
00145   class BinaryLocalFunctionObject
00146     : public FunctionObject, public BinaryLocalEvaluation<DataType> {
00147   public:
00148     BinaryLocalFunctionObject() {}
00149     BinaryLocalFunctionObject(const BinaryLocalFunctionObject<DataType> &) {}
00150     virtual ~BinaryLocalFunctionObject() {}
00151   };
00152 
00155   template<class DataType>
00156   class TernaryLocalEvaluation: public LocalEvaluation<DataType> {
00157   public:
00158     TernaryLocalEvaluation() {}
00159     TernaryLocalEvaluation(const TernaryLocalEvaluation<DataType> &) {}
00160     virtual ~TernaryLocalEvaluation() {}
00161 
00163     using LocalEvaluation<DataType>::operator();
00164     virtual void operator () (LocalDataContainer<DataType> & target,
00165                   LocalDataContainer<DataType> const & source1,
00166                   LocalDataContainer<DataType> const & source2) = 0;
00167 
00169     virtual void operator()(LocalDataContainer<DataType> & target,
00170                 vector<LocalDataContainer<DataType> const *> & sources) {
00171       try {
00172     if (sources.size() != 2) {
00173       RVLException e;
00174       e<<"Error: TernaryLocalFunctionObject::operator() (generic)\n";
00175       e<<"vector of sources not of length 2\n";
00176       throw e;
00177     }
00178     (*this)(target,*(sources[0]),*(sources[1]));
00179       }
00180       catch (RVLException & e) {
00181     e<<"\ncalled from TernaryLocalFunctionObject::operator() (generic)\n";
00182     throw e;
00183       }
00184     }
00185   };
00186 
00190   template<class DataType>
00191   class TernaryLocalFunctionObject: 
00192     public FunctionObject, public TernaryLocalEvaluation<DataType> {
00193   public:
00194     TernaryLocalFunctionObject() {}
00195     TernaryLocalFunctionObject(const TernaryLocalFunctionObject<DataType> &) {}
00196     virtual ~TernaryLocalFunctionObject() {}
00197   };
00198 
00201   template<class DataType>
00202   class QuaternaryLocalEvaluation: public LocalEvaluation<DataType> {
00203   public:
00204     QuaternaryLocalEvaluation() {}
00205     QuaternaryLocalEvaluation(const QuaternaryLocalEvaluation<DataType> &) {}
00206     virtual ~QuaternaryLocalEvaluation() {}
00207 
00209     using LocalEvaluation<DataType>::operator();
00210     virtual void operator () (LocalDataContainer<DataType> & target,
00211                   LocalDataContainer<DataType> const & source1,
00212                   LocalDataContainer<DataType> const & source2,
00213                   LocalDataContainer<DataType> const & source3) = 0;
00214 
00216     virtual void operator()(LocalDataContainer<DataType> & target,
00217                 vector<LocalDataContainer<DataType> const *> & sources) {
00218       try {
00219     if (sources.size() != 3) {
00220       RVLException e;
00221       e<<"Error: QuaternaryLocalFunctionObject::operator() (generic)\n";
00222       e<<"vector of sources not of length 3\n";
00223       throw e;
00224     }
00225     (*this)(target,*(sources[0]),*(sources[1]),*(sources[2]));
00226       }
00227       catch (RVLException & e) {
00228     e<<"\ncalled from QuaternaryLocalFunctionObject::operator() (generic)\n";
00229     throw e;
00230       }
00231     }
00232 
00233   };
00234 
00238   template<class DataType>
00239   class QuaternaryLocalFunctionObject: 
00240     public FunctionObject, public QuaternaryLocalEvaluation<DataType> {
00241   public:
00242     QuaternaryLocalFunctionObject() {}
00243     QuaternaryLocalFunctionObject(const QuaternaryLocalFunctionObject<DataType> &) {}
00244     virtual ~QuaternaryLocalFunctionObject() {}
00245   };
00246 
00247 }
00248 
00249 #endif

Generated on 5 Jan 2017 for LocalRVL by  doxygen 1.4.7