From 38d9cbfadd670a68e3b9522eeadb224897f1e19c Mon Sep 17 00:00:00 2001 From: spo Date: Wed, 28 Oct 2015 14:30:06 +0300 Subject: [PATCH] Move GeomValidator_* registration from PartSet_Module to GeomValidator_Plugin --- src/GeomValidators/CMakeLists.txt | 2 + src/GeomValidators/GeomValidators_Plugin.cpp | 45 ++++++++++++++++++++ src/GeomValidators/GeomValidators_Plugin.h | 28 ++++++++++++ src/PartSet/CMakeLists.txt | 2 +- src/PartSet/PartSet_Module.cpp | 35 +-------------- 5 files changed, 77 insertions(+), 35 deletions(-) create mode 100644 src/GeomValidators/GeomValidators_Plugin.cpp create mode 100644 src/GeomValidators/GeomValidators_Plugin.h diff --git a/src/GeomValidators/CMakeLists.txt b/src/GeomValidators/CMakeLists.txt index 2450cf38c..c9768eb39 100644 --- a/src/GeomValidators/CMakeLists.txt +++ b/src/GeomValidators/CMakeLists.txt @@ -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 index 000000000..e8f8574a1 --- /dev/null +++ b/src/GeomValidators/GeomValidators_Plugin.cpp @@ -0,0 +1,45 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +// 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 index 000000000..3c428d96f --- /dev/null +++ b/src/GeomValidators/GeomValidators_Plugin.h @@ -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 +#include +#include + +/**\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 diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 45ab6dc01..39ff91869 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -107,7 +107,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}) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 4dba40553..8c0fa0e5a 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -36,22 +36,11 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include - - #include #include #include #include #include -#include #include #include @@ -206,29 +195,7 @@ void PartSet_Module::registerValidators() aFactory->registerValidator("PartSet_EqualSelection", new PartSet_EqualSelection); 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() -- 2.39.2