#pragma once
namespace engineapi
{
	template<typename T>
	inline const SerializedMeta* MetaBundle::FetchMeta() const
	{
		string_view name = type_name<typename T::BaseResource>().View();
		for (auto& elem : metadatas)
		{
			if (elem.t_hash == name)
				return &elem;
		}
		return nullptr;
	}
	template<typename T>
	inline const SerializedMeta* MetaBundle::FetchMeta(const string_view& asset_name) const
	{
		string_view name = type_name<typename T::BaseResource>().View();
		for (auto& elem : metadatas)
		{
			if (elem.t_hash == name && asset_name == elem.name)
				return &elem;
		}
		return nullptr;
	}
	template<typename T>
	void MetaBundle::Add(RscHandle<T> h)
	{
		if (h)
		{
			metadatas.emplace_back(SerializedMeta{ h.guid, string(h->Name()), string(type_name<T>().View()) });
		}
	}
}