Salome HOME
Update copyrights
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Parameter.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef PARAMETERSPLUGIN_PARAMETER_H_
21 #define PARAMETERSPLUGIN_PARAMETER_H_
22
23 #include "ParametersPlugin.h"
24 #include <ModelAPI_Feature.h>
25
26 #include <memory>
27
28 /**
29  * \class ParametersPlugin_Parameter
30  * \ingroup Plugins
31  * \brief Feature for parameter.
32  */
33 class ParametersPlugin_Parameter : public ModelAPI_Feature
34 {
35  public:
36   virtual ~ParametersPlugin_Parameter();
37
38   /// Feature kind
39   inline static const std::string& ID()
40   {
41     static const std::string MY_PARAMETER_ID("Parameter");
42     return MY_PARAMETER_ID;
43   }
44   /// attribute of parameter name
45   inline static const std::string& VARIABLE_ID()
46   {
47     static const std::string MY_VARIABLE_ID("variable");
48     return MY_VARIABLE_ID;
49   }
50   /// attribute of parameter expression
51   inline static const std::string& EXPRESSION_ID()
52   {
53     static const std::string MY_EXPRESSION_ID("expression");
54     return MY_EXPRESSION_ID;
55   }
56   /// attribute of parameter expression error
57   inline static const std::string& EXPRESSION_ERROR_ID()
58   {
59     static const std::string MY_EXPRESSION_ERROR_ID("ExpressionError");
60     return MY_EXPRESSION_ERROR_ID;
61   }
62   /// list of references to the arguments of this expression
63   inline static const std::string& ARGUMENTS_ID()
64   {
65     static const std::string MY_ARGUMENTS_ID("arguments");
66     return MY_ARGUMENTS_ID;
67   }
68
69   /// return comment attribute Id
70   inline static const std::string& COMMENT_ID()
71   {
72     static const std::string MY_COMMENT_ID("comment");
73     return MY_COMMENT_ID;
74   }
75
76   /// Returns the kind of a feature
77   PARAMETERSPLUGIN_EXPORT virtual const std::string& getKind()
78   {
79     static std::string MY_KIND = ParametersPlugin_Parameter::ID();
80     return MY_KIND;
81   }
82
83   /// Pre-execution is not needed for parameter
84   PARAMETERSPLUGIN_EXPORT virtual bool isPreviewNeeded() const;
85
86   /// Creates a parameter in document
87   PARAMETERSPLUGIN_EXPORT virtual void execute();
88
89   /// Request for initialization of data model of the feature: adding all attributes
90   PARAMETERSPLUGIN_EXPORT virtual void initAttributes();
91
92   /// Reimplemented from ModelAPI_Feature::isInHistory(). Returns false.
93   PARAMETERSPLUGIN_EXPORT virtual bool isInHistory();
94
95   /// Reimplemented from ModelAPI_Feature::isInHistory().
96   PARAMETERSPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
97
98   /// Use plugin manager for features creation
99   ParametersPlugin_Parameter();
100
101  protected:
102   /// Evaluates theExpression and returns its value.
103   double evaluate(const std::string& theExpression, std::string& theError);
104   /// Updates name of the parameter
105   void updateName();
106   /// Updates expression of the parameter
107   bool updateExpression();
108 };
109
110 #endif