1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __INTERPKERNELFUNCTION_HXX__
21 #define __INTERPKERNELFUNCTION_HXX__
23 #include "INTERPKERNELDefines.hxx"
24 #include "InterpKernelException.hxx"
28 namespace INTERP_KERNEL
33 class INTERPKERNEL_EXPORT FunctionsFactory
36 static Function *buildFuncFromString(const char *type, int nbOfParams) throw(INTERP_KERNEL::Exception);
37 static Function *buildUnaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
38 //static Function *buildUnaryFuncFromString(char type) throw(INTERP_KERNEL::Exception);
39 static Function *buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
40 static Function *buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception);
41 static Function *buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
44 class INTERPKERNEL_EXPORT Function
48 virtual int getNbInputParams() const = 0;
49 virtual void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception) = 0;
50 virtual void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception) = 0;
51 virtual const char *getRepr() const = 0;
52 virtual bool isACall() const = 0;
55 class INTERPKERNEL_EXPORT UnaryFunction : public Function
58 int getNbInputParams() const;
61 class INTERPKERNEL_EXPORT IdentityFunction : public UnaryFunction
65 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
66 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
67 const char *getRepr() const;
70 static const char REPR[];
73 class INTERPKERNEL_EXPORT PositiveFunction : public UnaryFunction
77 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
78 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
79 const char *getRepr() const;
82 static const char REPR[];
85 class INTERPKERNEL_EXPORT NegateFunction : public UnaryFunction
89 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
90 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
91 const char *getRepr() const;
94 static const char REPR[];
97 class INTERPKERNEL_EXPORT CosFunction : public UnaryFunction
101 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
102 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
103 const char *getRepr() const;
104 bool isACall() const;
106 static const char REPR[];
109 class INTERPKERNEL_EXPORT SinFunction : public UnaryFunction
113 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
114 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
115 const char *getRepr() const;
116 bool isACall() const;
118 static const char REPR[];
121 class INTERPKERNEL_EXPORT TanFunction : public UnaryFunction
125 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
126 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
127 const char *getRepr() const;
128 bool isACall() const;
130 static const char REPR[];
133 class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
137 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
138 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
139 const char *getRepr() const;
140 bool isACall() const;
142 static const char REPR[];
145 class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction
149 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
150 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
151 const char *getRepr() const;
152 bool isACall() const;
154 static const char REPR[];
157 class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction
161 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
162 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
163 const char *getRepr() const;
164 bool isACall() const;
166 static const char REPR[];
169 class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction
173 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
174 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
175 const char *getRepr() const;
176 bool isACall() const;
178 static const char REPR[];
181 class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction
185 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
186 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
187 const char *getRepr() const;
188 bool isACall() const;
190 static const char REPR[];
193 class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction
197 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
198 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
199 const char *getRepr() const;
200 bool isACall() const;
202 static const char REPR[];
205 class INTERPKERNEL_EXPORT BinaryFunction : public Function
208 int getNbInputParams() const;
211 class PlusFunction : public BinaryFunction
215 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
216 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
217 const char *getRepr() const;
218 bool isACall() const;
220 static const char REPR[];
223 class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction
227 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
228 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
229 const char *getRepr() const;
230 bool isACall() const;
232 static const char REPR[];
235 class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction
239 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
240 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
241 const char *getRepr() const;
242 bool isACall() const;
244 static const char REPR[];
247 class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction
251 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
252 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
253 const char *getRepr() const;
254 bool isACall() const;
256 static const char REPR[];
259 class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction
263 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
264 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
265 const char *getRepr() const;
266 bool isACall() const;
268 static const char REPR[];
271 class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction
275 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
276 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
277 const char *getRepr() const;
278 bool isACall() const;
280 static const char REPR[];
283 class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction
287 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
288 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
289 const char *getRepr() const;
290 bool isACall() const;
292 static const char REPR[];
295 class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction
298 ~GreaterThanFunction();
299 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
300 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
301 const char *getRepr() const;
302 bool isACall() const;
304 static const char REPR[];
307 class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction
310 ~LowerThanFunction();
311 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
312 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
313 const char *getRepr() const;
314 bool isACall() const;
316 static const char REPR[];
319 class INTERPKERNEL_EXPORT TernaryFunction : public Function
322 int getNbInputParams() const;
325 class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction
329 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
330 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
331 const char *getRepr() const;
332 bool isACall() const;
334 static const char REPR[];