Salome HOME
Merge from V6_main_20120808 08Aug12
[tools/medcoupling.git] / src / INTERP_KERNEL / ExprEval / InterpKernelFunction.hxx
1 // Copyright (C) 2007-2012  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.
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
20 #ifndef __INTERPKERNELFUNCTION_HXX__
21 #define __INTERPKERNELFUNCTION_HXX__
22
23 #include "INTERPKERNELDefines.hxx"
24 #include "InterpKernelException.hxx"
25
26 #include <vector>
27
28 namespace INTERP_KERNEL
29 {
30   class Value;
31   class Function;
32
33   class INTERPKERNEL_EXPORT FunctionsFactory
34   {
35   public:
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);
42   };
43
44   class INTERPKERNEL_EXPORT Function
45   {
46   public:
47     virtual ~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;
53   };
54
55   class INTERPKERNEL_EXPORT UnaryFunction : public Function
56   { 
57   public:
58     int getNbInputParams() const;
59   };
60
61   class INTERPKERNEL_EXPORT IdentityFunction : public UnaryFunction
62   {
63   public:
64     ~IdentityFunction();
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;
68     bool isACall() const;
69   public:
70     static const char REPR[];
71   };
72
73   class INTERPKERNEL_EXPORT PositiveFunction : public UnaryFunction
74   {
75   public:
76     ~PositiveFunction();
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;
80     bool isACall() const;
81   public:
82     static const char REPR[];
83   };
84
85   class INTERPKERNEL_EXPORT NegateFunction : public UnaryFunction
86   {
87   public:
88     ~NegateFunction();
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;
92     bool isACall() const;
93   public:
94     static const char REPR[];
95   };
96
97   class INTERPKERNEL_EXPORT CosFunction : public UnaryFunction
98   {
99   public:
100     ~CosFunction();
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;
105   public:
106     static const char REPR[];
107   };
108
109   class INTERPKERNEL_EXPORT SinFunction : public UnaryFunction
110   {
111   public:
112     ~SinFunction();
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;
117   public:
118     static const char REPR[];
119   };
120
121   class INTERPKERNEL_EXPORT TanFunction : public UnaryFunction
122   {
123   public:
124     ~TanFunction();
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;
129   public:
130     static const char REPR[];
131   };
132
133   class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
134   {
135   public:
136     ~SqrtFunction();
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;
141   public:
142     static const char REPR[];
143   };
144
145   class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction
146   {
147   public:
148     ~AbsFunction();
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;
153   public:
154     static const char REPR[];
155   };
156
157   class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction
158   {
159   public:
160     ~ExpFunction();
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;
165   public:
166     static const char REPR[];
167   };
168
169   class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction
170   {
171   public:
172     ~LnFunction();
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;
177   public:
178     static const char REPR[];
179   };
180
181   class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction
182   {
183   public:
184     ~LogFunction();
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;
189   public:
190     static const char REPR[];
191   };
192
193   class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction
194   {
195   public:
196     ~Log10Function();
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;
201   public:
202     static const char REPR[];
203   };
204
205   class INTERPKERNEL_EXPORT BinaryFunction : public Function
206   {
207   public:
208     int getNbInputParams() const;
209   };
210
211   class PlusFunction : public BinaryFunction
212   {
213   public:
214     ~PlusFunction();
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;
219   public:
220     static const char REPR[];
221   };
222
223   class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction
224   {
225   public:
226     ~MinusFunction();
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;
231   public:
232     static const char REPR[];
233   };
234
235   class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction
236   {
237   public:
238     ~MultFunction();
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;
243   public:
244     static const char REPR[];
245   };
246   
247   class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction
248   {
249   public:
250     ~DivFunction();
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;
255   public:
256     static const char REPR[];
257   };
258
259   class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction
260   {
261   public:
262     ~PowFunction();
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;
267   public:
268     static const char REPR[];
269   };
270
271   class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction
272   {
273   public:
274     ~MaxFunction();
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;
279   public:
280     static const char REPR[];
281   };
282
283   class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction
284   {
285   public:
286     ~MinFunction();
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;
291   public:
292     static const char REPR[];
293   };
294
295   class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction
296   {
297   public:
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;
303   public:
304     static const char REPR[];
305   };
306
307   class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction
308   {
309   public:
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;
315   public:
316     static const char REPR[];
317   };
318
319   class INTERPKERNEL_EXPORT TernaryFunction : public Function
320   {
321   public:
322     int getNbInputParams() const;
323   };
324
325   class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction
326   {
327   public:
328     ~IfFunction();
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;
333   public:
334     static const char REPR[];
335   };
336 }
337
338 #endif