* @brief This function is called when an event is received * from the Soar kernel. * * @param pIncoming The event command * @param pResponse The reply (no real need to fill anything in here currently) *************************************************************/
| 612 | * @param pResponse The reply (no real need to fill anything in here currently) |
| 613 | *************************************************************/ |
| 614 | void Kernel::ReceivedAgentEvent(smlAgentEventId id, AnalyzeXML* pIncoming, ElementXML* /*pResponse*/) |
| 615 | { |
| 616 | // Get the name of the agent this event refers to. |
| 617 | char const* pAgentName = pIncoming->GetArgString(sml_Names::kParamName) ; |
| 618 | |
| 619 | // Look up the handler(s) from the map |
| 620 | AgentEventMap::ValueList* pHandlers = m_AgentEventMap.getList(id) ; |
| 621 | |
| 622 | if (!pHandlers) |
| 623 | { |
| 624 | return ; |
| 625 | } |
| 626 | |
| 627 | // See if we already have an Agent* for this agent. |
| 628 | // We may not, because "agent created" events are included in the list that come here. |
| 629 | Agent* pAgent = GetAgent(pAgentName) ; |
| 630 | |
| 631 | // Agent name can be null for some agent manager events |
| 632 | if (!pAgent && pAgentName) |
| 633 | { |
| 634 | // Create a new client side agent object |
| 635 | // We have to do this now because we'll be passing it back to the caller in a minute |
| 636 | pAgent = MakeAgent(pAgentName) ; |
| 637 | } |
| 638 | |
| 639 | // Go through the list of event handlers calling each in turn |
| 640 | for (AgentEventMap::ValueListIter iter = pHandlers->begin() ; iter != pHandlers->end() ; iter++) |
| 641 | { |
| 642 | AgentEventHandlerPlusData handlerPlus = *iter ; |
| 643 | AgentEventHandler handler = handlerPlus.m_Handler ; |
| 644 | void* pUserData = handlerPlus.getUserData() ; |
| 645 | |
| 646 | // Call the handler |
| 647 | handler(id, pUserData, pAgent) ; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | /************************************************************* |
| 652 | * @brief This function is called when an event is received |
nothing calls this directly
no test coverage detected