1 // Copyright (C) 2014-2017 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, or (at your option) any later version.
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef Model_Expression_H_
22 #define Model_Expression_H_
25 #include "ModelAPI_Expression.h"
27 #include <TDataStd_Comment.hxx>
28 #include <TDataStd_ExtStringList.hxx>
29 #include <TDataStd_Integer.hxx>
30 #include <TDataStd_Name.hxx>
31 #include <TDataStd_Real.hxx>
33 #include <TDF_Label.hxx>
35 /**\class Model_Expression
37 * \brief Implementation of ModelAPI_Expression.
39 class Model_Expression : public virtual ModelAPI_Expression
42 /// Sets the text of this Expression
43 MODEL_EXPORT virtual void setText(const std::string& theText);
45 /// Returns the text of this Expression
46 MODEL_EXPORT virtual std::string text() const;
48 /// Allows to set expression (text) error (by the parameters listener)
49 MODEL_EXPORT virtual void setError(const std::string& theError);
51 /// Returns an expression error
52 MODEL_EXPORT virtual std::string error();
54 /// Defines the used parameters (by the parameters listener)
55 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters);
57 /// Returns the used parameters
58 MODEL_EXPORT virtual std::set<std::string> usedParameters() const;
61 /// Initializes attributes
62 Model_Expression(TDF_Label& theLabel);
64 Handle_TDataStd_Name myText; ///< Text representation of the attribute (may differ for parameters)
65 Handle_TDataStd_Comment myError; ///< Error of expression of the text attribute
66 Handle_TDataStd_ExtStringList myUsedParameters; ///< Parameters used in expression
67 TDF_Label myLab; ///< if attribute is not initialized, store label here
71 /**\class Model_ExpressionDouble
73 * \brief Implementation of ModelAPI_ExpressionDouble.
75 class Model_ExpressionDouble :
76 public Model_Expression, // implementation inheritance
77 public ModelAPI_ExpressionDouble
80 /// Sets the text of this Expression
81 MODEL_EXPORT virtual void setText(const std::string& theText) {
82 Model_Expression::setText(theText);
85 /// Returns the text of this Expression
86 MODEL_EXPORT virtual std::string text() const {
87 return Model_Expression::text();
90 /// Allows to set expression (text) error (by the parameters listener)
91 MODEL_EXPORT virtual void setError(const std::string& theError) {
92 Model_Expression::setError(theError);
95 /// Returns an expression error
96 MODEL_EXPORT virtual std::string error() {
97 return Model_Expression::error();
100 /// Defines the used parameters (by the parameters listener)
101 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters) {
102 Model_Expression::setUsedParameters(theUsedParameters);
105 /// Returns the used parameters
106 MODEL_EXPORT virtual std::set<std::string> usedParameters() const {
107 return Model_Expression::usedParameters();
110 /// Defines the double value
111 MODEL_EXPORT virtual void setValue(const double theValue);
113 /// Returns the double value
114 MODEL_EXPORT virtual double value();
116 /// Allows to set expression (text) as invalid (by the parameters listener)
117 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
119 /// Returns true if text is invalid
120 MODEL_EXPORT virtual bool isInvalid();
123 /// Initializes attributes
124 Model_ExpressionDouble(TDF_Label& theLabel);
125 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
126 virtual void reinit();
128 friend class Model_AttributeDouble;
129 friend class Model_Data;
132 Handle_TDataStd_Real myReal; ///< double is Real attribute
136 /**\class Model_ExpressionInteger
138 * \brief Implementation of ModelAPI_ExpressionInteger.
140 class Model_ExpressionInteger :
141 public Model_Expression, // implementation inheritance
142 public ModelAPI_ExpressionInteger
145 /// Sets the text of this Expression
146 MODEL_EXPORT virtual void setText(const std::string& theText) {
147 Model_Expression::setText(theText);
150 /// Returns the text of this Expression
151 MODEL_EXPORT virtual std::string text() const {
152 return Model_Expression::text();
155 /// Allows to set expression (text) error (by the parameters listener)
156 MODEL_EXPORT virtual void setError(const std::string& theError) {
157 Model_Expression::setError(theError);
160 /// Returns an expression error
161 MODEL_EXPORT virtual std::string error() {
162 return Model_Expression::error();
165 /// Defines the used parameters (by the parameters listener)
166 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters) {
167 Model_Expression::setUsedParameters(theUsedParameters);
170 /// Returns the used parameters
171 MODEL_EXPORT virtual std::set<std::string> usedParameters() const {
172 return Model_Expression::usedParameters();
175 /// Defines the integer value
176 MODEL_EXPORT virtual void setValue(const int theValue);
178 /// Returns the integer value
179 MODEL_EXPORT virtual int value();
181 /// Allows to set expression (text) as invalid (by the parameters listener)
182 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
184 /// Returns true if text is invalid
185 MODEL_EXPORT virtual bool isInvalid();
188 /// Initializes attributes
189 Model_ExpressionInteger(TDF_Label& theLabel);
190 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
191 virtual void reinit();
193 friend class Model_AttributeInteger;
196 Handle_TDataStd_Integer myInteger;
199 #endif // Model_Expression_H_