X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Validator.cpp;h=9875f74274a9af41843c9140761b3273f224734d;hb=0b503091623876eda1ae9214e32f8831ef03778b;hp=dee9841c3c2c4de887ca1a7fa5536f417a1dba15;hpb=3874b57fe5aba25ff5aee2a07654fc23c1ee8eb0;p=modules%2Fshaper.git diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index dee9841c3..9875f7427 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include void Model_ValidatorsFactory::registerValidator(const std::string& theID, @@ -90,7 +91,7 @@ void Model_ValidatorsFactory::validators(const std::string& theFeatureID, } } } - addDefaultValidators(theResult); + addDefaultValidators(theResult, theArguments); } void Model_ValidatorsFactory::validators(const std::string& theFeatureID, @@ -134,13 +135,15 @@ const ModelAPI_Validator* Model_ValidatorsFactory::validator(const std::string& return NULL; } -void Model_ValidatorsFactory::addDefaultValidators(std::list& theValidators) const +void Model_ValidatorsFactory::addDefaultValidators(std::list& theValidators, + std::list >& theArguments) const { const static std::string kDefaultId = "Model_FeatureValidator"; std::map::const_iterator it = myIDs.find(kDefaultId); if(it == myIDs.end()) return; theValidators.push_back(it->second); + theArguments.push_back(std::list()); } bool Model_ValidatorsFactory::validate(const std::shared_ptr& theFeature) const @@ -258,3 +261,34 @@ bool Model_ValidatorsFactory::isConcealed(std::string theFeature, std::string th std::map >::iterator aFind = myConcealed.find(theFeature); return aFind != myConcealed.end() && aFind->second.find(theAttribute) != aFind->second.end(); } + +void Model_ValidatorsFactory::registerCase(std::string theFeature, std::string theAttribute, + std::string theSwitchId, std::string theCaseId) +{ + std::map > >::iterator + aFindFeature = myCases.find(theFeature); + if (aFindFeature == myCases.end()) { + myCases[theFeature] = std::map >(); + aFindFeature = myCases.find(theFeature); + } + (aFindFeature->second)[theAttribute] = std::pair(theSwitchId, theCaseId); +} + +bool Model_ValidatorsFactory::isCase( + FeaturePtr theFeature, std::string theAttribute) +{ + std::map > >::iterator + aFindFeature = myCases.find(theFeature->getKind()); + if (aFindFeature != myCases.end()) { + std::map >::iterator + aFindAttr = aFindFeature->second.find(theAttribute); + if (aFindAttr != aFindFeature->second.end()) { + // the the switch-attribute that contains the case value + AttributeStringPtr aSwitch = theFeature->string(aFindAttr->second.first); + if (aSwitch.get()) { + return aSwitch->value() == aFindAttr->second.second; // the second is the case identifier + } + } + } + return true; // if no additional conditions, this attribute is the case to be validated +}