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
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) throw(INTERP_KERNEL::Exception);
38 static Function *buildUnaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
39 //static Function *buildUnaryFuncFromString(char type) throw(INTERP_KERNEL::Exception);
40 static Function *buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
41 static Function *buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception);
42 static Function *buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
45 class INTERPKERNEL_EXPORT Function
49 virtual int getNbInputParams() const = 0;
50 virtual void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception) = 0;
51 virtual void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception) = 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 throw(INTERP_KERNEL::Exception);
67 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
79 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
91 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
103 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
115 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
127 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
128 const char *getRepr() const;
129 bool isACall() const;
131 static const char REPR[];
134 class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
138 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
139 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
140 const char *getRepr() const;
141 bool isACall() const;
143 static const char REPR[];
146 class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction
150 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
151 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
152 const char *getRepr() const;
153 bool isACall() const;
155 static const char REPR[];
158 class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction
162 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
163 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
164 const char *getRepr() const;
165 bool isACall() const;
167 static const char REPR[];
170 class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction
174 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
175 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
176 const char *getRepr() const;
177 bool isACall() const;
179 static const char REPR[];
182 class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction
186 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
187 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
188 const char *getRepr() const;
189 bool isACall() const;
191 static const char REPR[];
194 class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction
198 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
199 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
200 const char *getRepr() const;
201 bool isACall() const;
203 static const char REPR[];
206 class INTERPKERNEL_EXPORT BinaryFunction : public Function
209 int getNbInputParams() const;
212 class PlusFunction : public BinaryFunction
216 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
217 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
218 const char *getRepr() const;
219 bool isACall() const;
221 static const char REPR[];
224 class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction
228 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
229 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
230 const char *getRepr() const;
231 bool isACall() const;
233 static const char REPR[];
236 class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction
240 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
241 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
242 const char *getRepr() const;
243 bool isACall() const;
245 static const char REPR[];
248 class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction
252 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
253 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
254 const char *getRepr() const;
255 bool isACall() const;
257 static const char REPR[];
260 class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction
264 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
265 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
266 const char *getRepr() const;
267 bool isACall() const;
269 static const char REPR[];
272 class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction
276 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
277 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
278 const char *getRepr() const;
279 bool isACall() const;
281 static const char REPR[];
284 class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction
288 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
289 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
290 const char *getRepr() const;
291 bool isACall() const;
293 static const char REPR[];
296 class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction
299 ~GreaterThanFunction();
300 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
301 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
302 const char *getRepr() const;
303 bool isACall() const;
305 static const char REPR[];
308 class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction
311 ~LowerThanFunction();
312 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
313 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
314 const char *getRepr() const;
315 bool isACall() const;
317 static const char REPR[];
320 class INTERPKERNEL_EXPORT TernaryFunction : public Function
323 int getNbInputParams() const;
326 class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction
330 void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
331 void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
332 const char *getRepr() const;
333 bool isACall() const;
335 static const char REPR[];