FairMQChannel: Refactor, moving short methods to header

This commit is contained in:
Alexey Rybalchenko
2020-09-22 11:37:05 +02:00
committed by Dennis Klein
parent 120760da0a
commit 6699711e17
5 changed files with 116 additions and 280 deletions

View File

@@ -10,8 +10,10 @@
#define FAIR_MQ_TRANSPORTS_H
#include <fairmq/tools/CppSTL.h>
#include <fairmq/tools/Strings.h>
#include <memory>
#include <stdexcept>
#include <string>
#include <unordered_map>
@@ -28,6 +30,8 @@ enum class Transport
OFI
};
struct TransportError : std::runtime_error { using std::runtime_error::runtime_error; };
} /* namespace mq */
} /* namespace fair */
@@ -58,6 +62,18 @@ static std::unordered_map<Transport, std::string> TransportNames {
{ Transport::OFI, "ofi" }
};
inline std::string TransportName(Transport transport)
{
return TransportNames[transport];
}
inline Transport TransportType(const std::string& transport)
try {
return TransportTypes.at(transport);
} catch (std::out_of_range&) {
throw TransportError(tools::ToString("Unknown transport provided: ", transport));
}
} /* namespace mq */
} /* namespace fair */