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