FairMQ  1.4.14
C++ Message Queuing Library and Framework
AsioBase.h
1 /********************************************************************************
2  * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_SDK_ASIOBASE_H
10 #define FAIR_MQ_SDK_ASIOBASE_H
11 
12 #include <asio/executor.hpp>
13 #include <fairmq/sdk/Traits.h>
14 #include <memory>
15 #include <utility>
16 
17 namespace fair {
18 namespace mq {
19 namespace sdk {
20 
21 using DefaultExecutor = asio::executor;
22 using DefaultAllocator = std::allocator<int>;
23 
34 template<typename Executor, typename Allocator>
35 class AsioBase
36 {
37  public:
39  using ExecutorType = Executor;
41  auto GetExecutor() const noexcept -> ExecutorType { return fExecutor; }
42 
44  using AllocatorType = Allocator;
46  auto GetAllocator() const noexcept -> AllocatorType { return fAllocator; }
47 
49  AsioBase() = delete;
50 
52  explicit AsioBase(Executor ex, Allocator alloc)
53  : fExecutor(std::move(ex))
54  , fAllocator(std::move(alloc))
55  {}
56 
58  AsioBase(const AsioBase&) = delete;
59  AsioBase& operator=(const AsioBase&) = delete;
60 
62  AsioBase(AsioBase&&) noexcept = default;
63  AsioBase& operator=(AsioBase&&) noexcept = default;
64 
65  ~AsioBase() = default;
66 
67  private:
68  ExecutorType fExecutor;
69  AllocatorType fAllocator;
70 };
71 
72 } /* namespace sdk */
73 } /* namespace mq */
74 } /* namespace fair */
75 
76 #endif /* FAIR_MQ_SDK_ASIOBASE_H */
Executor ExecutorType
Member type of associated I/O executor.
Definition: AsioBase.h:39
Allocator AllocatorType
Member type of associated default allocator.
Definition: AsioBase.h:44
auto GetExecutor() const noexcept -> ExecutorType
Get associated I/O executor.
Definition: AsioBase.h:41
AsioBase(Executor ex, Allocator alloc)
Construct with associated I/O executor.
Definition: AsioBase.h:52
auto GetAllocator() const noexcept -> AllocatorType
Get associated default allocator.
Definition: AsioBase.h:46
Base for creating Asio-enabled I/O objects.
Definition: AsioBase.h:35
Definition: Error.h:56
AsioBase()=delete
NO default ctor.
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23

privacy