Salome HOME
Error management -- Attribute validator returns an error.
authorspo <sergey.pokhodenko@opencascade.com>
Wed, 29 Jul 2015 10:54:09 +0000 (13:54 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Wed, 5 Aug 2015 14:33:58 +0000 (17:33 +0300)
21 files changed:
src/ExchangePlugin/ExchangePlugin_Validators.cpp
src/ExchangePlugin/ExchangePlugin_Validators.h
src/GeomValidators/GeomValidators_ConstructionComposite.cpp
src/GeomValidators/GeomValidators_ConstructionComposite.h
src/GeomValidators/GeomValidators_Face.cpp
src/GeomValidators/GeomValidators_Face.h
src/GeomValidators/GeomValidators_Positive.cpp
src/GeomValidators/GeomValidators_Positive.h
src/GeomValidators/GeomValidators_ShapeType.cpp
src/GeomValidators/GeomValidators_ShapeType.h
src/ModelAPI/ModelAPI_AttributeValidator.h
src/ModelAPI/ModelAPI_ShapeValidator.cpp
src/ModelAPI/ModelAPI_ShapeValidator.h
src/ParametersPlugin/ParametersPlugin_Validators.cpp
src/ParametersPlugin/ParametersPlugin_Validators.h
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/SketchPlugin/SketchPlugin_ExternalValidator.cpp
src/SketchPlugin/SketchPlugin_ExternalValidator.h
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h

index 052140b8136f963bfb02118b346d0a8a06e4de56..d13b2c478248d939d940492b18b45ae6a1f08dc1 100644 (file)
@@ -38,7 +38,8 @@ bool ExchangePlugin_FormatValidator::parseFormats(const std::list<std::string>&
 }
 
 bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute,
-                                             const std::list<std::string>& theArguments) const
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const
 {
   if (!theAttribute->isInitialized())
     return false;
index 36fa3ea2fbe7e4c5eb1323e8a46519914cfb4fc3..cf7851e7a7690b624b7f2e9da04d95eacfbf521f 100644 (file)
@@ -33,7 +33,8 @@ public:
    * allowed formats.
    */
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 class ExchangePlugin_ImportFormatValidator : public ExchangePlugin_FormatValidator
index 16fd4a2e954f83225f1c62adaf7f91774cc41a8b..afd84190e447e3b8af4f5f340fd9f62dbff200b2 100644 (file)
@@ -7,7 +7,8 @@
 #include "ModelAPI_CompositeFeature.h"
 
 bool GeomValidators_ConstructionComposite::isValid(const AttributePtr& theAttribute,
-                                              const std::list<std::string>& theArguments) const
+                                                   const std::list<std::string>& theArguments,
+                                                   std::string& theError) const
 {
   bool aValid = false;
   AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
index abe123fe59947496062c1eec1063d9cd43b95214..c9f3163214ff7b7deeb45d60184053548ffc52df 100644 (file)
@@ -22,7 +22,8 @@ class GeomValidators_ConstructionComposite : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                             const std::list<std::string>& theArguments) const;
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const;
 };
 
 #endif
index c8797278b42d94c15b4674c65d4233594deac427..90eb2aac390c138374290897de01f6339b949315 100644 (file)
@@ -31,7 +31,8 @@ GeomAbs_SurfaceType GeomValidators_Face::faceType(const std::string& theType)
 }
 
 bool GeomValidators_Face::isValid(const AttributePtr& theAttribute,
-                                  const std::list<std::string>& theArguments) const
+                                  const std::list<std::string>& theArguments,
+                                  std::string& theError) const
 {
   bool aValid = false;
 
index 2ff49551c6b9c1a8e4e1aa319f1dc8e3c99b6d1d..c66d4b315c14e978a81b54803d1b50d509b5455c 100644 (file)
@@ -24,7 +24,8 @@ class GeomValidators_Face : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                             const std::list<std::string>& theArguments) const;
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const;
 protected:
   /// Convert string to TypeOfFace value
   /// \param theType a string value
