//SPDX-FileCopyrightText: 2023 Yury Gubich //SPDX-License-Identifier: GPL-3.0-or-later #include "resource.h" #include "pool.h" DB::Resource::Resource ( std::unique_ptr interface, std::weak_ptr parent ): parent(parent), interface(std::move(interface)) {} DB::Resource::Resource(Resource&& other): parent(other.parent), interface(std::move(other.interface)) {} DB::Resource::~Resource() { if (!interface) return; if (std::shared_ptr p = parent.lock()) p->free(std::move(interface)); } DB::Resource& DB::Resource::operator = (Resource&& other) { parent = other.parent; interface = std::move(other.interface); return *this; } DB::Interface* DB::Resource::operator -> () { return interface.get(); }