From 9cf0af14e4743ab216bca2c0d693d8ea57f69589 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Tue, 3 Feb 2015 13:27:45 +0000 Subject: [PATCH] Task #7347: Added message protocol for lofar.task.feedback.dataproducts --- .../include/MessageBus/CMakeLists.txt | 1 + .../MessageBus/Protocols/CMakeLists.txt | 11 +++ .../Protocols/TaskFeedbackDataproducts.h | 94 +++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt create mode 100644 LCS/MessageBus/include/MessageBus/Protocols/TaskFeedbackDataproducts.h diff --git a/LCS/MessageBus/include/MessageBus/CMakeLists.txt b/LCS/MessageBus/include/MessageBus/CMakeLists.txt index 0dd022fe577..1e71faa1a0f 100644 --- a/LCS/MessageBus/include/MessageBus/CMakeLists.txt +++ b/LCS/MessageBus/include/MessageBus/CMakeLists.txt @@ -10,3 +10,4 @@ install(FILES MsgBus.h DESTINATION include/${PACKAGE_NAME}) +add_subdirectory(Protocols) diff --git a/LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt b/LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt new file mode 100644 index 00000000000..902eaf1f50d --- /dev/null +++ b/LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt @@ -0,0 +1,11 @@ +# $Id$ + +# Create symbolic link to include directory. +execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME}/Protocols) + +# Install header files. +install(FILES + TaskFeedbackDataproducts.h + DESTINATION include/${PACKAGE_NAME}/Protocols) diff --git a/LCS/MessageBus/include/MessageBus/Protocols/TaskFeedbackDataproducts.h b/LCS/MessageBus/include/MessageBus/Protocols/TaskFeedbackDataproducts.h new file mode 100644 index 00000000000..8aa10a5ed18 --- /dev/null +++ b/LCS/MessageBus/include/MessageBus/Protocols/TaskFeedbackDataproducts.h @@ -0,0 +1,94 @@ +//# TaskFeedbackDataproducts.h: Protocol for emission of dataproducts feedback information +//# +//# Copyright (C) 2015 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite is free software: you can redistribute it and/or +//# modify it under the terms of the GNU General Public License as published +//# by the Free Software Foundation, either version 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License along +//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#ifndef LOFAR_MESSAGEBUS_TASK_FEEDBACK_DATAPRODUCTS_H +#define LOFAR_MESSAGEBUS_TASK_FEEDBACK_DATAPRODUCTS_H + +#ifdef HAVE_QPID +#include <MessageBus/Message.h> + +namespace LOFAR { + +namespace Protocols { + +// Name of the system sending these messages +static const std::string system = "LOFAR"; + +// Version of the header we write +static const std::string headerVersion = "1.0.0"; + +class TaskFeedbackDataproducts: public Message +{ +public: + TaskFeedbackDataproducts( + // End-user responsible for this request (if applicable) + const std::string &forUser, + + // Human-readable summary describing this request + const std::string &summary, + + // Payload: a parset containing the generated feedback + const ParameterSet &feedback + ): + Message( + "lofar.task.feedback.dataproducts", + forUser, + summary, + "lofar.task.feedback.dataproducts", + "1.0.0") + { + std::string buffer; + + feedback.writeBuffer(buffer); + setTXTPayload(buffer); + } + + // Parse a message + TaskFeedbackDataproducts(const qpid::messaging::Message qpidMsg) + : + Message(qpidMsg) + { + } + + // Read a message from disk (header + payload) + TaskFeedbackDataproducts(const std::string &rawContent) + : + Message(rawContent) + { + } + + ParameterSet feedback() const { + ParameterSet result; + result.adoptBuffer(payload()); + + return result; + } +}; + +} // namespace Protocols + +} // namespace LOFAR + +#endif + +#endif + -- GitLab