159 {
160
161 bool foundNonResolvedChild = false;
162 bool foundNegativeChild = false;
163 bool foundPositiveChild = false;
164 int decision = -1;
165
166
167 EventSlot* oldSlot = nullptr;
168 if (
m_slot->parentSlot &&
m_slot->entryPoint == node.name() ) {
171 }
172
173
174 auto searchResult =
m_slot->subSlotsByNode.find( node.name() );
175 if ( searchResult !=
m_slot->subSlotsByNode.end() ) {
176 bool breakout = false;
177 for ( unsigned int slotIndex : searchResult->second ) {
178
179
181
182 for ( auto child : node.getDaughters() ) {
183
184 int& childDecision =
m_slot->controlFlowState[child->getNodeIndex()];
185
186 if ( childDecision == -1 )
187 foundNonResolvedChild = true;
188 else if ( childDecision == 1 )
189 foundPositiveChild = true;
190 else
191 foundNegativeChild = true;
192
193 if ( node.m_modePromptDecision ) {
194 if ( node.m_modeOR && foundPositiveChild ) {
195 decision = 1;
196 breakout = true;
197 break;
198 } else if ( !node.m_modeOR && foundNegativeChild ) {
199 decision = 0;
200 breakout = true;
201 break;
202 }
203 } else {
204 if ( foundNonResolvedChild ) {
205 breakout = true;
206 break;
207 }
208 }
209 }
210
211
213 if ( breakout ) break;
214 }
215 } else {
216 for ( auto child : node.getDaughters() ) {
217 int& childDecision =
m_slot->controlFlowState[child->getNodeIndex()];
218
219 if ( childDecision == -1 )
220 foundNonResolvedChild = true;
221 else if ( childDecision == 1 )
222 foundPositiveChild = true;
223 else
224 foundNegativeChild = true;
225
226 if ( node.m_modePromptDecision ) {
227 if ( node.m_modeOR && foundPositiveChild ) {
228 decision = 1;
229 break;
230 } else if ( !node.m_modeOR && foundNegativeChild ) {
231 decision = 0;
232 break;
233 }
234 } else {
235 if ( foundNonResolvedChild ) break;
236 }
237 }
238 }
239
240 if ( !foundNonResolvedChild && decision == -1 ) {
241 if ( node.m_modeOR ) {
242 if ( foundPositiveChild )
243 decision = 1;
244 else
245 decision = 0;
246 } else {
247 if ( foundNegativeChild )
248 decision = 0;
249 else
250 decision = 1;
251 }
252 }
253
254 if ( node.m_inverted && decision == 1 )
255 decision = 0;
256 else if ( node.m_inverted && decision == 0 )
257 decision = 1;
258
259 if ( node.m_allPass && !foundNonResolvedChild ) decision = 1;
260
261 if ( decision != -1 ) {
262 m_slot->controlFlowState[node.getNodeIndex()] = decision;
263
264
265 if ( node.m_parents.size() == 1 ) {
266 node.m_parents[0]->accept( *this );
267 }
else if (
m_slot->parentSlot ) {
268 auto scout = SubSlotScout(
m_slot, node );
269 for ( auto& p : node.m_parents ) {
270 p->accept( scout );
271 if ( scout.reply() ) p->accept( *this );
272 scout.reset();
273 }
274 } else {
275 auto scout = ActiveLineageScout(
m_slot, node );
276 for ( auto& p : node.m_parents ) {
277 p->accept( scout );
278 if ( scout.reply() ) p->accept( *this );
279 scout.reset();
280 }
281 }
282
283 if ( oldSlot )
m_slot = oldSlot;
284 return true;
285 }
286
287
288
289 if ( searchResult !=
m_slot->subSlotsByNode.end() ) {
290 for ( unsigned int slotIndex : searchResult->second ) {
291
292
294
295 for ( auto child : node.getDaughters() ) {
296 bool result = child->accept( *this );
297 if ( !node.m_modeConcurrent )
298 if ( result ) break;
299
300
301 if ( node.m_modePromptDecision &&
m_slot->controlFlowState[node.getNodeIndex()] > -1 )
break;
302 }
303
304
306 }
307 } else {
308 for ( auto child : node.getDaughters() ) {
309 bool result = child->accept( *this );
310 if ( !node.m_modeConcurrent )
311 if ( result ) break;
312
313
314 if ( node.m_modePromptDecision &&
m_slot->controlFlowState[node.getNodeIndex()] > -1 )
break;
315 }
316 }
317
318 if ( oldSlot )
m_slot = oldSlot;
319 return false;
320 }