#ifndef INCLUDE_RESOURCE_HANDLE_IMPLEMENTATION # error Never include this file directly include 'resource_handle.hpp' #endif zgl::resource_handle::resource_handle(id_type id, reference_counter* manager) : m_id{ id }, m_counter{ manager } {} zgl::resource_handle::resource_handle(const resource_handle& other) noexcept : m_id{ other.m_id }, m_counter{ other.m_counter } { if (m_id != 0 and m_counter != nullptr) { m_counter->add_reference(m_id); } } zgl::resource_handle& zgl::resource_handle::operator=( const resource_handle& other ) noexcept { if (&other != this) { this->~resource_handle(); m_id = other.m_id; m_counter = other.m_counter; if (m_id != 0 and m_counter != nullptr) { m_counter->add_reference(m_id); } } return *this; } zgl::resource_handle::resource_handle(resource_handle&& other) noexcept : m_id{ other.m_id }, m_counter{ other.m_counter } { other.m_id = 0; other.m_counter = nullptr; } zgl::resource_handle& zgl::resource_handle::resource_handle::operator=( resource_handle&& other ) noexcept { if (&other != this) { this->~resource_handle(); m_id = other.m_id; m_counter = other.m_counter; other.m_id = 0; other.m_counter = nullptr; } return *this; } zgl::resource_handle::~resource_handle() { if (m_id != 0 and m_counter != nullptr) { m_counter->remove_reference(m_id); } }