DRDE/ACTK1_0/se/LPE/LPCrtCmdExtension.cpp

70 lines
2.6 KiB
C++
Raw Normal View History

2014-01-24 22:23:30 +00:00
#include "se/LPE/LPCrtCmdExtension.hpp"
#include "se/Command.hpp"
#include "se/LPE/LPExtension.hpp"
2014-01-28 18:16:48 +00:00
#include "se/LPE/SMDExtension.hpp"
2014-01-24 22:23:30 +00:00
#include "xml/XMLHelper.hpp"
namespace {
2014-01-28 18:16:48 +00:00
2014-01-24 22:23:30 +00:00
LPExtension& lpExtension() {
static LPExtension* lpExtension = new LPExtension();
return *lpExtension;
2014-01-28 18:16:48 +00:00
}
SMDExtension& smdExtension() {
static SMDExtension* smdExtension = new SMDExtension();
return *smdExtension;
}
2014-01-24 22:23:30 +00:00
}; // anonymous namespace
2014-02-04 19:58:44 +00:00
void LPCrtCmdExtension::setSMD(std::string smdIn)
2014-01-28 18:16:48 +00:00
{
haveSMD = true;
2014-02-04 19:58:44 +00:00
smdData = smdIn;
2014-01-28 18:16:48 +00:00
}
2014-01-24 22:23:30 +00:00
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);
2014-01-28 18:16:48 +00:00
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 );
}
2014-01-24 22:23:30 +00:00
}