Salome HOME
Merge Dev_2.1.0 with PythonAPI branch
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Parameter.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        ParametersPlugin_Parameter.h
4 // Created:     23 MArch 2015
5 // Author:      sbh
6
7 #ifndef PARAMETERSPLUGIN_PARAMETER_H_
8 #define PARAMETERSPLUGIN_PARAMETER_H_
9
10 #include "ParametersPlugin.h"
11 #include <ModelAPI_Feature.h>
12
13 #include <memory>
14
15 class ParametersPlugin_PyInterp;
16
17 /**
18  * \class ParametersPlugin_Parameter
19  * \ingroup Plugins
20  * \brief Feature for parameter.
21  */
22 class ParametersPlugin_Parameter : public ModelAPI_Feature
23 {
24  public:
25   virtual ~ParametersPlugin_Parameter();
26
27   /// Feature kind
28   inline static const std::string& ID()
29   {
30     static const std::string MY_PARAMETER_ID("Parameter");
31     return MY_PARAMETER_ID;
32   }
33   /// attribute of parameter name
34   inline static const std::string& VARIABLE_ID()
35   {
36     static const std::string MY_VARIABLE_ID("variable");
37     return MY_VARIABLE_ID;
38   }
39   /// attribute of parameter expression
40   inline static const std::string& EXPRESSION_ID()
41   {
42     static const std::string MY_EXPRESSION_ID("expression");
43     return MY_EXPRESSION_ID;
44   }
45   /// attribute of parameter expression error
46   inline static const std::string& EXPRESSION_ERROR_ID()
47   {
48     static const std::string MY_EXPRESSION_ERROR_ID("ExpressionError");
49     return MY_EXPRESSION_ERROR_ID;
50   }
51   /// list of references to the arguments of this expression
52   inline static const std::string& ARGUMENTS_ID()
53   {
54     static const std::string MY_ARGUMENTS_ID("arguments");
55     return MY_ARGUMENTS_ID;
56   }
57
58   /// Returns the kind of a feature
59   PARAMETERSPLUGIN_EXPORT virtual const std::string& getKind()
60   {
61     static std::string MY_KIND = ParametersPlugin_Parameter::ID();
62     return MY_KIND;
63   }
64
65   /// Pre-execution is not needed for parameter
66   PARAMETERSPLUGIN_EXPORT virtual bool isPreviewNeeded() const;
67
68   /// Creates a parameter in document
69   PARAMETERSPLUGIN_EXPORT virtual void execute();
70
71   /// Request for initialization of data model of the feature: adding all attributes
72   PARAMETERSPLUGIN_EXPORT virtual void initAttributes();
73
74   /// Reimplemented from ModelAPI_Feature::isInHistory(). Returns false.
75   PARAMETERSPLUGIN_EXPORT virtual bool isInHistory();
76
77   /// Reimplemented from ModelAPI_Feature::isInHistory().
78   PARAMETERSPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
79
80   /// Use plugin manager for features creation
81   ParametersPlugin_Parameter();
82
83  protected:
84   /// Evaluates theExpression and returns its value.
85   double evaluate(const std::string& theExpression, std::string& theError);
86   /// Updates name of the parameter
87   void updateName();
88   /// Updates expression of the parameter
89   bool updateExpression();
90
91  private:
92   std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
93 };
94
95 #endif