1 #include "otsdaq/SOAPUtilities/SOAPCommand.h"
2 #include "otsdaq/Macros/CoutMacros.h"
3 #include "otsdaq/MessageFacility/MessageFacility.h"
5 #include <xoap/SOAPElement.h>
6 #include <xoap/SOAPEnvelope.h>
7 #include <xoap/domutils.h>
14 SOAPCommand::SOAPCommand(
void) {}
17 SOAPCommand::SOAPCommand(
const xoap::MessageReference& message) { translate(message); }
20 SOAPCommand::SOAPCommand(std::string command) : command_(command) {}
22 SOAPCommand::SOAPCommand(std::string command,
SOAPParameters parameters) : command_(command), parameters_(parameters) {}
25 SOAPCommand::SOAPCommand(std::string command,
SOAPParameter parameter) : command_(command), parameters_(parameter) {}
28 SOAPCommand::~SOAPCommand(
void) {}
38 const std::string& SOAPCommand::getCommand(
void)
const {
return command_; }
41 const SOAPParameters& SOAPCommand::getParameters(
void)
const {
return parameters_; }
43 SOAPParameters& SOAPCommand::getParametersRef() {
return parameters_; }
46 std::string SOAPCommand::getParameterValue(std::string parameterName)
const
48 SOAPParameters::const_iterator it;
49 if((it = parameters_.find(parameterName)) != parameters_.end())
55 unsigned int SOAPCommand::getParametersSize(
void)
const {
return parameters_.size(); }
58 void SOAPCommand::translate(
const xoap::MessageReference& message)
62 xoap::SOAPElement messageCommand = *(message->getSOAPPart().getEnvelope().getBody().getChildElements().begin());
63 command_ = messageCommand.getElementName().getLocalName();
64 DOMNamedNodeMap* parameters = messageCommand.getDOM()->getAttributes();
65 for(
unsigned int i = 0; i < parameters->getLength(); i++)
67 parameters_.addParameter(xoap::XMLCh2String(parameters->item(i)->getNodeName()), xoap::XMLCh2String(parameters->item(i)->getNodeValue()));
72 void SOAPCommand::setCommand(std::string command) { command_ = command; }
75 void SOAPCommand::setParameters(
const SOAPParameters& parameters) { parameters_ = parameters; }
78 void SOAPCommand::setParameter(std::string parameterName, std::string parameterValue) { parameters_.addParameter(parameterName, parameterValue); }
81 void SOAPCommand::setParameter(
const SOAPParameter parameter) { parameters_.addParameter(parameter.getName(), parameter.getValue()); }
84 bool SOAPCommand::hasParameters(
void)
const {
return (parameters_.size() != 0); }
87 bool SOAPCommand::findParameter(std::string parameterName)
const {
return (parameters_.find(parameterName) != parameters_.end()); }
92 std::ostream& operator<<(std::ostream& os,
const SOAPCommand& c)
94 os <<
"Command: " << c.getCommand();
96 for(SOAPParameters::const_iterator it = (c.getParameters()).begin(); it != (c.getParameters()).end(); it++)
97 os <<
" Par " << p <<
" Name: " << it->first <<
" Value: " << it->second <<
",";