1 // Copyright (C) 2007-2013 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
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __INTERPKERNELFUNCTION_HXX__
22 #define __INTERPKERNELFUNCTION_HXX__
24 #include "INTERPKERNELDefines.hxx"
25 #include "InterpKernelException.hxx"
29 namespace INTERP_KERNEL
34 class INTERPKERNEL_EXPORT FunctionsFactory
37 static Function *buildFuncFromString(const char *type, int nbOfParams);
38 static Function *buildUnaryFuncFromString(const char *type);
39 //static Function *buildUnaryFuncFromString(char type);
40 static Function *buildBinaryFuncFromString(const char *type);
41 static Function *buildBinaryFuncFromString(char type);
42 static Function *buildTernaryFuncFromString(const char *type);
45 class INTERPKERNEL_EXPORT Function
49 virtual int getNbInputParams() const = 0;
50 virtual void operate(std::vector<Value *>& stack) const = 0;
51 virtual void operateX86(std::vector<std::string>& asmb) const = 0;
52 virtual const char *getRepr() const = 0;
53 virtual bool isACall() const = 0;
56 class INTERPKERNEL_EXPORT UnaryFunction : public Function
59 int getNbInputParams() const;
62 class INTERPKERNEL_EXPORT IdentityFunction : public UnaryFunction
66 void operate(std::vector<Value *>& stack) const;
67 void operateX86(std::vector<std::string>& asmb) const;
68 const char *getRepr() const;
71 static const char REPR[];
74 class INTERPKERNEL_EXPORT PositiveFunction : public UnaryFunction
78 void operate(std::vector<Value *>& stack) const;
79 void operateX86(std::vector<std::string>& asmb) const;
80 const char *getRepr() const;
83 static const char REPR[];
86 class INTERPKERNEL_EXPORT NegateFunction : public UnaryFunction
90 void operate(std::vector<Value *>& stack) const;
91 void operateX86(std::vector<std::string>& asmb) const;
92 const char *getRepr() const;
95 static const char REPR[];
98 class INTERPKERNEL_EXPORT CosFunction : public UnaryFunction
102 void operate(std::vector<Value *>& stack) const;
103 void operateX86(std::vector<std::string>& asmb) const;
104 const char *getRepr() const;
105 bool isACall() const;
107 static const char REPR[];
110 class INTERPKERNEL_EXPORT SinFunction : public UnaryFunction
114 void operate(std::vector<Value *>& stack) const;
115 void operateX86(std::vector<std::string>& asmb) const;
116 const char *getRepr() const;
117 bool isACall() const;
119 static const char REPR[];
122 class INTERPKERNEL_EXPORT TanFunction : public UnaryFunction
126 void operate(std::vector<Value *>& stack) const;
127 void operateX86(std::vector<std::string>& asmb) const;
128 const char *getRepr() const;
129 bool isACall() const;
131 static const char REPR[];
134 class INTERPKERNEL_EXPORT ACosFunction : public UnaryFunction
138 void operate(std::vector<Value *>& stack) const;
139 void operateX86(std::vector<std::string>& asmb) const;
140 const char *getRepr() const;
141 bool isACall() const;
143 static const char REPR[];
146 class INTERPKERNEL_EXPORT ASinFunction : public UnaryFunction
150 void operate(std::vector<Value *>& stack) const;
151 void operateX86(std::vector<std::string>& asmb) const;
152 const char *getRepr() const;
153 bool isACall() const;
155 static const char REPR[];
158 class INTERPKERNEL_EXPORT ATanFunction : public UnaryFunction
162 void operate(std::vector<Value *>& stack) const;
163 void operateX86(std::vector<std::string>& asmb) const;
164 const char *getRepr() const;
165 bool isACall() const;
167 static const char REPR[];
170 class INTERPKERNEL_EXPORT CoshFunction : public UnaryFunction
174 void operate(std::vector<Value *>& stack) const;
175 void operateX86(std::vector<std::string>& asmb) const;
176 const char *getRepr() const;
177 bool isACall() const;
179 static const char REPR[];
182 class INTERPKERNEL_EXPORT SinhFunction : public UnaryFunction
186 void operate(std::vector<Value *>& stack) const;
187 void operateX86(std::vector<std::string>& asmb) const;
188 const char *getRepr() const;
189 bool isACall() const;
191 static const char REPR[];
194 class INTERPKERNEL_EXPORT TanhFunction : public UnaryFunction
198 void operate(std::vector<Value *>& stack) const;
199 void operateX86(std::vector<std::string>& asmb) const;
200 const char *getRepr() const;
201 bool isACall() const;
203 static const char REPR[];
206 class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
210 void operate(std::vector<Value *>& stack) const;
211 void operateX86(std::vector<std::string>& asmb) const;
212 const char *getRepr() const;
213 bool isACall() const;
215 static const char REPR[];
218 class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction
222 void operate(std::vector<Value *>& stack) const;
223 void operateX86(std::vector<std::string>& asmb) const;
224 const char *getRepr() const;
225 bool isACall() const;
227 static const char REPR[];
230 class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction
234 void operate(std::vector<Value *>& stack) const;
235 void operateX86(std::vector<std::string>& asmb) const;
236 const char *getRepr() const;
237 bool isACall() const;
239 static const char REPR[];
242 class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction
246 void operate(std::vector<Value *>& stack) const;
247 void operateX86(std::vector<std::string>& asmb) const;
248 const char *getRepr() const;
249 bool isACall() const;
251 static const char REPR[];
254 class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction
258 void operate(std::vector<Value *>& stack) const;
259 void operateX86(std::vector<std::string>& asmb) const;
260 const char *getRepr() const;
261 bool isACall() const;
263 static const char REPR[];
266 class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction
270 void operate(std::vector<Value *>& stack) const;
271 void operateX86(std::vector<std::string>& asmb) const;
272 const char *getRepr() const;
273 bool isACall() const;
275 static const char REPR[];
278 class INTERPKERNEL_EXPORT BinaryFunction : public Function
281 int getNbInputParams() const;
284 class PlusFunction : public BinaryFunction
288 void operate(std::vector<Value *>& stack) const;
289 void operateX86(std::vector<std::string>& asmb) const;
290 const char *getRepr() const;
291 bool isACall() const;
293 static const char REPR[];
296 class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction
300 void operate(std::vector<Value *>& stack) const;
301 void operateX86(std::vector<std::string>& asmb) const;
302 const char *getRepr() const;
303 bool isACall() const;
305 static const char REPR[];
308 class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction
312 void operate(std::vector<Value *>& stack) const;
313 void operateX86(std::vector<std::string>& asmb) const;
314 const char *getRepr() const;
315 bool isACall() const;
317 static const char REPR[];
320 class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction
324 void operate(std::vector<Value *>& stack) const;
325 void operateX86(std::vector<std::string>& asmb) const;
326 const char *getRepr() const;
327 bool isACall() const;
329 static const char REPR[];
332 class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction
336 void operate(std::vector<Value *>& stack) const;
337 void operateX86(std::vector<std::string>& asmb) const;
338 const char *getRepr() const;
339 bool isACall() const;
341 static const char REPR[];
344 class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction
348 void operate(std::vector<Value *>& stack) const;
349 void operateX86(std::vector<std::string>& asmb) const;
350 const char *getRepr() const;
351 bool isACall() const;
353 static const char REPR[];
356 class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction
360 void operate(std::vector<Value *>& stack) const;
361 void operateX86(std::vector<std::string>& asmb) const;
362 const char *getRepr() const;
363 bool isACall() const;
365 static const char REPR[];
368 class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction
371 ~GreaterThanFunction();
372 void operate(std::vector<Value *>& stack) const;
373 void operateX86(std::vector<std::string>& asmb) const;
374 const char *getRepr() const;
375 bool isACall() const;
377 static const char REPR[];
380 class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction
383 ~LowerThanFunction();
384 void operate(std::vector<Value *>& stack) const;
385 void operateX86(std::vector<std::string>& asmb) const;
386 const char *getRepr() const;
387 bool isACall() const;
389 static const char REPR[];
392 class INTERPKERNEL_EXPORT TernaryFunction : public Function
395 int getNbInputParams() const;
398 class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction
402 void operate(std::vector<Value *>& stack) const;
403 void operateX86(std::vector<std::string>& asmb) const;
404 const char *getRepr() const;
405 bool isACall() const;
407 static const char REPR[];