mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
FairMQChannel: Refactor, moving short methods to header
This commit is contained in:
committed by
Dennis Klein
parent
120760da0a
commit
6699711e17
@@ -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 */
|
||||
|
||||
|
Reference in New Issue
Block a user