std::shared_ptr<XmlNode> DptfStatus::getArbitratorXmlForLoadedParticipants() { auto root = XmlNode::createRoot(); root->addChild(XmlNode::createComment("format_id=" + ArbitratorStatusFormatId.toString())); auto arbitratorRoot = XmlNode::createWrapperElement("arbitrator_status"); auto participantIndexList = m_participantManager->getParticipantIndexes(); auto numberOfUniqueDomains = 0; for (auto participantIndex = participantIndexList.begin(); participantIndex != participantIndexList.end(); ++participantIndex) { try { Participant* participant = m_participantManager->getParticipantPtr(*participantIndex); numberOfUniqueDomains = numberOfUniqueDomains + participant->getDomainCount(); } catch (...) { // Participant not available } } arbitratorRoot->addChild(XmlNode::createDataElement("number_of_domains", StatusFormat::friendlyValue(numberOfUniqueDomains))); auto policyIndexes = m_policyManager->getPolicyIndexes(); for (auto policyIndex = policyIndexes.begin(); policyIndex != policyIndexes.end(); ++policyIndex) { try { Policy* policy = m_policyManager->getPolicyPtr(*policyIndex); std::string name = policy->getName(); auto policyRoot = XmlNode::createWrapperElement("policy"); auto policyName = XmlNode::createDataElement("policy_name", name); policyRoot->addChild(policyName); for (auto participantIndex = participantIndexList.begin(); participantIndex != participantIndexList.end(); ++participantIndex) { try { Participant* participant = m_participantManager->getParticipantPtr(*participantIndex); policyRoot->addChild(participant->getArbitrationXmlForPolicy(*policyIndex)); } catch (...) { // Participant not available } } arbitratorRoot->addChild(policyRoot); } catch (...) { // Policy not available, do not add. } } root->addChild(arbitratorRoot); return root; }
std::string DptfStatus::getXmlForParticipant(UInt32 mappedIndex, eEsifError* returnCode) { auto participantIndexList = m_participantManager->getParticipantIndexes(); UIntN totalDomainCount = 0; // Total # of participants + domains for error checking for (auto i = participantIndexList.begin(); i != participantIndexList.end(); ++i) { try { Participant* participant = m_participantManager->getParticipantPtr(*i); totalDomainCount += participant->getDomainCount(); } catch (...) { // If participant pointer couldn't be returned or couldn't get domain count // Most likely, a participant was removed and left bind a null pointer } } if (mappedIndex >= totalDomainCount) { *returnCode = ESIF_E_UNSPECIFIED; throw dptf_exception("Invalid participant status requested."); } try { auto participantData = m_participantStatusMap->getStatusAsXml(mappedIndex); std::string s = participantData->toString(); return s; } catch (...) { *returnCode = ESIF_E_UNSPECIFIED; throw; } }