X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_FeatureValidator.cpp;h=2bbad12d176b27e3f24b3067235b69657732e48a;hb=3c3d2b36e230e15ee8384554118ea13ca1415772;hp=f311e54db1bab70f748df56728821378217889c7;hpb=8dc74f82810d5f597b78633b457efb0ef4f89f9f;p=modules%2Fshaper.git diff --git a/src/Model/Model_FeatureValidator.cpp b/src/Model/Model_FeatureValidator.cpp index f311e54db..2bbad12d1 100644 --- a/src/Model/Model_FeatureValidator.cpp +++ b/src/Model/Model_FeatureValidator.cpp @@ -9,21 +9,41 @@ #include #include -#include +#include -bool Model_FeatureValidator::isValid(const boost::shared_ptr& theFeature -/*, const std::string theAttr*/ -/*, std::list theArguments*/) const +bool Model_FeatureValidator::isValid(const std::shared_ptr& theFeature, + const std::list& theArguments) const { - boost::shared_ptr aData = theFeature->data(); + std::shared_ptr aData = theFeature->data(); + if (!aData) + return false; if (!aData->isValid()) return false; const std::string kAllTypes = ""; - std::list aLtAttributes = aData->attributes(kAllTypes); - std::list::iterator it = aLtAttributes.begin(); + std::list aLtAttributes = aData->attributesIDs(kAllTypes); + std::list::iterator it = aLtAttributes.begin(); for (; it != aLtAttributes.end(); it++) { - if (!(*it)->isInitialized()) - return false; + AttributePtr anAttr = aData->attribute(*it); + if (!anAttr->isInitialized()) { + std::map >::const_iterator aFeatureFind = + myNotObligatory.find(theFeature->getKind()); + if (aFeatureFind == myNotObligatory.end() || + aFeatureFind->second.find(*it) == aFeatureFind->second.end()) { + return false; + } + } } return true; } + +void Model_FeatureValidator::registerNotObligatory(std::string theFeature, std::string theAttribute) +{ + std::set& anAttrs = myNotObligatory[theFeature]; + anAttrs.insert(theAttribute); +} + +bool Model_FeatureValidator::isNotObligatory(std::string theFeature, std::string theAttribute) +{ + std::set& anAttrs = myNotObligatory[theFeature]; + return anAttrs.find(theAttribute) != anAttrs.end(); +}