1 #ifndef UVW_RESOURCE_INCLUDE_H
2 #define UVW_RESOURCE_INCLUDE_H
8 #include "underlying_type.hpp"
19 template<
typename T,
typename U>
24 auto parent()
const noexcept {
25 return this->
loop().loop.get();
28 void leak() noexcept {
29 sPtr = this->shared_from_this();
32 void reset() noexcept {
36 bool self()
const noexcept {
37 return static_cast<bool>(sPtr);
41 explicit Resource(ConstructorAccess ca, std::shared_ptr<Loop> ref)
44 this->get()->data =
this;
51 template<
typename R =
void>
52 std::shared_ptr<R>
data()
const {
53 return std::static_pointer_cast<R>(userData);
60 void data(std::shared_ptr<void> uData) {
61 userData = std::move(uData);
65 std::shared_ptr<void> userData{
nullptr};
66 std::shared_ptr<void> sPtr{
nullptr};
Event emitter base class.
Common class for almost all the resources available in uvw.
std::shared_ptr< R > data() const
Gets user-defined data. uvw won't use this field in any case.
void data(std::shared_ptr< void > uData)
Sets arbitrary data. uvw won't use this field in any case.
Wrapper class for underlying types.
Loop & loop() const noexcept
Gets the loop from which the resource was originated.