00001 /************************************************************************* 00002 00003 Copyright Rice University, 2004, 2005, 2006. 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_DC 00034 #define __RVL_DC 00035 00036 #include "utility.hh" 00037 00038 namespace RVL { 00039 00040 /* Main interfaces */ 00041 00056 class FunctionObject: public Writeable { 00057 00058 public: 00059 00060 FunctionObject() {} 00061 FunctionObject(const FunctionObject &) {} 00062 virtual ~FunctionObject() {} 00063 00067 virtual string getName() const = 0; 00068 00070 virtual ostream & write(ostream & str) const { 00071 str<<"Function Object"<<"\n"; 00072 str<<" name = "<<getName()<<"\n"; 00073 return str; 00074 } 00075 00076 }; 00077 00081 class FunctionObjectConstEval: public Writeable { 00082 public: 00083 virtual ~FunctionObjectConstEval() {} 00084 virtual string getName() const = 0; 00085 virtual ostream & write(ostream & str) const { 00086 str<<"Function Object for Constant Evaluation:"<<"\n"; 00087 str<<" name = "<<getName()<<"\n"; 00088 return str; 00089 } 00090 }; 00091 00100 template<typename Scalar> 00101 class ScalarRedn { 00102 private: 00103 mutable Scalar val; 00106 ScalarRedn(); 00107 public: 00110 ScalarRedn(Scalar _val) 00111 : val(_val) {} 00112 virtual ~ScalarRedn() {} 00113 00116 virtual void setValue() = 0; 00118 virtual void setValue(Scalar _val) { val=_val; } 00121 virtual Scalar getValue() const { return val; } 00122 }; 00123 00125 template<typename ValType> 00126 class FunctionObjectScalarRedn: 00127 public FunctionObjectConstEval, public ScalarRedn<ValType> { 00128 private: 00129 FunctionObjectScalarRedn(); 00130 public: 00131 FunctionObjectScalarRedn(ValType val): ScalarRedn<ValType>(val) {} 00132 FunctionObjectScalarRedn(FunctionObjectScalarRedn<ValType> & f) 00133 : ScalarRedn<ValType>(f) {} 00134 virtual ~FunctionObjectScalarRedn() {} 00135 }; 00136 00137 00169 class DataContainer: public Writeable { 00170 public: 00171 00172 DataContainer() {} 00173 DataContainer(const DataContainer &) {} 00174 virtual ~DataContainer() {} 00175 00182 virtual void eval(FunctionObject & f, 00183 vector<DataContainer const *> & x) = 0; 00184 00186 virtual void eval(FunctionObjectConstEval & f, 00187 vector<DataContainer const *> & x) const = 0; 00188 }; 00189 00193 class DataContainerFactory: 00194 public Factory<DataContainer> { 00195 00196 public: 00197 00198 DataContainerFactory() {} 00199 DataContainerFactory(const DataContainerFactory &) {} 00200 virtual ~DataContainerFactory() {} 00201 00202 /* returns dynamically allocated DataContainer */ 00203 /* inherited from Factory - 25.04.10 00204 virtual DataContainer * build() const = 0; 00205 */ 00206 00212 virtual bool compare( DataContainerFactory const & dcf) const = 0; 00213 00218 virtual bool isCompatible(DataContainer const & dc) const = 0; 00219 00220 }; 00221 00222 } 00223 00224 #endif 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234