Salome HOME
Documentation fixes.
[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 new part document if needed
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   PARAMETERSPLUGIN_EXPORT virtual bool isInHistory(); //false
75
76   PARAMETERSPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
77
78   /// Use plugin manager for features creation
79   ParametersPlugin_Parameter();
80
81  protected:
82   /// Evaluates theExpression and returns its value.
83   double evaluate(const std::string& theExpression, std::string& theError);
84   /// Update name of the parameter
85   void updateName();
86   /// Update expression of the parameter
87   void updateExpression();
88
89  private:
90   std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
91 };
92
93 #endif