Salome HOME
Issue #1369: Added "SubShapes" feature.
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Validators.h
1 /*
2  * Parameters_VariableValidator.h
3  *
4  *  Created on: Apr 9, 2015
5  *      Author: sbh
6  */
7
8 #ifndef PARAMETERSPLUGIN_VARIABLEVALIDATOR_H_
9 #define PARAMETERSPLUGIN_VARIABLEVALIDATOR_H_
10
11 #include <ParametersPlugin.h>
12 #include <ParametersPlugin_Validators.h>
13
14 #include <ModelAPI_AttributeValidator.h>
15
16 #include <memory>
17
18 /**
19  * \class ParametersPlugin_VariableValidator
20  * \ingroup Validators
21  * \brief Validator for the variable name of parameter.
22  */
23 class ParametersPlugin_VariableValidator : public ModelAPI_AttributeValidator
24 {
25  public:
26   PARAMETERSPLUGIN_EXPORT ParametersPlugin_VariableValidator();
27   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_VariableValidator();
28
29   /**
30    * \brief Returns true if attribute has a valid parameter name.
31    * \param theAttribute the checked attribute
32    * \param theArguments arguments of the attribute
33    * \param theError the error string message if validation fails
34    */
35   PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
36                                                const std::list<std::string>& theArguments,
37                                                std::string& theError) const;
38
39  protected:
40   /// Returns true if theString is a valid variable name.
41   PARAMETERSPLUGIN_EXPORT bool isVariable(const std::string& theString) const;
42   /// Returns true if theString is unique parameter name in the document of theAttribute.
43   PARAMETERSPLUGIN_EXPORT bool isUnique(const AttributePtr& theAttribute,
44                                         const std::string& theString) const;
45 };
46
47 /**
48  * \class ParametersPlugin_ExpressionValidator
49  * \ingroup Validators
50  * \brief Validator for the expression of parameter.
51  */
52 class ParametersPlugin_ExpressionValidator: public ModelAPI_AttributeValidator
53 {
54  public:
55   PARAMETERSPLUGIN_EXPORT ParametersPlugin_ExpressionValidator();
56   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_ExpressionValidator();
57
58   /**
59    * \brief Returns true if attribute has a valid parameter expression.
60    * \param theAttribute the checked attribute
61    * \param theArguments arguments of the attribute
62    * \param theError the error string message if validation fails
63    */
64   PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
65                                                const std::list<std::string>& theArguments,
66                                                std::string& theError) const;
67 };
68
69
70 #endif /* PARAMETERSPLUGIN_VARIABLEVALIDATOR_H_ */