1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_Expression.h
5 // Author: Sergey POKHODENKO
7 #ifndef Model_Expression_H_
8 #define Model_Expression_H_
11 #include "ModelAPI_Expression.h"
13 #include <TDataStd_Comment.hxx>
14 #include <TDataStd_ExtStringList.hxx>
15 #include <TDataStd_Integer.hxx>
16 #include <TDataStd_Name.hxx>
17 #include <TDataStd_Real.hxx>
19 #include <TDF_Label.hxx>
21 /**\class Model_Expression
23 * \brief Implementation of ModelAPI_Expression.
25 class Model_Expression : public virtual ModelAPI_Expression
28 /// Sets the text of this Expression
29 MODEL_EXPORT virtual void setText(const std::string& theText);
31 /// Returns the text of this Expression
32 MODEL_EXPORT virtual std::string text() const;
34 /// Allows to set expression (text) error (by the parameters listener)
35 MODEL_EXPORT virtual void setError(const std::string& theError);
37 /// Returns an expression error
38 MODEL_EXPORT virtual std::string error();
40 /// Defines the used parameters (by the parameters listener)
41 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters);
43 /// Returns the used parameters
44 MODEL_EXPORT virtual std::set<std::string> usedParameters() const;
47 /// Initializes attributes
48 Model_Expression(TDF_Label& theLabel);
50 Handle_TDataStd_Name myText; ///< Text representation of the attribute (may differ for parameters)
51 Handle_TDataStd_Comment myError; ///< Error of expression of the text attribute
52 Handle_TDataStd_ExtStringList myUsedParameters; ///< Parameters used in expression
53 TDF_Label myLab; ///< if attribute is not initialized, store label here
57 /**\class Model_ExpressionDouble
59 * \brief Implementation of ModelAPI_ExpressionDouble.
61 class Model_ExpressionDouble :
62 public Model_Expression, // implementation inheritance
63 public ModelAPI_ExpressionDouble
66 /// Sets the text of this Expression
67 MODEL_EXPORT virtual void setText(const std::string& theText) {
68 Model_Expression::setText(theText);
71 /// Returns the text of this Expression
72 MODEL_EXPORT virtual std::string text() const {
73 return Model_Expression::text();
76 /// Allows to set expression (text) error (by the parameters listener)
77 MODEL_EXPORT virtual void setError(const std::string& theError) {
78 Model_Expression::setError(theError);
81 /// Returns an expression error
82 MODEL_EXPORT virtual std::string error() {
83 return Model_Expression::error();
86 /// Defines the used parameters (by the parameters listener)
87 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters) {
88 Model_Expression::setUsedParameters(theUsedParameters);
91 /// Returns the used parameters
92 MODEL_EXPORT virtual std::set<std::string> usedParameters() const {
93 return Model_Expression::usedParameters();
96 /// Defines the double value
97 MODEL_EXPORT virtual void setValue(const double theValue);
99 /// Returns the double value
100 MODEL_EXPORT virtual double value();
102 /// Allows to set expression (text) as invalid (by the parameters listener)
103 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
105 /// Returns true if text is invalid
106 MODEL_EXPORT virtual bool isInvalid();
109 /// Initializes attributes
110 Model_ExpressionDouble(TDF_Label& theLabel);
111 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
112 virtual void reinit();
114 friend class Model_AttributeDouble;
115 friend class Model_Data;
118 Handle_TDataStd_Real myReal; ///< double is Real attribute
122 /**\class Model_ExpressionInteger
124 * \brief Implementation of ModelAPI_ExpressionInteger.
126 class Model_ExpressionInteger :
127 public Model_Expression, // implementation inheritance
128 public ModelAPI_ExpressionInteger
131 /// Sets the text of this Expression
132 MODEL_EXPORT virtual void setText(const std::string& theText) {
133 Model_Expression::setText(theText);
136 /// Returns the text of this Expression
137 MODEL_EXPORT virtual std::string text() const {
138 return Model_Expression::text();
141 /// Allows to set expression (text) error (by the parameters listener)
142 MODEL_EXPORT virtual void setError(const std::string& theError) {
143 Model_Expression::setError(theError);
146 /// Returns an expression error
147 MODEL_EXPORT virtual std::string error() {
148 return Model_Expression::error();
151 /// Defines the used parameters (by the parameters listener)
152 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters) {
153 Model_Expression::setUsedParameters(theUsedParameters);
156 /// Returns the used parameters
157 MODEL_EXPORT virtual std::set<std::string> usedParameters() const {
158 return Model_Expression::usedParameters();
161 /// Defines the integer value
162 MODEL_EXPORT virtual void setValue(const int theValue);
164 /// Returns the integer value
165 MODEL_EXPORT virtual int value();
167 /// Allows to set expression (text) as invalid (by the parameters listener)
168 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
170 /// Returns true if text is invalid
171 MODEL_EXPORT virtual bool isInvalid();
174 /// Initializes attributes
175 Model_ExpressionInteger(TDF_Label& theLabel);
176 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
177 virtual void reinit();
179 friend class Model_AttributeInteger;
182 Handle_TDataStd_Integer myInteger;
185 #endif // Model_Expression_H_