Salome HOME
Issue #1158: To use parameters in integer attributes -- Data Model
[modules/shaper.git] / src / Model / Model_Expression.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_Expression.h
4 // Created:     5 Aug 2015
5 // Author:      Sergey POKHODENKO
6
7 #ifndef Model_Expression_H_
8 #define Model_Expression_H_
9
10 #include "Model.h"
11 #include "ModelAPI_Expression.h"
12
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>
18
19 #include <TDF_Label.hxx>
20
21 /**\class Model_Expression
22  * \ingroup DataModel
23  * \brief Implementation of ModelAPI_Expression.
24  */
25 class Model_Expression : public virtual ModelAPI_Expression
26 {
27  public:
28   /// Sets the text of this Expression
29   MODEL_EXPORT virtual void setText(const std::string& theText);
30
31   /// Returns the text of this Expression
32   MODEL_EXPORT virtual std::string text() const;
33
34   /// Allows to set expression (text) error (by the parameters listener)
35   MODEL_EXPORT virtual void setError(const std::string& theError);
36
37   /// Returns an expression error
38   MODEL_EXPORT virtual std::string error();
39
40   /// Defines the used parameters (by the parameters listener)
41   MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters);
42
43   /// Returns the used parameters
44   MODEL_EXPORT virtual std::set<std::string> usedParameters() const;
45
46  protected:
47   /// Initializes attributes
48   Model_Expression(TDF_Label& theLabel);
49
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
54   friend class Model_Data;
55 };
56
57
58 /**\class Model_ExpressionDouble
59  * \ingroup DataModel
60  * \brief Implementation of ModelAPI_ExpressionDouble.
61  */
62 class Model_ExpressionDouble :
63     public Model_Expression, // implementation inheritance
64     public ModelAPI_ExpressionDouble
65 {
66  public:
67   /// Defines the double value
68   MODEL_EXPORT virtual void setValue(const double theValue);
69
70   /// Returns the double value
71   MODEL_EXPORT virtual double value();
72
73   /// Allows to set expression (text) as invalid (by the parameters listener)
74   MODEL_EXPORT virtual void setInvalid(const bool theFlag);
75
76   /// Returns true if text is invalid
77   MODEL_EXPORT virtual bool isInvalid();
78
79  protected:
80   /// Initializes attributes
81   Model_ExpressionDouble(TDF_Label& theLabel);
82
83   friend class Model_Data;
84
85  private:
86   Handle_TDataStd_Real myReal; ///< double is Real attribute
87 };
88
89
90 /**\class Model_ExpressionInteger
91  * \ingroup DataModel
92  * \brief Implementation of ModelAPI_ExpressionInteger.
93  */
94 class Model_ExpressionInteger :
95     public Model_Expression, // implementation inheritance
96     public ModelAPI_ExpressionInteger
97 {
98  public:
99   /// Defines the integer value
100   MODEL_EXPORT virtual void setValue(const int theValue);
101
102   /// Returns the integer value
103   MODEL_EXPORT virtual int value();
104
105   /// Allows to set expression (text) as invalid (by the parameters listener)
106   MODEL_EXPORT virtual void setInvalid(const bool theFlag);
107
108   /// Returns true if text is invalid
109   MODEL_EXPORT virtual bool isInvalid();
110
111  protected:
112   /// Initializes attributes
113   Model_ExpressionInteger(TDF_Label& theLabel);
114
115   friend class Model_Data;
116
117  private:
118   Handle_TDataStd_Integer myInteger;
119 };
120
121 #endif // Model_Expression_H_