Salome HOME
Move GeomValidator_* registration from PartSet_Module to GeomValidator_Plugin
authorspo <sergey.pokhodenko@opencascade.com>
Wed, 28 Oct 2015 11:30:06 +0000 (14:30 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Wed, 28 Oct 2015 11:30:06 +0000 (14:30 +0300)
src/GeomValidators/CMakeLists.txt
src/GeomValidators/GeomValidators_Plugin.cpp [new file with mode: 0644]
src/GeomValidators/GeomValidators_Plugin.h [new file with mode: 0644]
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp

index 2450cf38c23ba42dea837b6a252aedc2ac02f9e6..c9768eb39f606c33e5a82ccacd2673ad947869c6 100644 (file)
@@ -10,6 +10,7 @@ SET(PROJECT_HEADERS
     GeomValidators_Face.h
     GeomValidators_Finite.h
     GeomValidators_PartitionArguments.h
+    GeomValidators_Plugin.h
     GeomValidators_Positive.h
     GeomValidators_ShapeType.h
     GeomValidators_Tools.h
@@ -24,6 +25,7 @@ SET(PROJECT_SOURCES
     GeomValidators_Face.cpp
     GeomValidators_Finite.cpp
     GeomValidators_PartitionArguments.cpp
+    GeomValidators_Plugin.cpp
     GeomValidators_Positive.cpp
     GeomValidators_ShapeType.cpp
     GeomValidators_Tools.cpp
diff --git a/src/GeomValidators/GeomValidators_Plugin.cpp b/src/GeomValidators/GeomValidators_Plugin.cpp
new file mode 100644 (file)
index 0000000..e8f8574
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+#include <GeomValidators_Plugin.h>
+
+#include <GeomValidators_BooleanArguments.h>
+#include <GeomValidators_ConstructionComposite.h>
+#include <GeomValidators_Different.h>
+#include <GeomValidators_DifferentShapes.h>
+#include <GeomValidators_Face.h>
+#include <GeomValidators_Finite.h>
+#include <GeomValidators_PartitionArguments.h>
+#include <GeomValidators_ShapeType.h>
+#include <GeomValidators_ZeroOffset.h>
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+// the only created instance of this plugin
+static GeomValidators_Plugin* MY_GEOMVALIDATORS_INSTANCE = new GeomValidators_Plugin();
+
+GeomValidators_Plugin::GeomValidators_Plugin()
+{
+  // register validators
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
+  aFactory->registerValidator("GeomValidators_BooleanArguments", new GeomValidators_BooleanArguments);
+  aFactory->registerValidator("GeomValidators_ConstructionComposite", new GeomValidators_ConstructionComposite);
+  aFactory->registerValidator("GeomValidators_Different", new GeomValidators_Different);
+  aFactory->registerValidator("GeomValidators_DifferentShapes", new GeomValidators_DifferentShapes);
+  aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face);
+  aFactory->registerValidator("GeomValidators_Finite", new GeomValidators_Finite);
+  aFactory->registerValidator("GeomValidators_PartitionArguments", new GeomValidators_PartitionArguments);
+  aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType);
+  aFactory->registerValidator("GeomValidators_ZeroOffset", new GeomValidators_ZeroOffset);
+
+  // register this plugin
+  ModelAPI_Session::get()->registerPlugin(this);
+}
+
+FeaturePtr GeomValidators_Plugin::createFeature(std::string theFeatureID)
+{
+  // feature of such kind is not found
+  return FeaturePtr();
+}
diff --git a/src/GeomValidators/GeomValidators_Plugin.h b/src/GeomValidators/GeomValidators_Plugin.h
new file mode 100644 (file)
index 0000000..3c428d9
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        GeomValidators_Plugin.h
+// Created:     28 Oct 2015
+// Author:      Sergey POKHODENKO
+
+#ifndef GEOMVALIDATORS_PLUGIN_H_
+#define GEOMVALIDATORS_PLUGIN_H_
+
+#include <GeomValidators.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+/**\class GeomValidators_Plugin
+ * \ingroup Plugins
+ * \brief Interface common for any plugin: allows to use plugin by the plugins manager.
+ */
+class GEOMVALIDATORS_EXPORT GeomValidators_Plugin : public ModelAPI_Plugin
+{
+public:
+  /// Creates the feature object of this plugin by the feature string ID
+  virtual FeaturePtr createFeature(std::string theFeatureID);
+
+public:
+  GeomValidators_Plugin();
+};
+
+#endif
index 388a735fbd97e80240f1ed838c3f5b41c2795922..3aac9e0aff216d1ac44428cd5e3adcb831bac74e 100644 (file)
@@ -115,7 +115,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/GeomValidators
                     ${CMAKE_SOURCE_DIR}/src/AppElements
                     ${CAS_INCLUDE_DIRS}
-                                       ${SUIT_INCLUDE}
+                    ${SUIT_INCLUDE}
 )
 
 ADD_DEFINITIONS(-DPARTSET_EXPORTS ${CAS_DEFINITIONS})
index 67f1bcf7a857a65ddb98e52e1014dca3bf21bc97..a4582e35a2a7136dfa70e9a859011370c1ec0e15 100755 (executable)
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_OperationFeature.h>
 
-#include <GeomValidators_ShapeType.h>
-#include <GeomValidators_Finite.h>
-#include <GeomValidators_Face.h>
-#include <GeomValidators_ConstructionComposite.h>
-#include <GeomValidators_ZeroOffset.h>
-#include <GeomValidators_BooleanArguments.h>
-#include <GeomValidators_Different.h>
-#include <GeomValidators_PartitionArguments.h>
-
-
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Session.h>
-#include <GeomValidators_DifferentShapes.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeString.h>
 
@@ -207,29 +196,7 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("PartSet_AngleSelection", new PartSet_AngleSelection);
   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
   aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
-
-  aFactory->registerValidator("GeomValidators_DifferentShapes", new GeomValidators_DifferentShapes);
-  aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType);
-  aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face);
-  aFactory->registerValidator("GeomValidators_Finite", new GeomValidators_Finite);
-
-  aFactory->registerValidator("GeomValidators_ConstructionComposite",
-                              new GeomValidators_ConstructionComposite);
-
-  aFactory->registerValidator("GeomValidators_ZeroOffset",
-                              new GeomValidators_ZeroOffset);
-
-  aFactory->registerValidator("GeomValidators_BooleanArguments",
-                              new GeomValidators_BooleanArguments);
-
-  aFactory->registerValidator("PartSet_SketchEntityValidator",
-                              new PartSet_SketchEntityValidator);
-
-  aFactory->registerValidator("GeomValidators_Different",
-                              new GeomValidators_Different);
-
-  aFactory->registerValidator("GeomValidators_PartitionArguments",
-                              new GeomValidators_PartitionArguments);
+  aFactory->registerValidator("PartSet_SketchEntityValidator", new PartSet_SketchEntityValidator);
 }
 
 void PartSet_Module::registerFilters()