mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
feat: Add new function GetEnabledTransports()
* Also clang-format
This commit is contained in:
parent
0c4921d650
commit
e3d3be888f
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2014-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
@ -10,15 +10,13 @@
|
||||||
#define FAIR_MQ_TRANSPORTS_H
|
#define FAIR_MQ_TRANSPORTS_H
|
||||||
|
|
||||||
#include <fairmq/tools/Strings.h>
|
#include <fairmq/tools/Strings.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace fair::mq
|
namespace fair::mq {
|
||||||
{
|
|
||||||
|
|
||||||
enum class Transport
|
enum class Transport
|
||||||
{
|
{
|
||||||
|
@ -28,31 +26,26 @@ enum class Transport
|
||||||
OFI
|
OFI
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TransportError : std::runtime_error { using std::runtime_error::runtime_error; };
|
struct TransportError : std::runtime_error
|
||||||
|
|
||||||
} // namespace fair::mq
|
|
||||||
|
|
||||||
namespace fair::mq
|
|
||||||
{
|
{
|
||||||
|
using std::runtime_error::runtime_error;
|
||||||
static std::unordered_map<std::string, Transport> TransportTypes {
|
|
||||||
{ "default", Transport::DEFAULT },
|
|
||||||
{ "zeromq", Transport::ZMQ },
|
|
||||||
{ "shmem", Transport::SHM },
|
|
||||||
{ "ofi", Transport::OFI }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unordered_map<Transport, std::string> TransportNames {
|
static std::unordered_map<std::string, Transport> TransportTypes{
|
||||||
{ Transport::DEFAULT, "default" },
|
{"default", Transport::DEFAULT},
|
||||||
{ Transport::ZMQ, "zeromq" },
|
{"zeromq", Transport::ZMQ},
|
||||||
{ Transport::SHM, "shmem" },
|
{"shmem", Transport::SHM},
|
||||||
{ Transport::OFI, "ofi" }
|
{"ofi", Transport::OFI}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::string TransportName(Transport transport)
|
static std::unordered_map<Transport, std::string> TransportNames{
|
||||||
{
|
{Transport::DEFAULT, "default"},
|
||||||
return TransportNames[transport];
|
{Transport::ZMQ, "zeromq"},
|
||||||
}
|
{Transport::SHM, "shmem"},
|
||||||
|
{Transport::OFI, "ofi"}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::string TransportName(Transport transport) { return TransportNames[transport]; }
|
||||||
|
|
||||||
inline Transport TransportType(const std::string& transport)
|
inline Transport TransportType(const std::string& transport)
|
||||||
try {
|
try {
|
||||||
|
@ -66,6 +59,15 @@ inline std::ostream& operator<<(std::ostream& os, const Transport& transport)
|
||||||
return os << TransportName(transport);
|
return os << TransportName(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace fair::mq
|
inline auto GetEnabledTransports() -> std::vector<Transport>
|
||||||
|
{
|
||||||
|
#ifdef BUILD_OFI_TRANSPORT
|
||||||
|
return {Transport::ZMQ, Transport::SHM, Transport::OFI};
|
||||||
|
#else
|
||||||
|
return {Transport::ZMQ, Transport::SHM};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fair::mq
|
||||||
|
|
||||||
#endif /* FAIR_MQ_TRANSPORTS_H */
|
#endif /* FAIR_MQ_TRANSPORTS_H */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user