void SaveXmlComponentVisitor::Visit(Connection &connection)
{
	(*file) << " " << XmlTag::startTagConnector << "\n"
		 << "    " << XmlTag::startTagId << connection.GetId() << XmlTag::endTagId << "\n"
		 << "    " << XmlTag::startTagText << connection.GetName() << XmlTag::endTagText << "\n"
		 << "    " << XmlTag::startTagSource << connection.GetConnectComponents().at(0)->GetId() << XmlTag::endTagSource << "\n"
		 << "    " << XmlTag::startTagTarget << connection.GetConnectComponents().at(1)->GetId() << XmlTag::endTagTarget << "\n"
		 << " " << XmlTag::endTagConnector << "\n";
}
Exemplo n.º 2
0
bool KernelSML::HandleGetConnections(AgentSML* /*pAgentSML*/, char const* /*pCommandName*/, Connection* /*pCallingConnection*/, AnalyzeXML* /*pIncoming*/, soarxml::ElementXML* pResponse)
{
	// Create the result tag
	TagResult* pTagResult = new TagResult() ;
	pTagResult->AddAttribute(sml_Names::kCommandOutput, sml_Names::kStructuredOutput) ;

	// Walk the list of connections and return their info
	int index = 0 ;
	Connection* pConnection = m_pConnectionManager->GetConnectionByIndex(index) ;

	while (pConnection)
	{
		// Create the connection tag
		soarxml::ElementXML* pTagConnection = new soarxml::ElementXML() ;
		pTagConnection->SetTagName(sml_Names::kTagConnection) ;

		// Fill in the info
		pTagConnection->AddAttribute(sml_Names::kConnectionId, pConnection->GetID()) ;
		pTagConnection->AddAttribute(sml_Names::kConnectionName, pConnection->GetName()) ;
		pTagConnection->AddAttribute(sml_Names::kConnectionStatus, pConnection->GetStatus()) ;
		pTagConnection->AddAttribute(sml_Names::kAgentStatus, pConnection->GetAgentStatus()) ;

		// Add the connection into the result
		pTagResult->AddChild(pTagConnection) ;

		// Get the next connection.  Returns null when go beyond limit.
		// (This provides thread safe access to the list, in case it changes during this enumeration)
		index++ ;
		pConnection = m_pConnectionManager->GetConnectionByIndex(index) ;
	}

	// Add the result tag to the response
	pResponse->AddChild(pTagResult) ;

	// Return true to indicate we've filled in all of the result tag we need
	return true ;

}