Salome HOME
Merge branch 'abn/fix_intersec' into V7_main
[tools/medcoupling.git] / src / INTERP_KERNEL / ExprEval / InterpKernelFunction.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __INTERPKERNELFUNCTION_HXX__
22 #define __INTERPKERNELFUNCTION_HXX__
23
24 #include "INTERPKERNELDefines.hxx"
25 #include "InterpKernelException.hxx"
26
27 #include <vector>
28
29 namespace INTERP_KERNEL
30 {
31   class Value;
32   class Function;
33
34   class INTERPKERNEL_EXPORT FunctionsFactory
35   {
36   public:
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);
43   };
44
45   class INTERPKERNEL_EXPORT Function
46   {
47   public:
48     virtual ~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;
54   };
55
56   class INTERPKERNEL_EXPORT UnaryFunction : public Function
57   { 
58   public:
59     int getNbInputParams() const;
60   };
61
62   class INTERPKERNEL_EXPORT IdentityFunction : public UnaryFunction
63   {
64   public:
65     ~IdentityFunction();
66     void operate(std::vector<Value *>& stack) const;
67     void operateX86(std::vector<std::string>& asmb) const;
68     const char *getRepr() const;
69     bool isACall() const;
70   public:
71     static const char REPR[];
72   };
73
74   class INTERPKERNEL_EXPORT PositiveFunction : public UnaryFunction
75   {
76   public:
77     ~PositiveFunction();
78     void operate(std::vector<Value *>& stack) const;
79     void operateX86(std::vector<std::string>& asmb) const;
80     const char *getRepr() const;
81     bool isACall() const;
82   public:
83     static const char REPR[];
84   };
85
86   class INTERPKERNEL_EXPORT NegateFunction : public UnaryFunction
87   {
88   public:
89     ~NegateFunction();
90     void operate(std::vector<Value *>& stack) const;
91     void operateX86(std::vector<std::string>& asmb) const;
92     const char *getRepr() const;
93     bool isACall() const;
94   public:
95     static const char REPR[];
96   };
97
98   class INTERPKERNEL_EXPORT CosFunction : public UnaryFunction
99   {
100   public:
101     ~CosFunction();
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;
106   public:
107     static const char REPR[];
108   };
109
110   class INTERPKERNEL_EXPORT SinFunction : public UnaryFunction
111   {
112   public:
113     ~SinFunction();
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;
118   public:
119     static const char REPR[];
120   };
121
122   class INTERPKERNEL_EXPORT TanFunction : public UnaryFunction
123   {
124   public:
125     ~TanFunction();
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;
130   public:
131     static const char REPR[];
132   };
133
134   class INTERPKERNEL_EXPORT ACosFunction : public UnaryFunction
135   {
136   public:
137     ~ACosFunction();
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;
142   public:
143     static const char REPR[];
144   };
145
146   class INTERPKERNEL_EXPORT ASinFunction : public UnaryFunction
147   {
148   public:
149     ~ASinFunction();
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;
154   public:
155     static const char REPR[];
156   };
157
158   class INTERPKERNEL_EXPORT ATanFunction : public UnaryFunction
159   {
160   public:
161     ~ATanFunction();
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;
166   public:
167     static const char REPR[];
168   };
169
170   class INTERPKERNEL_EXPORT CoshFunction : public UnaryFunction
171   {
172   public:
173     ~CoshFunction();
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;
178   public:
179     static const char REPR[];
180   };
181
182   class INTERPKERNEL_EXPORT SinhFunction : public UnaryFunction
183   {
184   public:
185     ~SinhFunction();
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;
190   public:
191     static const char REPR[];
192   };
193
194   class INTERPKERNEL_EXPORT TanhFunction : public UnaryFunction
195   {
196   public:
197     ~TanhFunction();
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;
202   public:
203     static const char REPR[];
204   };
205
206   class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
207   {
208   public:
209     ~SqrtFunction();
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;
214   public:
215     static const char REPR[];
216   };
217
218   class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction
219   {
220   public:
221     ~AbsFunction();
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;
226   public:
227     static const char REPR[];
228   };
229
230   class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction
231   {
232   public:
233     ~ExpFunction();
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;
238   public:
239     static const char REPR[];
240   };
241
242   class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction
243   {
244   public:
245     ~LnFunction();
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;
250   public:
251     static const char REPR[];
252   };
253
254   class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction
255   {
256   public:
257     ~LogFunction();
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;
262   public:
263     static const char REPR[];
264   };
265
266   class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction
267   {
268   public:
269     ~Log10Function();
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;
274   public:
275     static const char REPR[];
276   };
277
278   class INTERPKERNEL_EXPORT BinaryFunction : public Function
279   {
280   public:
281     int getNbInputParams() const;
282   };
283
284   class PlusFunction : public BinaryFunction
285   {
286   public:
287     ~PlusFunction();
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;
292   public:
293     static const char REPR[];
294   };
295
296   class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction
297   {
298   public:
299     ~MinusFunction();
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;
304   public:
305     static const char REPR[];
306   };
307
308   class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction
309   {
310   public:
311     ~MultFunction();
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;
316   public:
317     static const char REPR[];
318   };
319   
320   class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction
321   {
322   public:
323     ~DivFunction();
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;
328   public:
329     static const char REPR[];
330   };
331
332   class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction
333   {
334   public:
335     ~PowFunction();
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;
340   public:
341     static const char REPR[];
342   };
343
344   class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction
345   {
346   public:
347     ~MaxFunction();
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;
352   public:
353     static const char REPR[];
354   };
355
356   class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction
357   {
358   public:
359     ~MinFunction();
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;
364   public:
365     static const char REPR[];
366   };
367
368   class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction
369   {
370   public:
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;
376   public:
377     static const char REPR[];
378   };
379
380   class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction
381   {
382   public:
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;
388   public:
389     static const char REPR[];
390   };
391
392   class INTERPKERNEL_EXPORT TernaryFunction : public Function
393   {
394   public:
395     int getNbInputParams() const;
396   };
397
398   class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction
399   {
400   public:
401     ~IfFunction();
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;
406   public:
407     static const char REPR[];
408   };
409 }
410
411 #endif