Salome HOME
Base implementation of Notebook
[modules/kernel.git] / src / Notebook / SALOME_EvalSet.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SALOME_EvalSet.hxx
23 //  Author : Peter KURNEV
24 //  Module : SALOME
25
26
27 #ifndef SALOME_EvalSet_Header_File
28 #define SALOME_EvalSet_Header_File
29
30 #include <list>
31 #include <SALOME_Eval.hxx>
32 #include <SALOME_EvalVariant.hxx>
33
34 #ifdef WNT
35 #pragma warning(disable : 4786)
36 #endif
37
38 class SALOME_EvalSet;
39 typedef std::list<SALOME_EvalSet*> SALOME_ListOfEvalSet;
40
41 //=======================================================================
42 //class : SALOME_EvalSet
43 //purpose  : 
44 //=======================================================================
45 class SALOME_EvalSet
46 {
47 public:
48   SALOME_EvalSet();
49   virtual ~SALOME_EvalSet();
50
51   virtual SALOME_String        name() const = 0;
52   virtual void                 operationList( SALOME_StringList& ) const = 0;
53   virtual void                 bracketsList( SALOME_StringList&, bool open ) const = 0;
54   virtual bool                 createValue( const SALOME_String&, SALOME_EvalVariant& ) const;
55   virtual int                  priority( const SALOME_String&, bool isBin ) const = 0;
56   virtual SALOME_EvalExprError isValid(const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType) const = 0;
57   virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant&) const = 0;
58
59   static bool contains( const SALOME_ListOfEvalSet&, const SALOME_EvalSet* );
60   static void insert( SALOME_ListOfEvalSet& aL, const int aIndex, SALOME_EvalSet* pS );
61 };
62
63 //=======================================================================
64 //class : SALOME_EvalSetBase
65 //purpose  : 
66 //=======================================================================
67 class SALOME_EvalSetBase : public SALOME_EvalSet
68 {
69 public:
70   SALOME_EvalSetBase();
71   virtual ~SALOME_EvalSetBase();
72
73   virtual void                 operationList( SALOME_StringList& ) const;
74   virtual void                 bracketsList ( SALOME_StringList&, bool open ) const;
75
76   virtual SALOME_EvalExprError isValid( const SALOME_String&, const SALOME_EvalVariantType a, const SALOME_EvalVariantType b) const;
77
78 protected: 
79   void addTypes( const SALOME_ListOfEvalVariantType& );
80   void addOperations( const SALOME_StringList& );
81
82 private:
83   SALOME_StringList            myOpers;
84   SALOME_ListOfEvalVariantType myTypes;
85 };
86
87 //=======================================================================
88 //class : SALOME_EvalSetArithmetic
89 //purpose  : 
90 //=======================================================================
91 class SALOME_EvalSetArithmetic : public SALOME_EvalSetBase
92 {
93 public:
94   SALOME_EvalSetArithmetic();
95   virtual ~SALOME_EvalSetArithmetic();
96
97   virtual bool                 createValue( const SALOME_String&, SALOME_EvalVariant& ) const;
98   virtual int                  priority( const SALOME_String&, bool isBin ) const;
99   virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const;
100
101   static  SALOME_String        Name();
102   virtual SALOME_String        name() const;
103 };
104
105 //=======================================================================
106 //class : SALOME_EvalSetLogic
107 //purpose  : 
108 //=======================================================================
109 class SALOME_EvalSetLogic : public SALOME_EvalSetBase
110 {
111 public:
112   SALOME_EvalSetLogic();
113
114   virtual ~SALOME_EvalSetLogic();
115
116   virtual bool                 createValue( const SALOME_String&, SALOME_EvalVariant& ) const;
117   virtual int                  priority( const SALOME_String&, bool isBin ) const;
118   virtual SALOME_EvalExprError calculate( const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const;
119
120   static  SALOME_String        Name();
121   virtual SALOME_String        name() const;
122
123 private:
124   int intValue(const SALOME_EvalVariant& ) const;
125 };
126
127 //=======================================================================
128 //class : SALOME_EvalSetMath
129 //purpose  : 
130 //=======================================================================
131 class SALOME_EvalSetMath : public SALOME_EvalSetBase
132 {
133 public:
134   SALOME_EvalSetMath();
135   virtual ~SALOME_EvalSetMath();
136
137   virtual bool                 createValue( const SALOME_String&, SALOME_EvalVariant& ) const;
138   virtual int                  priority( const SALOME_String&, bool isBin ) const;
139   virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const;
140
141   static  SALOME_String        Name();
142   virtual SALOME_String        name() const;
143 };
144
145 //=======================================================================
146 //class : SALOME_EvalSetString
147 //purpose  : 
148 //=======================================================================
149 class SALOME_EvalSetString : public SALOME_EvalSetBase
150 {
151 public:
152   SALOME_EvalSetString();
153   virtual ~SALOME_EvalSetString();
154
155   virtual bool                 createValue( const SALOME_String&, SALOME_EvalVariant& ) const;
156   virtual int                  priority( const SALOME_String&, bool isBin ) const;
157   virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const;
158
159   static  SALOME_String        Name();
160   virtual SALOME_String        name() const;
161 };
162
163 //=======================================================================
164 //class : SALOME_EvalSetSets
165 //purpose  : 
166 //=======================================================================
167 class SALOME_EvalSetSets : public SALOME_EvalSetBase
168 {
169 public:
170   typedef SALOME_ListOfEvalVariant  ValueSet;
171
172 public:
173   SALOME_EvalSetSets();
174   virtual ~SALOME_EvalSetSets();
175
176   virtual int                  priority( const SALOME_String&, bool isBin ) const;
177   virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const;
178   virtual SALOME_EvalExprError isValid( const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType ) const;
179   virtual void                 bracketsList( SALOME_StringList&, bool open ) const;
180
181   static  SALOME_String        Name();
182   virtual SALOME_String        name() const;
183
184   static void add   ( ValueSet&, const SALOME_EvalVariant& );
185   static void add   ( ValueSet&, const ValueSet& );
186   static void remove( ValueSet&, const SALOME_EvalVariant& );
187   static void remove( ValueSet&, const ValueSet& );
188 };
189
190 //=======================================================================
191 //class : SALOME_EvalSetConst
192 //purpose  : 
193 //=======================================================================
194 class SALOME_EvalSetConst : public SALOME_EvalSet
195 {
196 public:
197   SALOME_EvalSetConst();
198   virtual ~SALOME_EvalSetConst();
199
200   static  SALOME_String        Name();
201   virtual SALOME_String        name() const;
202
203   virtual bool                 createValue( const SALOME_String&, SALOME_EvalVariant& ) const;
204   virtual void                 operationList( SALOME_StringList& ) const;
205   virtual void                 bracketsList( SALOME_StringList&, bool open ) const;
206   virtual int                  priority( const SALOME_String&, bool isBin ) const;
207   virtual SALOME_EvalExprError isValid( const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType ) const;
208   virtual SALOME_EvalExprError calculate( const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const;
209 };
210
211 #endif