Salome HOME
Introduce ModelAPI_Expression.
[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_Name.hxx>
16 #include <TDataStd_Real.hxx>
17
18 #include <TDF_Label.hxx>
19
20 /**\class Model_Expression
21  * \ingroup DataModel
22  * \brief Implementation of ModelAPI_Expression.
23  */
24 class Model_Expression : public ModelAPI_Expression
25 {
26   Handle_TDataStd_Real myReal; ///< double is Real attribute
27   Handle_TDataStd_Name myText; ///< Text representation of the attribute (may differ for parameters)
28   Handle_TDataStd_Comment myError; ///< Error of expression of the text attribute
29   Handle_TDataStd_ExtStringList myUsedParameters; ///< Parameters used in expression
30  public:
31   /// Defines the double value
32   MODEL_EXPORT virtual void setValue(const double theValue);
33
34   /// Returns the double value
35   MODEL_EXPORT virtual double value();
36
37   /// Sets the text of this Expression
38   MODEL_EXPORT virtual void setText(const std::string& theText);
39
40   /// Returns the text of this Expression
41   MODEL_EXPORT virtual std::string text() const;
42
43   /// Allows to set expression (text) as invalid (by the parameters listener)
44   MODEL_EXPORT virtual void setInvalid(const bool theFlag);
45
46   /// Returns true if text is invalid
47   MODEL_EXPORT virtual bool isInvalid();
48
49   /// Allows to set expression (text) error (by the parameters listener)
50   MODEL_EXPORT virtual void setError(const std::string& theError);
51
52   /// Returns an expression error
53   MODEL_EXPORT virtual std::string error();
54
55   /// Defines the used parameters (by the parameters listener)
56   MODEL_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters);
57
58   /// Returns the used parameters
59   MODEL_EXPORT virtual std::set<std::string> usedParameters() const;
60
61  protected:
62   /// Initializes attributes
63   Model_Expression(TDF_Label& theLabel);
64
65   friend class Model_Data;
66 };
67
68 #endif