Back to index

salome-med  6.5.0
InterpKernelValue.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __INTERPKERNELVALUE_HXX__
00021 #define __INTERPKERNELVALUE_HXX__
00022 
00023 #include "INTERPKERNELDefines.hxx"
00024 #include "InterpKernelException.hxx"
00025 #include "InterpKernelUnit.hxx"
00026 
00027 namespace INTERP_KERNEL
00028 {
00029   class INTERPKERNEL_EXPORT Value
00030   {
00031   public:
00032     virtual Value *newInstance() const = 0;
00033     virtual ~Value() { }
00034     virtual void setDouble(double val) throw(INTERP_KERNEL::Exception) = 0;
00035     virtual void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception) = 0;
00036     //unary
00037     virtual void positive() throw(INTERP_KERNEL::Exception) = 0;
00038     virtual void negate() throw(INTERP_KERNEL::Exception) = 0;
00039     virtual void sqrt() throw(INTERP_KERNEL::Exception) = 0;
00040     virtual void cos() throw(INTERP_KERNEL::Exception) = 0;
00041     virtual void sin() throw(INTERP_KERNEL::Exception) = 0;
00042     virtual void tan() throw(INTERP_KERNEL::Exception) = 0;
00043     virtual void abs() throw(INTERP_KERNEL::Exception) = 0;
00044     virtual void exp() throw(INTERP_KERNEL::Exception) = 0;
00045     virtual void ln() throw(INTERP_KERNEL::Exception) = 0;
00046     virtual void log10() throw(INTERP_KERNEL::Exception) = 0;
00047     //binary
00048     virtual Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00049     virtual Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00050     virtual Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00051     virtual Value *div(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00052     virtual Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00053     virtual Value *max(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00054     virtual Value *min(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00055     virtual Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00056     virtual Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
00057     //ternary
00058     virtual Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception) = 0;
00059   };
00060 
00061   class INTERPKERNEL_EXPORT ValueDouble : public Value
00062   {
00063   public:
00064     ValueDouble();
00065     Value *newInstance() const;
00066     void setDouble(double val) throw(INTERP_KERNEL::Exception);
00067     void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception);
00068     //
00069     double getData() const { return _data; }
00070     void positive() throw(INTERP_KERNEL::Exception);
00071     void negate() throw(INTERP_KERNEL::Exception);
00072     void sqrt() throw(INTERP_KERNEL::Exception);
00073     void cos() throw(INTERP_KERNEL::Exception);
00074     void sin() throw(INTERP_KERNEL::Exception);
00075     void tan() throw(INTERP_KERNEL::Exception);
00076     void abs() throw(INTERP_KERNEL::Exception);
00077     void exp() throw(INTERP_KERNEL::Exception);
00078     void ln() throw(INTERP_KERNEL::Exception);
00079     void log10() throw(INTERP_KERNEL::Exception);
00080     //
00081     Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception);
00082     Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception);
00083     Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception);
00084     Value *div(const Value *other) const throw(INTERP_KERNEL::Exception);
00085     Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception);
00086     Value *max(const Value *other) const throw(INTERP_KERNEL::Exception);
00087     Value *min(const Value *other) const throw(INTERP_KERNEL::Exception);
00088     Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception);
00089     Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception);
00090     //
00091     Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception);
00092   private:
00093     ValueDouble(double val);
00094     static const ValueDouble *checkSameType(const Value *val) throw(INTERP_KERNEL::Exception);
00095   private:
00096     double _data;
00097   };
00098 
00099   class INTERPKERNEL_EXPORT ValueUnit : public Value
00100   {
00101   public:
00102     ValueUnit();
00103     Value *newInstance() const;
00104     void setDouble(double val) throw(INTERP_KERNEL::Exception);
00105     void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception);
00106     //
00107     DecompositionInUnitBase getData() const { return _data; }
00108     void positive() throw(INTERP_KERNEL::Exception);
00109     void negate() throw(INTERP_KERNEL::Exception);
00110     void sqrt() throw(INTERP_KERNEL::Exception);
00111     void cos() throw(INTERP_KERNEL::Exception);
00112     void sin() throw(INTERP_KERNEL::Exception);
00113     void tan() throw(INTERP_KERNEL::Exception);
00114     void abs() throw(INTERP_KERNEL::Exception);
00115     void exp() throw(INTERP_KERNEL::Exception);
00116     void ln() throw(INTERP_KERNEL::Exception);
00117     void log10() throw(INTERP_KERNEL::Exception);
00118     //
00119     Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception);
00120     Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception);
00121     Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception);
00122     Value *div(const Value *other) const throw(INTERP_KERNEL::Exception);
00123     Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception);
00124     Value *max(const Value *other) const throw(INTERP_KERNEL::Exception);
00125     Value *min(const Value *other) const throw(INTERP_KERNEL::Exception);
00126     Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception);
00127     Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception);
00128     //
00129     Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception);
00130   private:
00131     ValueUnit(const DecompositionInUnitBase& unit);
00132     static void unsupportedOp(const char *type) throw(INTERP_KERNEL::Exception);
00133     static const ValueUnit *checkSameType(const Value *val) throw(INTERP_KERNEL::Exception);
00134   private:
00135     DecompositionInUnitBase _data;
00136   };
00137 
00138   class INTERPKERNEL_EXPORT ValueDoubleExpr : public Value
00139   {
00140   public:
00141     ValueDoubleExpr(int szDestData, const double *srcData);
00142     ~ValueDoubleExpr();
00143     double *getData() const { return _dest_data; }
00144     Value *newInstance() const;
00145     void setDouble(double val) throw(INTERP_KERNEL::Exception);
00146     void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception);
00147     //
00148     void positive() throw(INTERP_KERNEL::Exception);
00149     void negate() throw(INTERP_KERNEL::Exception);
00150     void sqrt() throw(INTERP_KERNEL::Exception);
00151     void cos() throw(INTERP_KERNEL::Exception);
00152     void sin() throw(INTERP_KERNEL::Exception);
00153     void tan() throw(INTERP_KERNEL::Exception);
00154     void abs() throw(INTERP_KERNEL::Exception);
00155     void exp() throw(INTERP_KERNEL::Exception);
00156     void ln() throw(INTERP_KERNEL::Exception);
00157     void log10() throw(INTERP_KERNEL::Exception);
00158     //
00159     Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception);
00160     Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception);
00161     Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception);
00162     Value *div(const Value *other) const throw(INTERP_KERNEL::Exception);
00163     Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception);
00164     Value *max(const Value *other) const throw(INTERP_KERNEL::Exception);
00165     Value *min(const Value *other) const throw(INTERP_KERNEL::Exception);
00166     Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception);
00167     Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception);
00168     //
00169     Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception);
00170   private:
00171     int _sz_dest_data;
00172     double *_dest_data;
00173     const double *_src_data;
00174   };
00175 }
00176 
00177 #endif