diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index 8b1e7222..83f6d582 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -33,10 +33,12 @@ if(BUILD_FAIRMQ OR BUILD_SDK) tools/Strings.h tools/Unique.h tools/Version.h + Error.h Tools.h ) set(TOOLS_SOURCE_FILES + Error.cxx tools/Network.cxx tools/Process.cxx tools/Semaphore.cxx diff --git a/fairmq/sdk/Error.cxx b/fairmq/Error.cxx similarity index 87% rename from fairmq/sdk/Error.cxx rename to fairmq/Error.cxx index 865994d1..90f257fb 100644 --- a/fairmq/sdk/Error.cxx +++ b/fairmq/Error.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,13 +8,9 @@ #include "Error.h" -namespace fair::mq -{ +namespace fair::mq { -const char* ErrorCategory::name() const noexcept -{ - return "fairmq"; -} +const char* ErrorCategory::name() const noexcept { return "fairmq"; } std::string ErrorCategory::message(int ev) const { @@ -40,4 +36,4 @@ const ErrorCategory errorCategory{}; std::error_code MakeErrorCode(ErrorCode e) { return {static_cast(e), errorCategory}; } -} // namespace fair::mq +} // namespace fair::mq diff --git a/fairmq/Error.h b/fairmq/Error.h new file mode 100644 index 00000000..9a3464f5 --- /dev/null +++ b/fairmq/Error.h @@ -0,0 +1,54 @@ +/******************************************************************************** + * Copyright (C) 2021 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_ERROR_H +#define FAIR_MQ_ERROR_H + +#include +#include +#include + +namespace fair::mq { + +struct RuntimeError : ::std::runtime_error +{ + template + explicit RuntimeError(T&&... t) + : ::std::runtime_error::runtime_error(tools::ToString(std::forward(t)...)) + {} +}; + +enum class ErrorCode +{ + OperationInProgress = 10, + OperationTimeout, + OperationCanceled, + DeviceChangeStateFailed, + DeviceGetPropertiesFailed, + DeviceSetPropertiesFailed +}; + +std::error_code MakeErrorCode(ErrorCode); + +struct ErrorCategory : std::error_category +{ + const char* name() const noexcept override; + std::string message(int ev) const override; +}; + +} // namespace fair::mq + +namespace std { + +template<> +struct is_error_code_enum : true_type +{}; + +} // namespace std + +#endif /* FAIR_MQ_ERROR_H */ diff --git a/fairmq/sdk/CMakeLists.txt b/fairmq/sdk/CMakeLists.txt index 984796ef..7c7484a3 100644 --- a/fairmq/sdk/CMakeLists.txt +++ b/fairmq/sdk/CMakeLists.txt @@ -36,7 +36,6 @@ set(SDK_SOURCE_FILES DDSEnvironment.cxx DDSSession.cxx DDSTopology.cxx - Error.cxx Topology.cxx ) diff --git a/fairmq/sdk/Error.h b/fairmq/sdk/Error.h index a8848b49..10a346bd 100644 --- a/fairmq/sdk/Error.h +++ b/fairmq/sdk/Error.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,53 +9,12 @@ #ifndef FAIR_MQ_SDK_ERROR_H #define FAIR_MQ_SDK_ERROR_H -#include -#include -#include +#include -namespace fair::mq -{ +namespace fair::mq::sdk { -namespace sdk -{ +using RuntimeError = fair::mq::RuntimeError; -struct RuntimeError : ::std::runtime_error -{ - template - explicit RuntimeError(T&&... t) - : ::std::runtime_error::runtime_error(tools::ToString(std::forward(t)...)) - {} -}; - -} /* namespace sdk */ - -enum class ErrorCode -{ - OperationInProgress = 10, - OperationTimeout, - OperationCanceled, - DeviceChangeStateFailed, - DeviceGetPropertiesFailed, - DeviceSetPropertiesFailed -}; - -std::error_code MakeErrorCode(ErrorCode); - -struct ErrorCategory : std::error_category -{ - const char* name() const noexcept override; - std::string message(int ev) const override; -}; - -} // namespace fair::mq - -namespace std -{ - -template<> -struct is_error_code_enum : true_type -{}; - -} // namespace std +} /* namespace fair::mq::sdk */ #endif /* FAIR_MQ_SDK_ERROR_H */