+ if (myIsCashed) { // the cashing is active
+ std::map<ResultPtr, std::list<std::shared_ptr<GeomAPI_Shape> > >::iterator aContext =
+ myCash.find(theContext);
+ if (aContext != myCash.end()) {
+ // iterate shapes because "isEqual" method must be called for each shape
+ std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aShapes = aContext->second.begin();
+ for(; aShapes != aContext->second.end(); aShapes++) {
+ if (!theSubShape.get()) {
+ if (!aShapes->get())
+ return true;
+ } else {
+ if (theSubShape->isEqual(*aShapes))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ // no-cash method
+ for(int anIndex = size() - 1; anIndex >= 0; anIndex--) {
+ AttributeSelectionPtr anAttr = value(anIndex);
+ if (anAttr.get()) {
+ if (anAttr->context() == theContext) { // contexts are equal, so, check that values are also
+ std::shared_ptr<GeomAPI_Shape> aValue = anAttr->value();
+ if (!aValue.get()) {
+ if (!theSubShape.get()) { // both are null
+ return true;
+ }
+ } else {
+ if (aValue->isEqual(theSubShape)) // shapes are equal
+ return true;
+ }
+ }
+ }
+ }