Salome HOME
Issue #1343 validators update
[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   /// Type of shape
27   enum TypeOfShape
28   {
29     Empty,
30     Vertex,
31     Edge,
32     Line,
33     Circle,
34     Wire,
35     Face,
36     Plane,
37     Solid,
38     Compound,
39     AnyShape
40   };
41
42  public:
43    GEOMVALIDATORS_EXPORT GeomValidators_ShapeType() {}
44   //! Returns true if attribute has shape type listed in the parameter arguments
45   //! \param[in] theAttribute the checked attribute
46   //! \param[in] theArguments arguments of the attribute
47   //! \param[out] theError error message.
48   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
49                                              const std::list<std::string>& theArguments,
50                                              std::string& theError) const;
51 protected:
52   /// Convert string to TypeOfShape value
53   /// \param theType a string value
54   static TypeOfShape shapeType(const std::string& theType);
55
56   /// Returns true if the attibute's object type satisfies the argument value
57   /// \param[in] theAttribute a checked attribute
58   /// \param[in] theShapeType a type of shape
59   /// \param[out] theError error message.
60   bool isValidAttribute(const AttributePtr& theAttribute,
61                         const TypeOfShape theShapeType,
62                         std::string& theError) const;
63
64   /// Returns true if the attibute's object type satisfies the argument value
65   /// \param[in] theObject a checked object
66   /// \param[in] theShapeType a shape type
67   /// \param[out] theError error message.
68   bool isValidObject(const ObjectPtr& theObject,
69                      const TypeOfShape theShapeType,
70                      std::string& theError) const;
71
72   /// Returns true if the attibute's object type satisfies the argument value
73   /// \param[in] theShape a checked shape
74   /// \param[in] theShapeType a shape type
75   /// \param[out] theError error message.
76   bool isValidShape(const GeomShapePtr theShape,
77                     const TypeOfShape theShapeType,
78                     std::string& theError) const;
79
80 };
81
82 #endif