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:
...
@@ -74,14 +74,16 @@ public:
virtual
~
Message
();
virtual
~
Message
();
// Return properties of the constructed or received message
// Return properties of the constructed or received message
std
::
string
system
()
const
;
std
::
string
system
()
const
{
return
(
getXMLvalue
(
"message.header.system"
));
}
std
::
string
headerVersion
()
const
;
std
::
string
headerVersion
()
const
{
return
(
getXMLvalue
(
"message.header.version"
));
}
std
::
string
payload
()
const
;
std
::
string
payload
()
const
{
return
(
getXMLvalue
(
"message.payload"
));
}
std
::
string
from
()
const
;
std
::
string
from
()
const
{
return
(
getXMLvalue
(
"message.header.request.source"
));
}
std
::
string
forUser
()
const
;
std
::
string
forUser
()
const
{
return
(
getXMLvalue
(
"message.header.request.user"
));
}
std
::
string
summary
()
const
;
std
::
string
uuid
()
const
{
return
(
getXMLvalue
(
"message.header.request.uuid"
));
}
std
::
string
toService
()
const
;
std
::
string
summary
()
const
{
return
(
getXMLvalue
(
"message.header.request.summary"
));
}
std
::
string
toVersion
()
const
;
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
// Construct the given fields as a QPID message
qpid
::
messaging
::
Message
getQpidMsg
()
const
{
return
(
itsQpidMsg
);
}
qpid
::
messaging
::
Message
getQpidMsg
()
const
{
return
(
itsQpidMsg
);
}
...
@@ -90,6 +92,9 @@ public:
...
@@ -90,6 +92,9 @@ public:
std
::
string
getRawContent
()
const
{
return
(
itsQpidMsg
.
getContent
());
}
std
::
string
getRawContent
()
const
{
return
(
itsQpidMsg
.
getContent
());
}
private
:
private
:
// Internal very simple XML parser to get a key from the XML content.
string
getXMLvalue
(
const
string
&
key
)
const
;
// datamembers
// datamembers
qpid
::
messaging
::
Message
itsQpidMsg
;
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 @@
...
@@ -26,9 +26,11 @@
//# Includes
//# Includes
#include
<Common/LofarLogger.h>
#include
<Common/LofarLogger.h>
#include
<Common/lofar_string.h>
#include
<Common/lofar_string.h>
#include
<Common/StringUtil.h>
#include
<MessageBus/Message.h>
#include
<MessageBus/Message.h>
namespace
LOFAR
{
namespace
LOFAR
{
using
namespace
StringUtil
;
const
string
LOFAR_MSG_TEMPLATE
=
"\
const
string
LOFAR_MSG_TEMPLATE
=
"\
<message>
\n
\
<message>
\n
\
...
@@ -64,10 +66,9 @@ Message::Message(const std::string &from,
...
@@ -64,10 +66,9 @@ Message::Message(const std::string &from,
cout
<<
itsQpidMsg
.
getContent
()
<<
endl
;
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
;
cout
<<
itsQpidMsg
.
getContent
()
<<
endl
;
}
}
...
@@ -103,45 +104,33 @@ void Message::setListPayload(const qpid::types::Variant::List &payload)
...
@@ -103,45 +104,33 @@ void Message::setListPayload(const qpid::types::Variant::List &payload)
}
}
// Return properties of the constructed or received message
string
Message
::
getXMLvalue
(
const
string
&
key
)
const
std
::
string
Message
::
system
()
const
{
{
return
"???"
;
// get copy of content
}
vector
<
string
>
labels
=
split
(
key
,
'.'
);
string
content
(
itsQpidMsg
.
getContent
());
std
::
string
Message
::
headerVersion
()
const
{
// loop over subkeys
return
"???"
;
string
::
size_type
offset
=
0
;
}
string
::
size_type
begin
;
string
::
size_type
end
;
std
::
string
Message
::
payload
()
const
for
(
size_t
i
=
0
;
i
<
labels
.
size
();
++
i
)
{
{
// define tags to find
return
"???"
;
string
startTag
(
"<"
+
labels
[
i
]
+
">"
);
}
string
stopTag
(
"</"
+
labels
[
i
]
+
">"
);
// search begin tag
std
::
string
Message
::
from
()
const
begin
=
content
.
find
(
startTag
,
offset
);
{
if
(
begin
==
string
::
npos
)
{
return
"???"
;
return
(
"???"
);
}
}
// search end tag
std
::
string
Message
::
forUser
()
const
begin
+=
startTag
.
size
();
{
end
=
content
.
find
(
stopTag
,
begin
);
return
"???"
;
if
(
end
==
string
::
npos
)
{
}
return
(
"???"
);
}
std
::
string
Message
::
summary
()
const
}
{
return
(
content
.
substr
(
begin
,
end
-
begin
));
return
"???"
;
}
std
::
string
Message
::
toService
()
const
{
return
"???"
;
}
std
::
string
Message
::
toVersion
()
const
{
return
"???"
;
}
}
...
...
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[]) {
...
@@ -78,6 +78,17 @@ int main(int argc, char* argv[]) {
string
KVmapje
(
"abc=[aap,noot,mies]
\n
myInteger=5
\n
myDouble=3.14"
);
string
KVmapje
(
"abc=[aap,noot,mies]
\n
myInteger=5
\n
myDouble=3.14"
);
msg1
.
setTXTPayload
(
KVmapje
);
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
);
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