Salome HOME
updated copyright message
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_Validators.h
1 // Copyright (C) 2014-2023  CEA, EDF
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_VARIABLEVALIDATOR_H_
21 #define PARAMETERSPLUGIN_VARIABLEVALIDATOR_H_
22
23 #include <ParametersPlugin.h>
24 #include <ParametersPlugin_Validators.h>
25
26 #include <ModelAPI_AttributeValidator.h>
27
28 #include <memory>
29
30 /**
31  * \class ParametersPlugin_VariableValidator
32  * \ingroup Validators
33  * \brief Validator for the variable name of parameter.
34  */
35 class ParametersPlugin_VariableValidator : public ModelAPI_AttributeValidator
36 {
37  public:
38   PARAMETERSPLUGIN_EXPORT ParametersPlugin_VariableValidator();
39   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_VariableValidator();
40
41   /**
42    * \brief Returns true if attribute has a valid parameter name.
43    * \param theAttribute the checked attribute
44    * \param theArguments arguments of the attribute
45    * \param theError the error string message if validation fails
46    */
47   PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
48                                                const std::list<std::string>& theArguments,
49                                                Events_InfoMessage& theError) const;
50
51  protected:
52   /// Returns true if theString is unique parameter name in the document of theAttribute.
53   PARAMETERSPLUGIN_EXPORT bool isUnique(const AttributePtr& theAttribute,
54                                         const std::string& theString) const;
55 };
56
57 /**
58  * \class ParametersPlugin_ExpressionValidator
59  * \ingroup Validators
60  * \brief Validator for the expression of parameter.
61  */
62 class ParametersPlugin_ExpressionValidator: public ModelAPI_AttributeValidator
63 {
64  public:
65   PARAMETERSPLUGIN_EXPORT ParametersPlugin_ExpressionValidator();
66   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_ExpressionValidator();
67
68   /**
69    * \brief Returns true if attribute has a valid parameter expression.
70    * \param theAttribute the checked attribute
71    * \param theArguments arguments of the attribute
72    * \param theError the error string message if validation fails
73    */
74   PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
75                                                const std::list<std::string>& theArguments,
76                                                Events_InfoMessage& theError) const;
77 };
78
79
80 #endif /* PARAMETERSPLUGIN_VARIABLEVALIDATOR_H_ */