uvw 3.4.0
Loading...
Searching...
No Matches
uv_type.hpp
1#ifndef UVW_UV_TYPE_INCLUDE_H
2#define UVW_UV_TYPE_INCLUDE_H
3
4#include <memory>
5#include <type_traits>
6#include <utility>
7#include "config.h"
8#include "loop.h"
9
10namespace uvw {
11
17template<typename U>
18struct uv_type {
19 explicit uv_type(loop::token, std::shared_ptr<loop> ref) noexcept
20 : owner{std::move(ref)}, resource{} {}
21
22 uv_type(const uv_type &) = delete;
23 uv_type(uv_type &&) = delete;
24
25 uv_type &operator=(const uv_type &) = delete;
26 uv_type &operator=(uv_type &&) = delete;
27
32 loop &parent() const noexcept {
33 return *owner;
34 }
35
51 const U *raw() const noexcept {
52 return &resource;
53 }
54
70 U *raw() noexcept {
71 return &resource;
72 }
73
74protected:
75 ~uv_type() = default;
76
77private:
78 std::shared_ptr<loop> owner;
79 U resource;
80};
81
82} // namespace uvw
83
84#endif // UVW_UV_TYPE_INCLUDE_H
The loop class.
Definition loop.h:60
Common class for almost all the resources available in uvw.
Definition resource.hpp:18
uvw default namespace.
Definition async.h:8
Wrapper class for underlying types.
Definition uv_type.hpp:18
const U * raw() const noexcept
Gets the underlying raw data structure.
Definition uv_type.hpp:51
loop & parent() const noexcept
Gets the loop from which the resource was originated.
Definition uv_type.hpp:32
U * raw() noexcept
Gets the underlying raw data structure.
Definition uv_type.hpp:70