localreduction.hh

Go to the documentation of this file.
00001 /*************************************************************************
00002 
00003 Copyright Rice University, 2004-2011.
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_LDCREDN
00034 #define __RVL_LDCREDN
00035 
00036 #include "localdata.hh"
00037 
00038 namespace RVL {
00039   
00041   template<typename DataType>
00042   class LocalConstEval {
00043   public:
00044     virtual ~LocalConstEval() {}
00046     virtual void operator()(vector<LocalDataContainer<DataType> const *> & sources) = 0;
00047   };
00048 
00050   template<typename DataType>
00051   class UnaryLocalConstEval
00052     : public LocalConstEval<DataType> {
00053   public:
00054     virtual ~UnaryLocalConstEval() {}
00055 
00057     virtual void operator()(LocalDataContainer<DataType> const & source) = 0;
00058 
00060     void operator()(vector<LocalDataContainer<DataType> const *> & sources) {
00061       try {
00062     if (sources.size() != 1) {
00063       RVLException e;
00064       e<<"Error: UnaryLocalConstEval::opeartor() (generic)\n";
00065       e<<"input length != 1\n";
00066       throw e;
00067     }
00068     return (*this)(*(sources[0]));
00069       }
00070       catch (RVLException & e) {
00071     e<<"\ncalled from UnaryLocalConstEval::operator() (generic)\n";
00072     throw e;
00073       }
00074     }
00075 
00076   };
00077 
00079   template<typename DataType>
00080   class BinaryLocalConstEval
00081     : public LocalConstEval<DataType>  {
00082   public:
00083     virtual ~BinaryLocalConstEval() {}
00084 
00086     virtual void operator () (LocalDataContainer<DataType> const & source1,
00087                   LocalDataContainer<DataType> const & source2) = 0;
00088 
00090     void operator()(vector<LocalDataContainer<DataType> const *> & sources) {
00091       try {
00092     if (sources.size() != 2) {
00093       RVLException e;
00094       e<<"Error: BinaryLocalConstEval::opeartor() (generic)\n";
00095       e<<"input length != 2\n";
00096       throw e;
00097     }
00098     (*this)(*(sources[0]),*(sources[1]));
00099       }
00100       catch (RVLException & e) {
00101     e<<"\ncalled from BinaryLocalConstEval::operator() (generic)\n";
00102     throw e;
00103       }
00104     }
00105   };
00106 
00108   template<typename DataType, typename ValType = DataType>
00109   class TernaryLocalConstEval
00110     : public LocalConstEval<DataType> {
00111   public:
00112     virtual ~TernaryLocalConstEval() {}
00113 
00115     virtual void operator () (LocalDataContainer<DataType> const & source1,
00116                   LocalDataContainer<DataType> const & source2,
00117                   LocalDataContainer<DataType> const & source3) = 0;
00118 
00120     void operator()(vector<LocalDataContainer<DataType> const *> & sources) {
00121       try {
00122     if (sources.size() != 3) {
00123       RVLException e;
00124       e<<"Error: TernaryLocalConstEval::operator() (generic)\n";
00125       e<<"input length != 3\n";
00126       throw e;
00127     }
00128     (*this)(*(sources[0]),*(sources[1]),*(sources[2]));
00129       }
00130       catch (RVLException & e) {
00131     e<<"\ncalled from TernaryLocalConstEval::operator() (generic)\n";
00132     throw e;
00133       }
00134     }
00135 
00136   };
00137 
00139   template<typename DataType>
00140   class QuaternaryLocalConstEval
00141     : public LocalConstEval<DataType> {
00142   public:
00143     virtual ~QuaternaryLocalConstEval() {}
00144 
00146     virtual void operator () (LocalDataContainer<DataType> const & source1,
00147                   LocalDataContainer<DataType> const & source2,
00148                   LocalDataContainer<DataType> const & source3,
00149                   LocalDataContainer<DataType> const & source4) = 0;
00150 
00152     void operator()(vector<LocalDataContainer<DataType> const *> & sources) {
00153       try {
00154     if (sources.size() != 4) {
00155       RVLException e;
00156       e<<"Error: QuaternaryLocalConstEval::opeartor() (generic)\n";
00157       e<<"input length != 3\n";
00158       throw e;
00159     }
00160     (*this)(*(sources[0]),*(sources[1]),*(sources[2]),*(sources[3]));
00161       }
00162       catch (RVLException & e) {
00163     e<<"\ncalled from QuaternaryLocalConstEval::operator() (generic)\n";
00164     throw e;
00165       }
00166     }
00167   };
00168 
00173   template<typename DataType>
00174   class UnaryLocalFunctionObjectConstEval
00175     : public FunctionObjectConstEval, public UnaryLocalConstEval<DataType> {
00176   public:
00177     virtual ~UnaryLocalFunctionObjectConstEval() {}
00178   };
00179 
00180   template<typename DataType>
00181   class BinaryLocalFunctionObjectConstEval
00182     : public FunctionObjectConstEval, public BinaryLocalConstEval<DataType> {
00183   public:
00184     virtual ~BinaryLocalFunctionObjectConstEval() {}
00185   };
00186 
00187   template<typename DataType>
00188   class TernaryLocalFunctionObjectConstEval
00189     : public FunctionObjectConstEval, public TernaryLocalConstEval<DataType> {
00190   public:
00191     virtual ~TernaryLocalFunctionObjectConstEval() {}
00192   };
00193 
00194   template<typename DataType>
00195   class QuaternaryLocalFunctionObjectConstEval
00196     : public FunctionObjectConstEval, public QuaternaryLocalConstEval<DataType> {
00197   public:
00198     virtual ~QuaternaryLocalFunctionObjectConstEval() {}
00199   };
00200 
00203   template<typename DataType, typename ValType>
00204   class UnaryLocalFunctionObjectScalarRedn
00205     : public FunctionObjectScalarRedn<ValType>, public UnaryLocalConstEval<DataType> {
00206   private:
00207     UnaryLocalFunctionObjectScalarRedn();
00208   public:
00209     UnaryLocalFunctionObjectScalarRedn(ValType val)
00210       : FunctionObjectScalarRedn<ValType>(val) {}
00211     UnaryLocalFunctionObjectScalarRedn(UnaryLocalFunctionObjectScalarRedn<DataType,ValType> const & f) 
00212       : FunctionObjectScalarRedn<ValType>(f) {}
00213     virtual ~UnaryLocalFunctionObjectScalarRedn() {}
00214   };
00215 
00216   template<typename DataType, typename ValType>
00217   class BinaryLocalFunctionObjectScalarRedn
00218     : public FunctionObjectScalarRedn<ValType>, public BinaryLocalConstEval<DataType> {
00219   private:
00220     BinaryLocalFunctionObjectScalarRedn();
00221   public:
00222     BinaryLocalFunctionObjectScalarRedn(ValType val)
00223       : FunctionObjectScalarRedn<ValType>(val) {}
00224     BinaryLocalFunctionObjectScalarRedn(BinaryLocalFunctionObjectScalarRedn<DataType,ValType> const & f) 
00225       : FunctionObjectScalarRedn<ValType>(f) {}
00226     virtual ~BinaryLocalFunctionObjectScalarRedn() {}
00227   };
00228 
00229   template<typename DataType, typename ValType>
00230   class TernaryLocalFunctionObjectScalarRedn
00231     : public FunctionObjectScalarRedn<ValType>, public TernaryLocalConstEval<DataType> {
00232   private:
00233     TernaryLocalFunctionObjectScalarRedn();
00234   public:
00235     TernaryLocalFunctionObjectScalarRedn(ValType val)
00236       : FunctionObjectScalarRedn<ValType>(val) {}
00237     TernaryLocalFunctionObjectScalarRedn(TernaryLocalFunctionObjectScalarRedn<DataType,ValType> const & f) 
00238       : FunctionObjectScalarRedn<ValType>(f) {}
00239     virtual ~TernaryLocalFunctionObjectScalarRedn() {}
00240   };
00241 
00242   template<typename DataType, typename ValType>
00243   class QuaternaryLocalFunctionObjectScalarRedn
00244     : public FunctionObjectScalarRedn<ValType>, public QuaternaryLocalConstEval<DataType> {
00245   private:
00246     QuaternaryLocalFunctionObjectScalarRedn();
00247   public:
00248     QuaternaryLocalFunctionObjectScalarRedn(ValType val)
00249       : FunctionObjectScalarRedn<ValType>(val) {}
00250     QuaternaryLocalFunctionObjectScalarRedn(QuaternaryLocalFunctionObjectScalarRedn<DataType,ValType> const & f) 
00251       : FunctionObjectScalarRedn<ValType>(f) {}
00252     virtual ~QuaternaryLocalFunctionObjectScalarRedn() {}
00253   };
00254 
00255 }
00256 
00257 #endif

Generated on 5 Jan 2017 for LocalRVL by  doxygen 1.4.7