MCPcopy Create free account
hub / github.com/SoarGroup/Soar / ReceivedOutput

Method ReceivedOutput

Core/ClientSML/src/sml_ClientWorkingMemory.cpp:485–605  ·  view source on GitHub ↗

* @brief This function is called when output is received * from the Soar kernel. * * @param pIncoming The output command (list of wmes added/removed from output link) * @param pResponse The reply (no real need to fill anything in here currently) *************************************************************/

Source from the content-addressed store, hash-verified

483* @param pResponse The reply (no real need to fill anything in here currently)
484*************************************************************/
485bool WorkingMemory::ReceivedOutput(AnalyzeXML* pIncoming, ElementXML* /*pResponse*/)
486{
487#ifdef _DEBUG
488 char* pMsgText = pIncoming->GetCommandTag()->GenerateXMLString(true, true) ;
489#endif
490
491 // Get the command tag which contains the list of wmes
492 ElementXML const* pCommand = pIncoming->GetCommandTag() ;
493
494 int nChildren = pCommand->GetNumberChildren() ;
495
496 ElementXML wmeXML(NULL) ;
497 ElementXML* pWmeXML = &wmeXML ;
498
499 bool ok = true ;
500
501 // Make sure the output orphans list is empty
502 // We'll use this to store output wmes that have no parent identifier yet
503 // (this is rare but can happen if the kernel generates wmes in an unusual order)
504 m_OutputOrphans.clear() ;
505
506 bool tracing = this->GetAgent()->GetKernel()->IsTracingCommunications() ;
507
508 for (int i = 0 ; i < nChildren ; i++)
509 {
510 pCommand->GetChild(&wmeXML, i) ;
511
512 // Ignore tags that aren't wmes.
513 if (!pWmeXML->IsTag(sml_Names::kTagWME))
514 {
515 continue ;
516 }
517
518 // Find out if this is an add or a remove
519 char const* pAction = pWmeXML->GetAttribute(sml_Names::kWME_Action) ;
520
521 if (!pAction)
522 {
523 continue ;
524 }
525
526 bool add = IsStringEqual(pAction, sml_Names::kValueAdd) ;
527 bool remove = IsStringEqual(pAction, sml_Names::kValueRemove) ;
528
529 if (add)
530 {
531 ok = ReceivedOutputAddition(pWmeXML, tracing) && ok ;
532 }
533 else if (remove)
534 {
535 ok = ReceivedOutputRemoval(pWmeXML, tracing) && ok ;
536 }
537 }
538
539 // Check that we managed to reconnect all of the orphaned wmes
540 if (!m_OutputOrphans.empty())
541 {
542 ok = false ;

Callers

nothing calls this directly

Calls 15

GetCommandTagMethod · 0.80
IsTagMethod · 0.80
SetDetailedErrorMethod · 0.80
GetParentMethod · 0.80
ReceivedOutputEventMethod · 0.80
GetAgentFunction · 0.70
IsStringEqualFunction · 0.50
DeleteStringFunction · 0.50
GenerateXMLStringMethod · 0.45

Tested by

no test coverage detected