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 *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
|
@ -10,15 +10,13 @@
|
|||
#define FAIR_MQ_TRANSPORTS_H
|
||||
|
||||
#include <fairmq/tools/Strings.h>
|
||||
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace fair::mq
|
||||
{
|
||||
namespace fair::mq {
|
||||
|
||||
enum class Transport
|
||||
{
|
||||
|
@ -28,31 +26,26 @@ enum class Transport
|
|||
OFI
|
||||
};
|
||||
|
||||
struct TransportError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||
|
||||
} // namespace fair::mq
|
||||
|
||||
namespace fair::mq
|
||||
struct TransportError : std::runtime_error
|
||||
{
|
||||
|
||||
static std::unordered_map<std::string, Transport> TransportTypes {
|
||||
{ "default", Transport::DEFAULT },
|
||||
{ "zeromq", Transport::ZMQ },
|
||||
{ "shmem", Transport::SHM },
|
||||
{ "ofi", Transport::OFI }
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
static std::unordered_map<Transport, std::string> TransportNames {
|
||||
{ Transport::DEFAULT, "default" },
|
||||
{ Transport::ZMQ, "zeromq" },
|
||||
{ Transport::SHM, "shmem" },
|
||||
{ Transport::OFI, "ofi" }
|
||||
static std::unordered_map<std::string, Transport> TransportTypes{
|
||||
{"default", Transport::DEFAULT},
|
||||
{"zeromq", Transport::ZMQ},
|
||||
{"shmem", Transport::SHM},
|
||||
{"ofi", Transport::OFI}
|
||||
};
|
||||
|
||||
inline std::string TransportName(Transport transport)
|
||||
{
|
||||
return TransportNames[transport];
|
||||
}
|
||||
static std::unordered_map<Transport, std::string> TransportNames{
|
||||
{Transport::DEFAULT, "default"},
|
||||
{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)
|
||||
try {
|
||||
|
@ -66,6 +59,15 @@ inline std::ostream& operator<<(std::ostream& os, const Transport& 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 */
|
||||
|
|
Loading…
Reference in New Issue
Block a user