/******************************************************************************** * Copyright (C) 2019 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_SDK_ASIOBASE_H #define FAIR_MQ_SDK_ASIOBASE_H #include #include #include #include namespace fair { namespace mq { namespace sdk { using DefaultExecutor = asio::executor; using DefaultAllocator = std::allocator; /** * @class AsioBase AsioBase.h * @tparam Executor Associated I/O executor * @tparam Allocator Associated default allocator * @brief Base for creating Asio-enabled I/O objects * * @par Thread Safety * @e Distinct @e objects: Safe.@n * @e Shared @e objects: Unsafe. */ template class AsioBase { public: /// Member type of associated I/O executor using ExecutorType = Executor; /// Get associated I/O executor auto GetExecutor() const noexcept -> ExecutorType { return fExecutor; } /// Member type of associated default allocator using AllocatorType = Allocator; /// Get associated default allocator auto GetAllocator() const noexcept -> AllocatorType { return fAllocator; } /// NO default ctor AsioBase() = delete; /// Construct with associated I/O executor explicit AsioBase(Executor ex, Allocator alloc) : fExecutor(std::move(ex)) , fAllocator(std::move(alloc)) {} /// NOT copyable AsioBase(const AsioBase&) = delete; AsioBase& operator=(const AsioBase&) = delete; /// movable AsioBase(AsioBase&&) noexcept = default; AsioBase& operator=(AsioBase&&) noexcept = default; ~AsioBase() = default; private: ExecutorType fExecutor; AllocatorType fAllocator; }; } /* namespace sdk */ } /* namespace mq */ } /* namespace fair */ #endif /* FAIR_MQ_SDK_ASIOBASE_H */