00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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