1
0
forked from blue/pica
pica/database/resource.h

32 lines
627 B
C++

//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <memory>
#include "interface.h"
namespace DB {
class Pool;
class Resource {
friend class Pool;
Resource(std::unique_ptr<Interface> interface, std::weak_ptr<Pool> parent);
public:
Resource(const Resource&) = delete;
Resource(Resource&& other);
~Resource();
Resource& operator = (const Resource&) = delete;
Resource& operator = (Resource&& other);
Interface* operator -> ();
private:
std::weak_ptr<Pool> parent;
std::unique_ptr<Interface> interface;
};
}