index 9d3fbf983cbb233da6fbd89d8ee71c3aae325a99..cd7dcc68c85b5e5387de316fe820e9bfcd6077ef 100644 (file)
@@ -21,8 +21,9 @@ GeomValidators_Positive::GeomValidators_Positive()
   aFactory->registerValidator("GeomValidators_Positive", this);
 }
 
-bool GeomValidators_Positive::isValid(
-    const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
+bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, 
+                                      const std::list<std::string>& theArguments,
+                                      std::string& theError) const
 {
   AttributeDoublePtr aDouble = 
     std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
index abfbe948bc519bd8bcbe0cbd390a46d947cf368d..8c88ab08d7ccff62d85556f509308fd0ab5fbc29 100644 (file)
@@ -22,7 +22,8 @@ public:
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                             const std::list<std::string>& theArguments) const;
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const;
 
 };
 
index 85d21a0ad39c70b387080188a530977d89e2ba41..cefd7a592548388b114db60ebe376b574065cf18 100644 (file)
@@ -42,7 +42,8 @@ GeomValidators_ShapeType::TypeOfShape GeomValidators_ShapeType::shapeType(const
 }
 
 bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute,
-                                       const std::list<std::string>& theArguments) const
+                                       const std::list<std::string>& theArguments,
+                                       std::string& theError) const
 {
   bool aValid = false;
 
index 782d9eaeb3b4f61888d85fb37b3ed0b99be39478..daefb1e22b98a4fde54075f1364de9b34c602e8d 100644 (file)
@@ -43,7 +43,8 @@ class GeomValidators_ShapeType : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                             const std::list<std::string>& theArguments) const;
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const;
 protected:
   /// Convert string to TypeOfShape value
   /// \param theType a string value
index 151c793c21ee3445fdaf36b9eaf5873f6f3ebd3e..9ec8cb9349969f3c7b2d2c93b637994378c0e27a 100644 (file)
@@ -21,7 +21,8 @@ public:
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const = 0;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError = std::string()) const = 0;
 
   MODELAPI_EXPORT ~ModelAPI_AttributeValidator();
 };
index fb03f459fbacc878155c6b552d2a9c37d3f0898f..1bd2e50c52995527dd0eebebdd6220970be6e29c 100644 (file)
@@ -10,7 +10,8 @@
 #include "ModelAPI_Object.h"
 
 bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
-                                       const std::list<std::string>& theArguments) const
+                                      const std::list<std::string>& theArguments,
+                                      std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   AttributeSelectionPtr aSelectionAttribute = 
index beac5e2c9d76600741e5a3f1d4d68199f81ffe3d..878ad80e6a2f92727fd4eaf6bcaf56c0f889c77e 100644 (file)
@@ -23,7 +23,8 @@ public:
   /// \param theAttribute an attribute to check
   /// \param theArguments a filter parameters
   MODELAPI_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                       const std::list<std::string>& theArguments) const;
+                                       const std::list<std::string>& theArguments,
+                                       std::string& theError) const;
 };
 
 #endif
index 90ded60313edf285607d299f0d0908c846d4bbd9..8242713d8b579b9592bc8fdf027820988973c684 100644 (file)
@@ -21,7 +21,8 @@ ParametersPlugin_VariableValidator::~ParametersPlugin_VariableValidator()
 }
 
 bool ParametersPlugin_VariableValidator::isValid(const AttributePtr& theAttribute,
-                                                 const std::list<std::string>& theArguments) const
+                                                 const std::list<std::string>& theArguments,
+                                                 std::string& theError) const
 {
   AttributeStringPtr aStrAttr = std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
   bool result = isVariable(aStrAttr->value()) && isUnique(theAttribute, aStrAttr->value());
@@ -75,7 +76,8 @@ ParametersPlugin_ExpressionValidator::~ParametersPlugin_ExpressionValidator()
 }
 
 bool ParametersPlugin_ExpressionValidator::isValid(const AttributePtr& theAttribute,
-                                                  const std::list<std::string>& theArguments) const
+                                                   const std::list<std::string>& theArguments,
+                                                   std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   ResultParameterPtr aParam =
index 8b4626eadb823064aea0eacdf5ced93595ecc753..b81b1c92c1a5b0c00628c692159ca8af4d79843f 100644 (file)
@@ -25,7 +25,8 @@ class ParametersPlugin_VariableValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                               const std::list<std::string>& theArguments) const;
+                                               const std::list<std::string>& theArguments,
+                                               std::string& theError) const;
 
  protected:
   PARAMETERSPLUGIN_EXPORT bool isVariable(const std::string& theString) const;
