Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
5890ae56
Commit
5890ae56
authored
10 years ago
by
Ruud Overeem
Browse files
Options
Downloads
Patches
Plain Diff
Task #7367: Minimal implementation of lofar message class including unit test.
parent
247d65d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
LCS/MessageBus/include/MessageBus/Message.h
+13
-8
13 additions, 8 deletions
LCS/MessageBus/include/MessageBus/Message.h
LCS/MessageBus/src/Message.cc
+30
-41
30 additions, 41 deletions
LCS/MessageBus/src/Message.cc
LCS/MessageBus/test/tMessage.cc
+11
-0
11 additions, 0 deletions
LCS/MessageBus/test/tMessage.cc
with
54 additions
and
49 deletions
LCS/MessageBus/include/MessageBus/Message.h
+
13
−
8
View file @
5890ae56
...
...
@@ -74,14 +74,16 @@ public:
virtual
~
Message
();
// Return properties of the constructed or received message
std
::
string
system
()
const
;
std
::
string
headerVersion
()
const
;
std
::
string
payload
()
const
;
std
::
string
from
()
const
;
std
::
string
forUser
()
const
;
std
::
string
summary
()
const
;
std
::
string
toService
()
const
;
std
::
string
toVersion
()
const
;
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"
));
}
// Construct the given fields as a QPID message
qpid
::
messaging
::
Message
getQpidMsg
()
const
{
return
(
itsQpidMsg
);
}
...
...
@@ -90,6 +92,9 @@ public:
std
::
string
getRawContent
()
const
{
return
(
itsQpidMsg
.
getContent
());
}
private
:
// Internal very simple XML parser to get a key from the XML content.
string
getXMLvalue
(
const
string
&
key
)
const
;
// datamembers
qpid
::
messaging
::
Message
itsQpidMsg
;
};
...
...
This diff is collapsed.
Click to expand it.
LCS/MessageBus/src/Message.cc
+
30
−
41
View file @
5890ae56
...
...
@@ -26,9 +26,11 @@
//# Includes
#include
<Common/LofarLogger.h>
#include
<Common/lofar_string.h>
#include
<Common/StringUtil.h>
#include
<MessageBus/Message.h>
namespace
LOFAR
{
using
namespace
StringUtil
;
const
string
LOFAR_MSG_TEMPLATE
=
"\
<message>
\n
\
...
...
@@ -64,10 +66,9 @@ Message::Message(const std::string &from,
cout
<<
itsQpidMsg
.
getContent
()
<<
endl
;
}
Message
::
Message
(
const
qpid
::
messaging
::
Message
&
qpidMsg
)
Message
::
Message
(
const
qpid
::
messaging
::
Message
&
qpidMsg
)
:
itsQpidMsg
(
qpidMsg
)
{
itsQpidMsg
.
setContent
(
formatString
(
LOFAR_MSG_TEMPLATE
.
c_str
(),
""
,
""
,
""
,
""
,
""
,
""
,
""
,
qpidMsg
.
getContent
().
c_str
()));
cout
<<
itsQpidMsg
.
getContent
()
<<
endl
;
}
...
...
@@ -103,45 +104,33 @@ void Message::setListPayload(const qpid::types::Variant::List &payload)
}
// Return properties of the constructed or received message
std
::
string
Message
::
system
()
const
string
Message
::
getXMLvalue
(
const
string
&
key
)
const
{
return
"???"
;
}
std
::
string
Message
::
headerVersion
()
const
{
return
"???"
;
}
std
::
string
Message
::
payload
()
const
{
return
"???"
;
}
std
::
string
Message
::
from
()
const
{
return
"???"
;
}
std
::
string
Message
::
forUser
()
const
{
return
"???"
;
}
std
::
string
Message
::
summary
()
const
{
return
"???"
;
}
std
::
string
Message
::
toService
()
const
{
return
"???"
;
}
std
::
string
Message
::
toVersion
()
const
{
return
"???"
;
// get copy of content
vector
<
string
>
labels
=
split
(
key
,
'.'
);
string
content
(
itsQpidMsg
.
getContent
());
// loop over subkeys
string
::
size_type
offset
=
0
;
string
::
size_type
begin
;
string
::
size_type
end
;
for
(
size_t
i
=
0
;
i
<
labels
.
size
();
++
i
)
{
// define tags to find
string
startTag
(
"<"
+
labels
[
i
]
+
">"
);
string
stopTag
(
"</"
+
labels
[
i
]
+
">"
);
// search begin tag
begin
=
content
.
find
(
startTag
,
offset
);
if
(
begin
==
string
::
npos
)
{
return
(
"???"
);
}
// search end tag
begin
+=
startTag
.
size
();
end
=
content
.
find
(
stopTag
,
begin
);
if
(
end
==
string
::
npos
)
{
return
(
"???"
);
}
}
return
(
content
.
substr
(
begin
,
end
-
begin
));
}
...
...
This diff is collapsed.
Click to expand it.
LCS/MessageBus/test/tMessage.cc
+
11
−
0
View file @
5890ae56
...
...
@@ -78,6 +78,17 @@ int main(int argc, char* argv[]) {
string
KVmapje
(
"abc=[aap,noot,mies]
\n
myInteger=5
\n
myDouble=3.14"
);
msg1
.
setTXTPayload
(
KVmapje
);
cout
<<
"system : "
<<
msg1
.
system
()
<<
endl
;
cout
<<
"systemversion : "
<<
msg1
.
headerVersion
()
<<
endl
;
cout
<<
"serviceName : "
<<
msg1
.
toService
()
<<
endl
;
cout
<<
"serviceVersion : "
<<
msg1
.
toVersion
()
<<
endl
;
cout
<<
"summary : "
<<
msg1
.
summary
()
<<
endl
;
cout
<<
"timestamp : "
<<
msg1
.
timestamp
()
<<
endl
;
cout
<<
"source : "
<<
msg1
.
from
()
<<
endl
;
cout
<<
"user : "
<<
msg1
.
forUser
()
<<
endl
;
cout
<<
"uuid : "
<<
msg1
.
uuid
()
<<
endl
;
cout
<<
"payload : "
<<
msg1
.
payload
()
<<
endl
;
return
(
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment