1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_Expression.h
5 // Author: Sergey POKHODENKO
7 #ifndef ModelAPI_Expression_H_
8 #define ModelAPI_Expression_H_
16 /**\class ModelAPI_Expression
18 * \brief Expression for calculated values.
20 class ModelAPI_Expression
23 /// To virtually destroy the fields of successors
24 MODELAPI_EXPORT virtual ~ModelAPI_Expression();
26 /// Returns true if attribute was initialized by some value
27 MODELAPI_EXPORT virtual bool isInitialized();
29 /// Makes attribute initialized
30 MODELAPI_EXPORT virtual void setInitialized();
32 /// Sets the text of this Expression
33 MODELAPI_EXPORT virtual void setText(const std::string& theText) = 0;
35 /// Returns the text of this Expression
36 MODELAPI_EXPORT virtual std::string text() const = 0;
38 /// Allows to set expression (text) as invalid (by the parameters listener)
39 MODELAPI_EXPORT virtual void setInvalid(const bool theFlag) = 0;
41 /// Returns true if text is invalid
42 MODELAPI_EXPORT virtual bool isInvalid() = 0;
44 /// Allows to set expression (text) error (by the parameters listener)
45 MODELAPI_EXPORT virtual void setError(const std::string& theError) = 0;
47 /// Returns an expression error
48 MODELAPI_EXPORT virtual std::string error() = 0;
50 /// Defines the used parameters (by the parameters listener)
51 MODELAPI_EXPORT virtual void setUsedParameters(const std::set<std::string>& theUsedParameters) = 0;
53 /// Returns the used parameters
54 MODELAPI_EXPORT virtual std::set<std::string> usedParameters() const = 0;
57 /// Objects are created for features automatically
58 MODELAPI_EXPORT ModelAPI_Expression();
59 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
60 MODELAPI_EXPORT virtual void reinit() = 0;
62 bool myIsInitialized; ///< is some value assigned to this attribute
64 friend class Model_Data;
65 friend class Model_AttributeDouble;
66 friend class Model_AttributeInteger;
67 friend class GeomData_Point;
68 friend class GeomData_Point2D;
72 /**\class ModelAPI_ExpressionDouble
74 * \brief Expression for calculated double values.
76 class ModelAPI_ExpressionDouble : public virtual ModelAPI_Expression
79 /// Defines the double value
80 MODELAPI_EXPORT virtual void setValue(const double theValue) = 0;
82 /// Returns the double value
83 MODELAPI_EXPORT virtual double value() = 0;
86 /// Objects are created for features automatically
87 MODELAPI_EXPORT ModelAPI_ExpressionDouble();
89 friend class Model_Data;
93 /**\class ModelAPI_ExpressionInteger
95 * \brief Expression for calculated integer values.
97 class ModelAPI_ExpressionInteger : public virtual ModelAPI_Expression
100 /// Defines the integer value
101 MODELAPI_EXPORT virtual void setValue(const int theValue) = 0;
103 /// Returns the integer value
104 MODELAPI_EXPORT virtual int value() = 0;
107 /// Objects are created for features automatically
108 MODELAPI_EXPORT ModelAPI_ExpressionInteger();
110 friend class Model_Data;
114 //! Smart pointers for objects
115 typedef std::shared_ptr<ModelAPI_Expression> ExpressionPtr;
116 typedef std::shared_ptr<ModelAPI_ExpressionDouble> ExpressionDoublePtr;
117 typedef std::shared_ptr<ModelAPI_ExpressionInteger> ExpressionIntegerPtr;