SDK: Refactor out DDSTask

This commit is contained in:
Dennis Klein 2019-08-20 17:51:25 +02:00 committed by Dennis Klein
parent 0f50abf3d9
commit 3cd6d8cfca
5 changed files with 70 additions and 33 deletions

View File

@ -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

View File

@ -11,6 +11,7 @@
#include <fairmq/sdk/DDSEnvironment.h>
#include <fairmq/sdk/DDSInfo.h>
#include <fairmq/sdk/DDSTask.h>
#include <boost/filesystem.hpp>
@ -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:

49
fairmq/sdk/DDSTask.h Normal file
View File

@ -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 <fairmq/sdk/DDSAgent.h>
#include <ostream>
#include <cstdint>
namespace fair {
namespace mq {
namespace sdk {
/**
* @class DDSTask <fairmq/sdk/DDSTask.h>
* @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 */

View File

@ -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<uint64_t> DDSTopology::GetDeviceList()
auto DDSTopology::GetTasks() const -> std::vector<DDSTask>
{
std::vector<uint64_t> taskIDs;
taskIDs.reserve(GetNumRequiredAgents());
std::vector<DDSTask> 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(); }

View File

@ -10,8 +10,9 @@
#define FAIR_MQ_SDK_DDSTOPOLOGY_H
#include <boost/filesystem.hpp>
#include <fairmq/sdk/DDSInfo.h>
#include <fairmq/sdk/DDSEnvironment.h>
#include <fairmq/sdk/DDSInfo.h>
#include <fairmq/sdk/DDSTask.h>
#include <memory>
#include <string>
@ -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<uint64_t> GetDeviceList();
/// @brief Get list of tasks in this topology
auto GetTasks() const -> std::vector<DDSTask>;
/// @brief Get the name of the topology
auto GetName() const -> std::string;