DRDE/ACTK1_0/se/LPE/LPCrtCmdExtension.cpp

70 lines
2.6 KiB
C++

#include "se/LPE/LPCrtCmdExtension.hpp"
#include "se/Command.hpp"
#include "se/LPE/LPExtension.hpp"
#include "se/LPE/SMDExtension.hpp"
#include "xml/XMLHelper.hpp"
namespace {
LPExtension& lpExtension() {
static LPExtension* lpExtension = new LPExtension();
return *lpExtension;
}
SMDExtension& smdExtension() {
static SMDExtension* smdExtension = new SMDExtension();
return *smdExtension;
}
}; // anonymous namespace
void LPCrtCmdExtension::setSMD(std::string smdIn)
{
haveSMD = true;
smdData = smdIn;
}
void LPCrtCmdExtension::addToCommand(const Command &command) const
{
XMLWriter* xmlWriter = command.getXmlWriter();
DOMElement* extensionElement = command.getExtensionElement();
DOMElement* launchElement = xmlWriter->appendChild(extensionElement,
"create", lpExtension().getURI());
DOMElement* exPhaseElement = xmlWriter->appendChild(launchElement, "launch:phase");
XMLHelper::setTextContent(exPhaseElement, lpePhaseName);
if (haveNoticeID) {
DOMElement* noticeElement = xmlWriter->appendChild(launchElement, "launch:notice");
DOMElement* exPhaseElement1 = xmlWriter->appendChild(noticeElement, "launch:noticeID");
XMLHelper::setTextContent( exPhaseElement1, noticeID );
DOMElement* exPhaseElement2 = xmlWriter->appendChild(noticeElement, "launch:notAfter");
XMLHelper::setTextContent( exPhaseElement2, notAfter );
DOMElement* exPhaseElement3 = xmlWriter->appendChild(noticeElement, "launch:acceptedDate");
XMLHelper::setTextContent( exPhaseElement3, acceptedDate );
}
if (haveSMD) { const string smd_id("1-2");
const string notBefore("2009-08-16T09:00:00.0Z"); const string notAfter("2099-08-16T09:00:00.0Z");
DOMElement* createLPElement = xmlWriter->appendChild(extensionElement, "launch:create");
DOMElement* smdElement = xmlWriter->appendChild(extensionElement,
"signedMark", smdExtension().getURI());
DOMElement* smdElement1 = xmlWriter->appendChild(smdElement, "smd:id");
XMLHelper::setTextContent( smdElement1, smd_id );
DOMElement* smdElement2 = xmlWriter->appendChild(smdElement, "smd:notBefore");
XMLHelper::setTextContent( smdElement2, notBefore );
DOMElement* smdElement3 = xmlWriter->appendChild(smdElement, "smd:notAfter");
XMLHelper::setTextContent( smdElement3, notAfter );
DOMElement* smdElement4 = xmlWriter->appendChild(smdElement, "smd:endcodedSignedMark");
XMLHelper::setTextContent( smdElement4, smdData );
}
}