From 3017cb9277284385976ca16992e0004f6459f855 Mon Sep 17 00:00:00 2001 From: Daniil Date: Tue, 19 Nov 2024 20:37:18 +0300 Subject: [PATCH] fix: search by template in generated struct only --- .../searchModule/agents/FindSolvingMethodAgent.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/problem-solver/cxx/searchModule/agents/FindSolvingMethodAgent.cpp b/problem-solver/cxx/searchModule/agents/FindSolvingMethodAgent.cpp index 32316cb7..d932036a 100644 --- a/problem-solver/cxx/searchModule/agents/FindSolvingMethodAgent.cpp +++ b/problem-solver/cxx/searchModule/agents/FindSolvingMethodAgent.cpp @@ -85,9 +85,16 @@ ScResult FindSolvingMethodAgent::DoProgram(ScActionInitiatedEvent const & event, generatedStruct << templateResult[i]; } ScTemplateSearchResult searchResult; - - if (m_context.SearchByTemplate(targetSituationTemplate, searchResult) && - isGeneratedStructureFound(generatedStruct, searchResult)) + bool isGeneratedConstructionFound = false; + m_context.SearchByTemplate( + targetSituationTemplate, + [&isGeneratedConstructionFound](ScTemplateSearchResultItem const & item) -> void { + isGeneratedConstructionFound = true; + }, + [this, generatedStruct](ScAddr const & elementAddr) -> bool { + return m_context.CheckConnector(generatedStruct, elementAddr, ScType::EdgeAccessConstPosPerm); + }); + if (isGeneratedConstructionFound) { suitableMethods.insert(solvingMethod); break;