#pragma once
#include <memory>
#include <string>
struct ReferenceBlock {
uint64_t references = 0;
};
class Asset {
public:
std::string path;
template<class T>
struct AssetPtr {
AssetPtr() = default;
AssetPtr(T* ptr, ReferenceBlock* block) : handle(ptr), block(block) {
block->references++;
}
AssetPtr(const AssetPtr &rhs) {
handle = rhs.handle;
block = rhs.block;
if(block != nullptr)
AssetPtr& operator=(const AssetPtr& rhs) {
if(&rhs != this) {
if (block != nullptr)
return *this;
~AssetPtr() {
block->references--;
void clear() {
block = nullptr;
handle = nullptr;
T* handle = nullptr;
ReferenceBlock* block = nullptr;
explicit operator bool() const{
return handle != nullptr;
T* operator->() {
return handle;
T* operator->() const {
T* operator*() {
T* operator*() const {