std::string& theError) const
{
std::string anAttributeType = theAttribute->attributeType();
- if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aSelectionListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
- // all context objects should not be sketch entities
- for(int anIndex = 0, aSize = aSelectionListAttr->size(); anIndex < aSize; ++anIndex) {
- AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(anIndex);
- ResultPtr aContext = aSelectAttr->context();
- if(!aContext.get()) {
- theError = "Error: Context is empty.";
- return false;
- }
+ if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
+ AttributeSelectionPtr anAttrSelection =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ ResultPtr aContext = anAttrSelection->context();
+ if(!aContext.get()) {
+ theError = "Error: Context is empty.";
+ return false;
+ }
+
+ ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+ if(aResultConstruction.get()) {
+ theError = "Error: Result construction selected.";
+ return false;
+ }
+ } else if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr anAttrSelectionList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
- ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
- if(aResultConstruction.get()) {
- theError = "Error: Result construction selected.";
+ // All objects should not be result constructions.
+ for(int anIndex = 0, aSize = anAttrSelectionList->size(); anIndex < aSize; ++anIndex) {
+ AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
+ if(!isValid(anAttrSelection, theArguments, theError)) {
return false;
}
}
+ } else {
+ theError = "Error: Attribute \"" + anAttributeType + "\" does not supported by this validator.";
+ return false;
}
return true;