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

Method UpdateAgentList

Core/ClientSML/src/sml_ClientKernel.cpp:883–920  ·  view source on GitHub ↗

* @brief Get the list of agents currently active in the kernel * and create local Agent objects for each one (if we * don't already have that agent registered). *************************************************************/

Source from the content-addressed store, hash-verified

881* don't already have that agent registered).
882*************************************************************/
883void Kernel::UpdateAgentList()
884{
885 AnalyzeXML response ;
886 if (GetConnection()->SendAgentCommand(&response, sml_Names::kCommand_GetAgentList))
887 {
888 ElementXML const* pResult = response.GetResultTag() ;
889 ElementXML child(NULL) ;
890
891 // Keep a record of the agents we find, so we can delete any that have been removed.
892 std::list<Agent*> inUse ;
893
894 for (int i = 0 ; i < pResult->GetNumberChildren() ; i++)
895 {
896 pResult->GetChild(&child, i) ;
897
898 // Look for the <name> tags
899 if (child.IsTag(sml_Names::kTagName))
900 {
901 // Get the agent's name
902 char const* pAgentName = child.GetCharacterData() ;
903
904 // If we don't know about this agent already, then add it to our list.
905 Agent* pAgent = m_AgentMap.find(pAgentName) ;
906
907 if (!pAgent)
908 {
909 pAgent = MakeAgent(pAgentName) ;
910 }
911
912 inUse.push_back(pAgent) ;
913 }
914 }
915
916 // Any agents that are in our map but not in the "inuse" list we should delete
917 // as they no longer exist.
918 m_AgentMap.keep(&inUse) ;
919 }
920}
921
922/*************************************************************
923* @brief Ask the kernel for the current list of connections

Callers 1

Calls 10

SendAgentCommandMethod · 0.80
GetResultTagMethod · 0.80
IsTagMethod · 0.80
GetConnectionFunction · 0.70
GetNumberChildrenMethod · 0.45
GetChildMethod · 0.45
GetCharacterDataMethod · 0.45
findMethod · 0.45
push_backMethod · 0.45
keepMethod · 0.45

Tested by

no test coverage detected