/************************************************************************* Copyright Rice University, 2004-2011. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. **************************************************************************/ #ifndef __RVL_LDCREDN #define __RVL_LDCREDN #include "localdata.hh" namespace RVL { /** Local FOCE */ template class LocalConstEval { public: virtual ~LocalConstEval() {} /** Eval method for LDCs */ virtual void operator()(vector const *> & sources) = 0; }; /** Unary Local FOCE with templated return type interface. */ template class UnaryLocalConstEval : public LocalConstEval { public: virtual ~UnaryLocalConstEval() {} /** Evaluation method for LDCs */ virtual void operator()(LocalDataContainer const & source) = 0; /** Generic evaluation method */ void operator()(vector const *> & sources) { try { if (sources.size() != 1) { RVLException e; e<<"Error: UnaryLocalConstEval::opeartor() (generic)\n"; e<<"input length != 1\n"; throw e; } return (*this)(*(sources[0])); } catch (RVLException & e) { e<<"\ncalled from UnaryLocalConstEval::operator() (generic)\n"; throw e; } } }; /** Binary Local FOCE with templated return type interface. */ template class BinaryLocalConstEval : public LocalConstEval { public: virtual ~BinaryLocalConstEval() {} /** Evaluation method for LDCs */ virtual void operator () (LocalDataContainer const & source1, LocalDataContainer const & source2) = 0; /** Generic evaluation method */ void operator()(vector const *> & sources) { try { if (sources.size() != 2) { RVLException e; e<<"Error: BinaryLocalConstEval::opeartor() (generic)\n"; e<<"input length != 2\n"; throw e; } (*this)(*(sources[0]),*(sources[1])); } catch (RVLException & e) { e<<"\ncalled from BinaryLocalConstEval::operator() (generic)\n"; throw e; } } }; /** Ternary Local FOCE with templated return type interface. */ template class TernaryLocalConstEval : public LocalConstEval { public: virtual ~TernaryLocalConstEval() {} /** Evaluation method for LDCs */ virtual void operator () (LocalDataContainer const & source1, LocalDataContainer const & source2, LocalDataContainer const & source3) = 0; /** Generic evaluation method */ void operator()(vector const *> & sources) { try { if (sources.size() != 3) { RVLException e; e<<"Error: TernaryLocalConstEval::operator() (generic)\n"; e<<"input length != 3\n"; throw e; } (*this)(*(sources[0]),*(sources[1]),*(sources[2])); } catch (RVLException & e) { e<<"\ncalled from TernaryLocalConstEval::operator() (generic)\n"; throw e; } } }; /** Quaternary Local FOCE with templated return type interface. */ template class QuaternaryLocalConstEval : public LocalConstEval { public: virtual ~QuaternaryLocalConstEval() {} /** Evaluation method for LDCs */ virtual void operator () (LocalDataContainer const & source1, LocalDataContainer const & source2, LocalDataContainer const & source3, LocalDataContainer const & source4) = 0; /** Generic evaluation method */ void operator()(vector const *> & sources) { try { if (sources.size() != 4) { RVLException e; e<<"Error: QuaternaryLocalConstEval::opeartor() (generic)\n"; e<<"input length != 3\n"; throw e; } (*this)(*(sources[0]),*(sources[1]),*(sources[2]),*(sources[3])); } catch (RVLException & e) { e<<"\ncalled from QuaternaryLocalConstEval::operator() (generic)\n"; throw e; } } }; /** local const eval hierarchy. use for evaluations without templated reduction types - for example, when reduction target is external, accessed by reference. */ template class UnaryLocalFunctionObjectConstEval : public FunctionObjectConstEval, public UnaryLocalConstEval { public: virtual ~UnaryLocalFunctionObjectConstEval() {} }; template class BinaryLocalFunctionObjectConstEval : public FunctionObjectConstEval, public BinaryLocalConstEval { public: virtual ~BinaryLocalFunctionObjectConstEval() {} }; template class TernaryLocalFunctionObjectConstEval : public FunctionObjectConstEval, public TernaryLocalConstEval { public: virtual ~TernaryLocalFunctionObjectConstEval() {} }; template class QuaternaryLocalFunctionObjectConstEval : public FunctionObjectConstEval, public QuaternaryLocalConstEval { public: virtual ~QuaternaryLocalFunctionObjectConstEval() {} }; /** local reduction function object hierarchy */ template class UnaryLocalFunctionObjectScalarRedn : public FunctionObjectScalarRedn, public UnaryLocalConstEval { private: UnaryLocalFunctionObjectScalarRedn(); public: UnaryLocalFunctionObjectScalarRedn(ValType val) : FunctionObjectScalarRedn(val) {} UnaryLocalFunctionObjectScalarRedn(UnaryLocalFunctionObjectScalarRedn const & f) : FunctionObjectScalarRedn(f) {} virtual ~UnaryLocalFunctionObjectScalarRedn() {} }; template class BinaryLocalFunctionObjectScalarRedn : public FunctionObjectScalarRedn, public BinaryLocalConstEval { private: BinaryLocalFunctionObjectScalarRedn(); public: BinaryLocalFunctionObjectScalarRedn(ValType val) : FunctionObjectScalarRedn(val) {} BinaryLocalFunctionObjectScalarRedn(BinaryLocalFunctionObjectScalarRedn const & f) : FunctionObjectScalarRedn(f) {} virtual ~BinaryLocalFunctionObjectScalarRedn() {} }; template class TernaryLocalFunctionObjectScalarRedn : public FunctionObjectScalarRedn, public TernaryLocalConstEval { private: TernaryLocalFunctionObjectScalarRedn(); public: TernaryLocalFunctionObjectScalarRedn(ValType val) : FunctionObjectScalarRedn(val) {} TernaryLocalFunctionObjectScalarRedn(TernaryLocalFunctionObjectScalarRedn const & f) : FunctionObjectScalarRedn(f) {} virtual ~TernaryLocalFunctionObjectScalarRedn() {} }; template class QuaternaryLocalFunctionObjectScalarRedn : public FunctionObjectScalarRedn, public QuaternaryLocalConstEval { private: QuaternaryLocalFunctionObjectScalarRedn(); public: QuaternaryLocalFunctionObjectScalarRedn(ValType val) : FunctionObjectScalarRedn(val) {} QuaternaryLocalFunctionObjectScalarRedn(QuaternaryLocalFunctionObjectScalarRedn const & f) : FunctionObjectScalarRedn(f) {} virtual ~QuaternaryLocalFunctionObjectScalarRedn() {} }; } #endif