* @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). *************************************************************/
| 881 | * don't already have that agent registered). |
| 882 | *************************************************************/ |
| 883 | void 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 |
no test coverage detected