// Author: Natalia ERMOLAEVA
#include "ModuleBase_FilterFactory.h"
+#include <ModuleBase_Filter.h>
#include <Model_FeatureValidator.h>
#include <ModelAPI_Feature.h>
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");
const SelectMgr_ListOfFilter& ModuleBase_FilterFactory::filters(const std::string& theFeatureID,
const std::string& theAttrID/*,
- std::list<ModuleBase_Filter*>& theFilters/*,
+ std::list<Handle(ModuleBase_Filter)>& theFilters/*,
std::list<std::list<std::string> >& theArguments*/) const
{
SelectMgr_ListOfFilter aFilters;
if (anAttr != aFeature->second.end()) {
AttrValidators::const_iterator aValIter = anAttr->second.cbegin();
for (; aValIter != anAttr->second.cend(); aValIter++) {
- std::map<std::string, ModuleBase_Filter*>::const_iterator aFound = myIDs.find(
+ std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator aFound = myIDs.find(
aValIter->first);
if (aFound == myIDs.end()) {
Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered");
//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<std::string, ModuleBase_Filter*>::const_iterator aIt = myIDs.find(theID);
+/* std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator aIt = myIDs.find(theID);
if (aIt != myIDs.end()) {
return aIt->second;
}*/
return NULL;
}
-void ModuleBase_FilterFactory::addDefaultValidators(std::list<ModuleBase_Filter*>& theValidators) const
+void ModuleBase_FilterFactory::addDefaultValidators(std::list<Handle(ModuleBase_Filter)>& theValidators) const
{
/* const static std::string kDefaultId = "Model_FeatureValidator";
- std::map<std::string, ModuleBase_Filter*>::const_iterator it = myIDs.find(kDefaultId);
+ std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator it = myIDs.find(kDefaultId);
if(it == myIDs.end())
return;
theValidators.push_back(it->second);*/
if (aFeature != myFeatures.end()) {
AttrValidators::const_iterator aValidator = aFeature->second.begin();
for(; aValidator != aFeature->second.end(); aValidator++) {
- std::map<std::string, ModuleBase_Filter*>::const_iterator aValFind =
+ std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator aValFind =
myIDs.find(aValidator->first);
if (aValFind == myIDs.end()) {
Events_Error::send(std::string("Validator ") + aValidator->first + " was not registered");
}
}
// check default validator
- std::map<std::string, ModuleBase_Filter*>::const_iterator aDefaultVal = myIDs.find(kDefaultId);
+ std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator aDefaultVal = myIDs.find(kDefaultId);
if(aDefaultVal != myIDs.end()) {
static const std::list<std::string> anEmptyArgList;
const ModelAPI_FeatureValidator* aFValidator =
if (anAttr != aFeatureIter->second.end()) {
AttrValidators::const_iterator aValIter = anAttr->second.cbegin();
for (; aValIter != anAttr->second.cend(); aValIter++) {
- std::map<std::string, ModuleBase_Filter*>::const_iterator aFound = myIDs.find(
+ std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator aFound = myIDs.find(
aValIter->first);
if (aFound == myIDs.end()) {
Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered");
void ModuleBase_FilterFactory::registerNotObligatory(std::string theFeature, std::string theAttribute)
{
/* const static std::string kDefaultId = "Model_FeatureValidator";
- std::map<std::string, ModuleBase_Filter*>::const_iterator it = myIDs.find(kDefaultId);
+ std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator it = myIDs.find(kDefaultId);
if (it != myIDs.end()) {
Model_FeatureValidator* aValidator = dynamic_cast<Model_FeatureValidator*>(it->second);
if (aValidator) {
bool ModuleBase_FilterFactory::isNotObligatory(std::string theFeature, std::string theAttribute)
{
/* const static std::string kDefaultId = "Model_FeatureValidator";
- std::map<std::string, ModuleBase_Filter*>::const_iterator it = myIDs.find(kDefaultId);
+ std::map<std::string, Handle(ModuleBase_Filter)>::const_iterator it = myIDs.find(kDefaultId);
if (it != myIDs.end()) {
Model_FeatureValidator* aValidator = dynamic_cast<Model_FeatureValidator*>(it->second);
if (aValidator) {
#include "ModuleBase.h"
#include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_Filter.h"
#include <SelectMgr_ListOfFilter.hxx>
#include <map>
#include <set>
-class ModuleBase_Filter;
-
/**
* Allows to get a selection filter by the feature identifier and
* the attribute identifier (if attribute is validated).
private:
- std::map<std::string, ModuleBase_Filter*> myIDs; ///< map from ID to registered validator
+ std::map<std::string, Handle_ModuleBase_Filter> myIDs; ///< map from ID to registered validator
/// validators IDs to list of arguments
typedef std::map<std::string, std::list<std::string> > AttrValidators;
/// validators IDs by feature ID
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,
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<ModelAPI_Feature>& theFeature) const;
virtual bool isConcealed(std::string theFeature, std::string theAttribute);
protected:
- void addDefaultValidators(std::list<ModuleBase_Filter*>& theValidators) const;
+ void addDefaultValidators(std::list<Handle_ModuleBase_Filter>& theValidators) const;
/// Get instance from workshop
ModuleBase_FilterFactory();