@@ -43,7 +44,8 @@ class ParametersPlugin_ExpressionValidator: public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                               const std::list<std::string>& theArguments) const;
+                                               const std::list<std::string>& theArguments,
+                                               std::string& theError) const;
 };
 
 
index 29afcf8d0af7e8346b5a40d0f7556e8158351e86..b6be3e0e387eb648391936c3148011b0c1cccbd5 100644 (file)
@@ -184,7 +184,8 @@ bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection
 
 
 bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, 
-                                                const std::list<std::string>& theArguments) const
+                                                const std::list<std::string>& theArguments,
+                                                std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
 
@@ -322,7 +323,8 @@ bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr&
 }
 
 bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
-                                            const std::list<std::string>& theArguments) const
+                                            const std::list<std::string>& theArguments,
+                                            std::string& theError) const
 {
   bool isSketchEntities = true;
   std::set<std::string> anEntityKinds;
@@ -373,8 +375,9 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
 
 
 
-bool PartSet_SameTypeAttrValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool PartSet_SameTypeAttrValidator::isValid(const AttributePtr& theAttribute, 
+                                            const std::list<std::string>& theArguments,
+                                            std::string& theError ) const
 {
   // there is a check whether the feature contains a point and a linear edge or two point values
   std::string aParamA = theArguments.front();
@@ -399,8 +402,9 @@ bool PartSet_SameTypeAttrValidator::isValid(
   return false;
 }
 
-bool PartSet_CoincidentAttr::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute, 
+                                     const std::list<std::string>& theArguments,
+                                     std::string& theError) const
 {
   // there is a check whether the feature contains a point and a linear edge or two point values
   std::string aParamA = theArguments.front();
index 38d693db99af830dd6766f93fdab0b76831654ac..04868061328dd0c76631f18a1c82f33eb1ca53da 100644 (file)
@@ -112,7 +112,8 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute an attribute
   //! \param theArguments a list of arguments (names of attributes to check)
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 
 protected:
   //! Checks whethe other feature attributes has a reference to the given attribute
@@ -132,7 +133,8 @@ class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute an attribute
   //! \param theArguments a list of arguments (names of attributes to check)
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 /**\class PartSet_SameTypeAttrValidator
@@ -148,7 +150,8 @@ class PartSet_SameTypeAttrValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 /**\class PartSet_CoincidentAttr
@@ -163,7 +166,8 @@ class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 
index 7b85871883d0e3a4cf2bcf4dcf3a0c9ea63e5401..3302e4c1e0368fccf34068b6f6fb1c60474dbf0c 100644 (file)
@@ -13,7 +13,8 @@
 #include <ModelAPI_AttributeRefAttr.h>
 
 bool SketchPlugin_ExternalValidator::isValid(const AttributePtr& theAttribute,
-                                          const std::list<std::string>& theArguments) const
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const
 {
   if (theArguments.size() != 1)
     return true;
index 62d95bfe04eefc4e6d7c8099132fab93f05a6f7d..c2773d23a4e9ac4138c3d996649431e2d5ad8deb 100644 (file)
@@ -24,7 +24,8 @@ public:
   /// \param theAttribute an attribute to check
   /// \param theArguments a filter parameters
   SKETCHPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
-                                           const std::list<std::string>& theArguments) const;
+                                           const std::list<std::string>& theArguments,
+                                           std::string& theError) const;
 
 protected:
   /// returns true if the feature of the attribute is external
index 2af4de2e15f64df05b512be9ef9456108e26c99f..b8b2fa53e498be217bd9f10fb550ea393caa5aca 100644 (file)
@@ -28,8 +28,9 @@
 #include <GeomDataAPI_Point2D.h>
 
 
-bool SketchPlugin_DistanceAttrValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribute, 
+                                                 const std::list<std::string>& theArguments,
+                                                 std::string& theError) const
 {
   // there is a check whether the feature contains a point and a linear edge or two point values
   std::string aParamA = theArguments.front();
@@ -78,8 +79,9 @@ bool SketchPlugin_DistanceAttrValidator::isValid(
   return false;
 }
 
-bool SketchPlugin_TangentAttrValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute, 
+                                                const std::list<std::string>& theArguments,
+                                                std::string& theError) const
 {
   // there is a check whether the feature contains a point and a linear edge or two point values
   std::string aParamA = theArguments.front();
@@ -115,8 +117,9 @@ bool SketchPlugin_TangentAttrValidator::isValid(
   return false;
 }
 
-bool SketchPlugin_NotFixedValidator::isValid(
-    const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
+bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute, 
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const
 {
   std::shared_ptr<SketchPlugin_Feature> aFeature =
       std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
@@ -144,8 +147,9 @@ bool SketchPlugin_NotFixedValidator::isValid(
   return true;
 }
 
-bool SketchPlugin_EqualAttrValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool SketchPlugin_EqualAttrValidator::isValid(const AttributePtr& theAttribute, 
+                                              const std::list<std::string>& theArguments,
+                                              std::string& theError) const
 {
   std::string aParamA = theArguments.front();
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
@@ -188,8 +192,9 @@ bool SketchPlugin_EqualAttrValidator::isValid(
   return true;
 }
 
-bool SketchPlugin_MirrorAttrValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute, 
+                                               const std::list<std::string>& theArguments,
+                                               std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   AttributeSelectionListPtr aSelAttr = 
@@ -212,8 +217,9 @@ bool SketchPlugin_MirrorAttrValidator::isValid(
 }
 
 
-bool SketchPlugin_CoincidenceAttrValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool SketchPlugin_CoincidenceAttrValidator::isValid(const AttributePtr& theAttribute, 
+                                                    const std::list<std::string>& theArguments,
+                                                    std::string& theError) const
 {
   // there is a check whether the feature contains a point and a linear edge or two point values
   std::string aParamA = theArguments.front();
@@ -255,8 +261,9 @@ bool SketchPlugin_CoincidenceAttrValidator::isValid(
 }
 
 
-bool SketchPlugin_CopyValidator::isValid(
-  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, 
+                                         const std::list<std::string>& theArguments,
+                                         std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   AttributeSelectionListPtr aSelAttr = 
index 24d79c1b47b36faeb1daa4be22fcb631d1d99d86..f9f45506feacef5e948913c7df791698db821abf 100644 (file)
@@ -23,7 +23,8 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 /**\class SketchPlugin_TangentAttrValidator
@@ -39,7 +40,8 @@ class SketchPlugin_TangentAttrValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 
@@ -56,7 +58,8 @@ class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 /**\class SketchPlugin_EqualAttrValidator
@@ -72,7 +75,8 @@ class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 /**\class SketchPlugin_MirrorAttrValidator
@@ -88,7 +92,8 @@ class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute (not used)
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 
@@ -105,7 +110,8 @@ class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute (not used)
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 
@@ -123,7 +129,8 @@ class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator
   //! \param theAttribute the checked attribute
   //! \param theArguments arguments of the attribute (not used)
   virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments) const;
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
 };
 
 #endif