Salome HOME
Merge from V6_main (04/10/2012)
[modules/med.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 // 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) 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);
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 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;
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 throw(INTERP_KERNEL::Exception);
67     void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
79     void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
91     void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
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 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;
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 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;
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 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;
130   public:
131     static const char REPR[];
132   };
133
134   class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction
135   {
136   public:
137     ~SqrtFunction();
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;
142   public:
143     static const char REPR[];
144   };
145
146   class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction
147   {
148   public:
149     ~AbsFunction();
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;
154   public:
155     static const char REPR[];
156   };
157
158   class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction
159   {
160   public:
161     ~ExpFunction();
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;
166   public:
167     static const char REPR[];
168   };
169
170   class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction
171   {
172   public:
173     ~LnFunction();
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;
178   public:
179     static const char REPR[];
180   };
181
182   class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction
183   {
184   public:
185     ~LogFunction();
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;
190   public:
191     static const char REPR[];
192   };
193
194   class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction
195   {
196   public:
197     ~Log10Function();
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;
202   public:
203     static const char REPR[];
204   };
205
206   class INTERPKERNEL_EXPORT BinaryFunction : public Function
207   {
208   public:
209     int getNbInputParams() const;
210   };
211
212   class PlusFunction : public BinaryFunction
213   {
214   public:
215     ~PlusFunction();
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;
220   public:
221     static const char REPR[];
222   };
223
224   class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction
225   {
226   public:
227     ~MinusFunction();
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;
232   public:
233     static const char REPR[];
234   };
235
236   class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction
237   {
238   public:
239     ~MultFunction();
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;
244   public:
245     static const char REPR[];
246   };
247   
248   class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction
249   {
250   public:
251     ~DivFunction();
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;
256   public:
257     static const char REPR[];
258   };
259
260   class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction
261   {
262   public:
263     ~PowFunction();
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;
268   public:
269     static const char REPR[];
270   };
271
272   class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction
273   {
274   public:
275     ~MaxFunction();
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;
280   public:
281     static const char REPR[];
282   };
283
284   class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction
285   {
286   public:
287     ~MinFunction();
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;
292   public:
293     static const char REPR[];
294   };
295
296   class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction
297   {
298   public:
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;
304   public:
305     static const char REPR[];
306   };
307
308   class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction
309   {
310   public:
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;
316   public:
317     static const char REPR[];
318   };
319
320   class INTERPKERNEL_EXPORT TernaryFunction : public Function
321   {
322   public:
323     int getNbInputParams() const;
324   };
325
326   class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction
327   {
328   public:
329     ~IfFunction();
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;
334   public:
335     static const char REPR[];
336   };
337 }
338
339 #endif