mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 18:11:49 +00:00
FairMQ: Fix various errors from CI
* move Plugins::Version to fair::mq::tools * fix Parser interface * make device a shared pointer in main * provide std::hash template specialization * fix FairMQ.Plugins/FairMQ.PluginsStatic when run with ctest * fix MQ/serialization example * add --no-as-needed flag * GCC 4 does not support member refs, move to pointer types
This commit is contained in:
committed by
Mohammad Al-Turany
parent
ad0f050c99
commit
a26925cbf5
@@ -9,7 +9,9 @@
|
||||
#ifndef FAIR_MQ_TOOLS_CPPSTL_H
|
||||
#define FAIR_MQ_TOOLS_CPPSTL_H
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
@@ -25,6 +27,18 @@ std::unique_ptr<T> make_unique(Args&& ...args)
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
// provide an enum hasher to compensate std::hash not supporting enums in C++11
|
||||
template<typename Enum>
|
||||
struct HashEnum
|
||||
{
|
||||
auto operator()(const Enum& e) const noexcept
|
||||
-> typename std::enable_if<std::is_enum<Enum>::value, std::size_t>::type
|
||||
{
|
||||
using _type = typename std::underlying_type<Enum>::type;
|
||||
return std::hash<_type>{}(static_cast<_type>(e));
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace tools */
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <fairmq/tools/CppSTL.h>
|
||||
#include <fairmq/tools/Network.h>
|
||||
#include <fairmq/tools/Strings.h>
|
||||
#include <fairmq/tools/Version.h>
|
||||
|
||||
namespace FairMQ
|
||||
{
|
||||
@@ -13,6 +14,7 @@ namespace tools
|
||||
{
|
||||
|
||||
using fair::mq::tools::make_unique;
|
||||
using fair::mq::tools::HashEnum;
|
||||
|
||||
using fair::mq::tools::getHostIPs;
|
||||
using fair::mq::tools::getInterfaceIP;
|
||||
@@ -20,6 +22,8 @@ using fair::mq::tools::getDefaultRouteNetworkInterface;
|
||||
|
||||
using fair::mq::tools::S;
|
||||
|
||||
using fair::mq::tools::Version;
|
||||
|
||||
} // namespace tools
|
||||
} // namespace FairMQ
|
||||
|
||||
|
39
fairmq/tools/Version.h
Normal file
39
fairmq/tools/Version.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2017 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_TOOLS_VERSION_H
|
||||
#define FAIR_MQ_TOOLS_VERSION_H
|
||||
|
||||
#include <ostream>
|
||||
#include <tuple>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
namespace mq
|
||||
{
|
||||
namespace tools
|
||||
{
|
||||
|
||||
struct Version
|
||||
{
|
||||
const int fkMajor, fkMinor, fkPatch;
|
||||
|
||||
friend auto operator< (const Version& lhs, const Version& rhs) -> bool { return std::tie(lhs.fkMajor, lhs.fkMinor, lhs.fkPatch) < std::tie(rhs.fkMajor, rhs.fkMinor, rhs.fkPatch); }
|
||||
friend auto operator> (const Version& lhs, const Version& rhs) -> bool { return rhs < lhs; }
|
||||
friend auto operator<=(const Version& lhs, const Version& rhs) -> bool { return !(lhs > rhs); }
|
||||
friend auto operator>=(const Version& lhs, const Version& rhs) -> bool { return !(lhs < rhs); }
|
||||
friend auto operator==(const Version& lhs, const Version& rhs) -> bool { return std::tie(lhs.fkMajor, lhs.fkMinor, lhs.fkPatch) == std::tie(rhs.fkMajor, rhs.fkMinor, rhs.fkPatch); }
|
||||
friend auto operator!=(const Version& lhs, const Version& rhs) -> bool { return !(lhs == rhs); }
|
||||
friend auto operator<<(std::ostream& os, const Version& v) -> std::ostream& { return os << v.fkMajor << "." << v.fkMinor << "." << v.fkPatch; }
|
||||
};
|
||||
|
||||
} /* namespace tools */
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
||||
|
||||
#endif /* FAIR_MQ_TOOLS_VERSION_H */
|
Reference in New Issue
Block a user