Skip to content
Snippets Groups Projects
Commit 55c0a6d1 authored by Ruud Overeem's avatar Ruud Overeem
Browse files

Task #7342: Update to new header format.

parent 87264620
No related branches found
No related tags found
No related merge requests found
......@@ -55,11 +55,17 @@ public:
// Human-readable summary describing this request
const std::string &summary,
// Service to send this message to
const std::string &toService,
// Protocol of the contents of the message
const std::string &protocol,
// Version of the protocol we're using to describe the payload
const std::string &toVersion
const std::string &protocolVersion,
// momID of the information (if available)
const std::string &momID,
// sasID of the information (if available)
const std::string &sasID
);
// Parse a message
......@@ -77,16 +83,19 @@ public:
virtual ~Message();
// Return properties of the constructed or received message
std::string system() const { return (getXMLvalue("message.header.system")); }
std::string headerVersion() const { return (getXMLvalue("message.header.version")); }
std::string payload() const { return (getXMLvalue("message.payload")); }
std::string from() const { return (getXMLvalue("message.header.request.source")); }
std::string forUser() const { return (getXMLvalue("message.header.request.user")); }
std::string uuid() const { return (getXMLvalue("message.header.request.uuid")); }
std::string summary() const { return (getXMLvalue("message.header.request.summary")); }
std::string timestamp() const { return (getXMLvalue("message.header.request.timestamp")); }
std::string toService() const { return (getXMLvalue("message.header.service.name")); }
std::string toVersion() const { return (getXMLvalue("message.header.service.version")); }
std::string system() const { return (getXMLvalue("message.header.system")); }
std::string headerVersion() const { return (getXMLvalue("message.header.version")); }
std::string protocol() const { return (getXMLvalue("message.header.protocol.name")); }
std::string protocolVersion() const { return (getXMLvalue("message.header.protocol.version")); }
std::string from() const { return (getXMLvalue("message.header.source.name")); }
std::string forUser() const { return (getXMLvalue("message.header.source.user")); }
std::string uuid() const { return (getXMLvalue("message.header.source.uuid")); }
std::string summary() const { return (getXMLvalue("message.header.source.summary")); }
std::string timestamp() const { return (getXMLvalue("message.header.source.timestamp")); }
std::string momid() const { return (getXMLvalue("message.header.ids.momid")); }
std::string sasis() const { return (getXMLvalue("message.header.ids.sasid")); }
std::string payload() const { return (getXMLvalue("message.payload")); }
std::string header() const { return (getXMLvalue("message.header")); }
// Construct the given fields as a QPID message
qpid::messaging::Message& qpidMsg() { return (itsQpidMsg); }
......@@ -97,10 +106,10 @@ public:
// function for printing
std::ostream& print (std::ostream& os) const;
private:
// Internal very simple XML parser to get a key from the XML content.
// Very simple XML parser to get a key from the XML content.
std::string getXMLvalue(const std::string& key) const;
private:
// -- datamembers --
qpid::messaging::Message itsQpidMsg;
};
......
......@@ -3,17 +3,21 @@
<header>
<system>LOFAR</system>
<version>1.0.0</version>
<service>
<protocol>
<name>%s</name>
<version>%s</version>
</service>
<request>
<source>%s</source>
</protocol>
<source>
<name>%s</name>
<user>%s</user>
<uuid>%s</uuid>
<timestamp>%s</timestamp>
<summary>%s</summary>
</request>
</source>
<ids>
<momid>%s</momid>
<sasid>%s</sasid>
</ids>
</header>
<payload>
%s
......
......@@ -37,17 +37,21 @@ const string LOFAR_MSG_TEMPLATE = "\
<header>\n\
<system>LOFAR</system>\n\
<version>1.0.0</version>\n\
<service>\n\
<protocol>\n\
<name>%s</name>\n\
<version>%s</version>\n\
</service>\n\
<request>\n\
<source>%s</source>\n\
</protocol>\n\
<source>\n\
<name>%s</name>\n\
<user>%s</user>\n\
<uuid>%s</uuid>\n\
<timestamp>%s</timestamp>\n\
<summary>%s</summary>\n\
</request>\n\
</source>\n\
<ids>\n\
<momid>%s</momid>\n\
<sasid>%s</sasid>\n\
</ids>\n\
</header>\n\
<payload>\n\
%s\n\
......@@ -57,11 +61,14 @@ const string LOFAR_MSG_TEMPLATE = "\
Message::Message(const std::string &from,
const std::string &forUser,
const std::string &summary,
const std::string &toService,
const std::string &toVersion)
const std::string &protocol,
const std::string &protocolVersion,
const std::string &momid,
const std::string &sasid)
{
itsQpidMsg.setContent(formatString(LOFAR_MSG_TEMPLATE.c_str(), toService.c_str(), toVersion.c_str(),
from.c_str(), forUser.c_str(), "", "", summary.c_str(), "%s"));
itsQpidMsg.setContent(formatString(LOFAR_MSG_TEMPLATE.c_str(), protocol.c_str(), protocolVersion.c_str(),
from.c_str(), forUser.c_str(), "", "", summary.c_str(),
momid.c_str(), sasid.c_str(), "%s"));
cout << itsQpidMsg.getContent() << endl;
}
......@@ -102,13 +109,15 @@ std::ostream& Message::print (std::ostream& os) const
{
os << "system : " << system() << endl;
os << "systemversion : " << headerVersion() << endl;
os << "serviceName : " << toService() << endl;
os << "serviceVersion : " << toVersion() << endl;
os << "protocolName : " << protocol() << endl;
os << "protocolVersion: " << protocolVersion() << endl;
os << "summary : " << summary() << endl;
os << "timestamp : " << timestamp() << endl;
os << "source : " << from() << endl;
os << "user : " << forUser() << endl;
os << "uuid : " << uuid() << endl;
os << "momid : " << momid() << endl;
os << "sasid : " << sasis() << endl;
os << "payload : " << payload() << endl;
return (os);
}
......
......@@ -70,7 +70,7 @@ int main(int argc, char* argv[]) {
return (1);
}
Message msg1("mySubSystem", "user", "some test message", "lofar.observation.start", "1.0");
Message msg1("mySubSystem", "user", "some test message", "lofar.observation.start", "1.0", "12345", "54321");
qpid::messaging::Message qpMsg("Qpid message");
Message msg2(qpMsg);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment