From 3cd6d8cfca0c9a4505ca147f598594a28c74e59e Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Tue, 20 Aug 2019 17:51:25 +0200 Subject: [PATCH] SDK: Refactor out DDSTask --- fairmq/sdk/CMakeLists.txt | 5 ++++ fairmq/sdk/DDSSession.h | 21 +--------------- fairmq/sdk/DDSTask.h | 49 ++++++++++++++++++++++++++++++++++++++ fairmq/sdk/DDSTopology.cxx | 19 ++++++++------- fairmq/sdk/DDSTopology.h | 9 +++---- 5 files changed, 70 insertions(+), 33 deletions(-) create mode 100644 fairmq/sdk/DDSTask.h diff --git a/fairmq/sdk/CMakeLists.txt b/fairmq/sdk/CMakeLists.txt index 5c9d0704..6204d4ec 100644 --- a/fairmq/sdk/CMakeLists.txt +++ b/fairmq/sdk/CMakeLists.txt @@ -15,11 +15,16 @@ set(target SDK) set(SDK_PUBLIC_HEADER_FILES ../SDK.h + AsioAsyncOp.h + AsioBase.h DDSAgent.h DDSEnvironment.h DDSSession.h + DDSTask.h DDSTopology.h + Error.h Topology.h + Traits.h ) set(SDK_PRIVATE_HEADER_FILES diff --git a/fairmq/sdk/DDSSession.h b/fairmq/sdk/DDSSession.h index 7a7e31dd..2b16ad12 100644 --- a/fairmq/sdk/DDSSession.h +++ b/fairmq/sdk/DDSSession.h @@ -11,6 +11,7 @@ #include #include +#include #include @@ -42,26 +43,6 @@ auto operator>>(std::istream& is, DDSRMSPlugin& plugin) -> std::istream&; class DDSTopology; class DDSAgent; -class DDSTask -{ - public: - using Id = std::uint64_t; - - explicit DDSTask(Id id) - : fId(id) - {} - - Id GetId() const { return fId; } - - friend auto operator<<(std::ostream& os, const DDSTask& task) -> std::ostream& - { - return os << "DDSTask id: " << task.fId; - } - - private: - Id fId; -}; - class DDSChannel { public: diff --git a/fairmq/sdk/DDSTask.h b/fairmq/sdk/DDSTask.h new file mode 100644 index 00000000..b3e788f1 --- /dev/null +++ b/fairmq/sdk/DDSTask.h @@ -0,0 +1,49 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_MQ_SDK_DDSTASK_H +#define FAIR_MQ_SDK_DDSTASK_H + +// #include + +#include +#include + +namespace fair { +namespace mq { +namespace sdk { + +/** + * @class DDSTask + * @brief Represents a DDS task + */ +class DDSTask +{ + public: + using Id = std::uint64_t; + + explicit DDSTask(Id id) + : fId(id) + {} + + Id GetId() const { return fId; } + + friend auto operator<<(std::ostream& os, const DDSTask& task) -> std::ostream& + { + return os << "DDSTask id: " << task.fId; + } + + private: + Id fId; +}; + +} // namespace sdk +} // namespace mq +} // namespace fair + +#endif /* FAIR_MQ_SDK_DDSTASK_H */ diff --git a/fairmq/sdk/DDSTopology.cxx b/fairmq/sdk/DDSTopology.cxx index c2d46415..3a8c94e3 100644 --- a/fairmq/sdk/DDSTopology.cxx +++ b/fairmq/sdk/DDSTopology.cxx @@ -63,29 +63,30 @@ auto DDSTopology::GetTopoFile() const -> Path return file; } -int DDSTopology::GetNumRequiredAgents() +auto DDSTopology::GetNumRequiredAgents() const -> int { return fImpl->fTopo.getRequiredNofAgents(); } -std::vector DDSTopology::GetDeviceList() +auto DDSTopology::GetTasks() const -> std::vector { - std::vector taskIDs; - taskIDs.reserve(GetNumRequiredAgents()); + std::vector list; + list.reserve(GetNumRequiredAgents()); - // TODO make sure returned tasks are actually devices auto itPair = fImpl->fTopo.getRuntimeTaskIterator( - [](const dds::topology_api::STopoRuntimeTask::FilterIterator_t::value_type& /*value*/) -> bool { return true; }); + [](const dds::topology_api::STopoRuntimeTask::FilterIterator_t::value_type&) -> bool { + return true; + }); auto tasks = boost::make_iterator_range(itPair.first, itPair.second); - for (auto task : tasks) { + for (const auto& task : tasks) { LOG(debug) << "Found task " << task.first << ": " << "Path: " << task.second.m_taskPath << ", " << "Name: " << task.second.m_task->getName() << "_" << task.second.m_taskIndex; - taskIDs.push_back(task.first); + list.emplace_back(task.first); } - return taskIDs; + return list; } auto DDSTopology::GetName() const -> std::string { return fImpl->fTopo.getName(); } diff --git a/fairmq/sdk/DDSTopology.h b/fairmq/sdk/DDSTopology.h index c530d73e..4687b4d8 100644 --- a/fairmq/sdk/DDSTopology.h +++ b/fairmq/sdk/DDSTopology.h @@ -10,8 +10,9 @@ #define FAIR_MQ_SDK_DDSTOPOLOGY_H #include -#include #include +#include +#include #include #include @@ -48,10 +49,10 @@ class DDSTopology auto GetTopoFile() const -> Path; /// @brief Get number of required agents for this topology - int GetNumRequiredAgents(); + auto GetNumRequiredAgents() const -> int; - /// @brief Get list of devices - std::vector GetDeviceList(); + /// @brief Get list of tasks in this topology + auto GetTasks() const -> std::vector; /// @brief Get the name of the topology auto GetName() const -> std::string;