From: nds Date: Thu, 11 Dec 2014 10:08:13 +0000 (+0300) Subject: It is a filters implementation to be set in the XML file. X-Git-Tag: before_slalome_7.5.1~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=278328bad4390893a24864ee89a13a7c2e34bafc;p=modules%2Fshaper.git It is a filters implementation to be set in the XML file. It uses the handle for an OCC object instance. --- diff --git a/src/ModuleBase/ModuleBase_FilterFactory.cpp b/src/ModuleBase/ModuleBase_FilterFactory.cpp index 9ab3762cc..56b0b8ca3 100644 --- a/src/ModuleBase/ModuleBase_FilterFactory.cpp +++ b/src/ModuleBase/ModuleBase_FilterFactory.cpp @@ -3,6 +3,7 @@ // Author: Natalia ERMOLAEVA #include "ModuleBase_FilterFactory.h" +#include #include #include @@ -13,7 +14,7 @@ void ModuleBase_FilterFactory::registerFilter(const std::string& theID, - ModuleBase_Filter* theValidator) + Handle(ModuleBase_Filter) theFilter) { /*if (myIDs.find(theID) != myIDs.end()) { Events_Error::send(std::string("Validator ") + theID + " is already registered"); @@ -45,7 +46,7 @@ void ModuleBase_FilterFactory::assignFilter(const std::string& theID, const SelectMgr_ListOfFilter& ModuleBase_FilterFactory::filters(const std::string& theFeatureID, const std::string& theAttrID/*, - std::list& theFilters/*, + std::list& theFilters/*, std::list >& theArguments*/) const { SelectMgr_ListOfFilter aFilters; @@ -57,7 +58,7 @@ const SelectMgr_ListOfFilter& ModuleBase_FilterFactory::filters(const std::strin if (anAttr != aFeature->second.end()) { AttrValidators::const_iterator aValIter = anAttr->second.cbegin(); for (; aValIter != anAttr->second.cend(); aValIter++) { - std::map::const_iterator aFound = myIDs.find( + std::map::const_iterator aFound = myIDs.find( aValIter->first); if (aFound == myIDs.end()) { Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered"); @@ -76,19 +77,19 @@ ModuleBase_FilterFactory::ModuleBase_FilterFactory() //registerValidator(kDefaultId, new Model_FeatureValidator); } -const ModuleBase_Filter* ModuleBase_FilterFactory::validator(const std::string& theID) const +const Handle(ModuleBase_Filter) ModuleBase_FilterFactory::validator(const std::string& theID) const { -/* std::map::const_iterator aIt = myIDs.find(theID); +/* std::map::const_iterator aIt = myIDs.find(theID); if (aIt != myIDs.end()) { return aIt->second; }*/ return NULL; } -void ModuleBase_FilterFactory::addDefaultValidators(std::list& theValidators) const +void ModuleBase_FilterFactory::addDefaultValidators(std::list& theValidators) const { /* const static std::string kDefaultId = "Model_FeatureValidator"; - std::map::const_iterator it = myIDs.find(kDefaultId); + std::map::const_iterator it = myIDs.find(kDefaultId); if(it == myIDs.end()) return; theValidators.push_back(it->second);*/ @@ -103,7 +104,7 @@ bool ModuleBase_FilterFactory::validate(const std::shared_ptr& if (aFeature != myFeatures.end()) { AttrValidators::const_iterator aValidator = aFeature->second.begin(); for(; aValidator != aFeature->second.end(); aValidator++) { - std::map::const_iterator aValFind = + std::map::const_iterator aValFind = myIDs.find(aValidator->first); if (aValFind == myIDs.end()) { Events_Error::send(std::string("Validator ") + aValidator->first + " was not registered"); @@ -118,7 +119,7 @@ bool ModuleBase_FilterFactory::validate(const std::shared_ptr& } } // check default validator - std::map::const_iterator aDefaultVal = myIDs.find(kDefaultId); + std::map::const_iterator aDefaultVal = myIDs.find(kDefaultId); if(aDefaultVal != myIDs.end()) { static const std::list anEmptyArgList; const ModelAPI_FeatureValidator* aFValidator = @@ -146,7 +147,7 @@ bool ModuleBase_FilterFactory::validate(const std::shared_ptr& if (anAttr != aFeatureIter->second.end()) { AttrValidators::const_iterator aValIter = anAttr->second.cbegin(); for (; aValIter != anAttr->second.cend(); aValIter++) { - std::map::const_iterator aFound = myIDs.find( + std::map::const_iterator aFound = myIDs.find( aValIter->first); if (aFound == myIDs.end()) { Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered"); @@ -171,7 +172,7 @@ bool ModuleBase_FilterFactory::validate(const std::shared_ptr& void ModuleBase_FilterFactory::registerNotObligatory(std::string theFeature, std::string theAttribute) { /* const static std::string kDefaultId = "Model_FeatureValidator"; - std::map::const_iterator it = myIDs.find(kDefaultId); + std::map::const_iterator it = myIDs.find(kDefaultId); if (it != myIDs.end()) { Model_FeatureValidator* aValidator = dynamic_cast(it->second); if (aValidator) { @@ -183,7 +184,7 @@ void ModuleBase_FilterFactory::registerNotObligatory(std::string theFeature, std bool ModuleBase_FilterFactory::isNotObligatory(std::string theFeature, std::string theAttribute) { /* const static std::string kDefaultId = "Model_FeatureValidator"; - std::map::const_iterator it = myIDs.find(kDefaultId); + std::map::const_iterator it = myIDs.find(kDefaultId); if (it != myIDs.end()) { Model_FeatureValidator* aValidator = dynamic_cast(it->second); if (aValidator) { diff --git a/src/ModuleBase/ModuleBase_FilterFactory.h b/src/ModuleBase/ModuleBase_FilterFactory.h index d8b305a57..1e5cdeb55 100644 --- a/src/ModuleBase/ModuleBase_FilterFactory.h +++ b/src/ModuleBase/ModuleBase_FilterFactory.h @@ -7,14 +7,13 @@ #include "ModuleBase.h" #include "ModuleBase_IWorkshop.h" +#include "ModuleBase_Filter.h" #include #include #include -class ModuleBase_Filter; - /** * Allows to get a selection filter by the feature identifier and * the attribute identifier (if attribute is validated). @@ -33,7 +32,7 @@ class ModuleBase_FilterFactory : public QObject private: - std::map myIDs; ///< map from ID to registered validator + std::map myIDs; ///< map from ID to registered validator /// validators IDs to list of arguments typedef std::map > AttrValidators; /// validators IDs by feature ID @@ -47,7 +46,7 @@ class ModuleBase_FilterFactory : public QObject public: /// Registers the instance of the validator by the ID MODULEBASE_EXPORT virtual void registerFilter(const std::string& theID, - ModuleBase_Filter* theValidator); + Handle_ModuleBase_Filter theValidator); /// Assigns validator to the attribute of the feature MODULEBASE_EXPORT virtual void assignFilter(const std::string& theID, @@ -59,7 +58,7 @@ class ModuleBase_FilterFactory : public QObject const std::string& theAttrID) const; /// Returns registered validator by its Id - MODULEBASE_EXPORT virtual const ModuleBase_Filter* validator(const std::string& theID) const; + MODULEBASE_EXPORT virtual const Handle_ModuleBase_Filter validator(const std::string& theID) const; /// Returns true if feature and all its attributes are valid. MODULEBASE_EXPORT virtual bool validate(const std::shared_ptr& theFeature) const; @@ -79,7 +78,7 @@ class ModuleBase_FilterFactory : public QObject virtual bool isConcealed(std::string theFeature, std::string theAttribute); protected: - void addDefaultValidators(std::list& theValidators) const; + void addDefaultValidators(std::list& theValidators) const; /// Get instance from workshop ModuleBase_FilterFactory();