Salome HOME
Issue #532: validator is added to xml; new type "plane" is treated
[modules/shaper.git] / src / GeomValidators / GeomValidators_ShapeType.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomValidators_ShapeType.h
4 // Created:     19 Mar 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef GeomValidators_ShapeType_H
8 #define GeomValidators_ShapeType_H
9
10 #include "GeomValidators.h"
11 #include "ModelAPI_AttributeValidator.h"
12
13 #include <GeomAPI_Shape.h>
14
15 #include <string>
16
17 /**
18 * \ingroup Validators
19 * A validator for shape types, such as vertex, line, circe or arc.
20 * If there are some argument parameters, this validator returns true if the attribute satisfied
21 * at least one argument (OR combination of arguments).
22 */
23 class GeomValidators_ShapeType : public ModelAPI_AttributeValidator
24 {
25  public:
26   //  the edge type
27   enum TypeOfShape
28   {
29     Empty,
30     Vertex,
31     Edge,
32     Line,
33     Circle,
34     Face,
35     Solid,
36     Compound,
37     Plane,
38     AnyShape
39   };
40
41  public:
42    GEOMVALIDATORS_EXPORT GeomValidators_ShapeType() {}
43   //! returns true if attribute is valid
44   //! \param theAttribute the checked attribute
45   //! \param theArguments arguments of the attribute
46   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
47                                              const std::list<std::string>& theArguments,
48                                              std::string& theError) const;
49 protected:
50   /// Convert string to TypeOfShape value
51   /// \param theType a string value
52   static TypeOfShape shapeType(const std::string& theType);
53
54   bool isValidArgument(const AttributePtr& theAttribute,
55                        const std::string& theArgument) const;
56
57   /// Returns true if the attibute's object type satisfies the argument value
58   /// \param theAttribute a checked attribute
59   /// \param theArgument a parameter
60   bool isValidAttribute(const AttributePtr& theAttribute,
61                         const TypeOfShape theShapeType) const;
62
63   /// Returns true if the attibute's object type satisfies the argument value
64   /// \param theAttribute a checked object
65   /// \param theShapeType a shape type
66   bool isValidObject(const ObjectPtr& theObject,
67                      const TypeOfShape theShapeType) const;
68
69   /// Returns true if the attibute's object type satisfies the argument value
70   /// \param theShape a checked shape
71   /// \param theShapeType a shape type
72   bool isValidShape(const GeomShapePtr theShape,
73                     const TypeOfShape theShapeType) const;
74
75 };
76
77 #endif