EHS/src/io/Resource.cpp

95 lines
1.4 KiB
C++
Raw Normal View History

2024-02-05 22:25:30 -08:00
#include "ehs/io/Resource.h"
namespace ehs
{
Resource::Resource()
: hashId(0)
{
AddType("Resource");
}
Resource::Resource(ehs::Str_8 id)
: hashId(id.Hash_64()), id(std::move(id))
{
AddType("Resource");
}
Resource::Resource(Resource&& rsrc) noexcept
: BaseObj((BaseObj&&)rsrc), hashId(rsrc.hashId), id(std::move(rsrc.id))
{
rsrc.hashId = 0;
}
Resource::Resource(const Resource& rsrc)
: BaseObj(rsrc), hashId(rsrc.hashId), id(rsrc.id)
{
}
Resource& Resource::operator=(Resource&& rsrc) noexcept
{
if (this == &rsrc)
return *this;
BaseObj::operator=((BaseObj&&)rsrc);
hashId = rsrc.hashId;
id = std::move(rsrc.id);
rsrc.hashId = 0;
return *this;
}
Resource& Resource::operator=(const Resource& rsrc)
{
if (this == &rsrc)
return *this;
BaseObj::operator=(rsrc);
hashId = rsrc.hashId;
id = rsrc.id;
return *this;
}
bool Resource::operator==(const ehs::UInt_64 otherHashId) const
{
return hashId == otherHashId;
}
bool Resource::operator!=(const ehs::UInt_64 otherHashId) const
{
return hashId != otherHashId;
}
void Resource::Release()
{
}
void Resource::SetId(ehs::Str_8 newId)
{
hashId = newId.Hash_64();
id = std::move(newId);
}
ehs::UInt_64 Resource::GetHashId() const
{
return hashId;
}
ehs::Str_8 Resource::GetId() const
{
return id;
}
bool Resource::IsValid() const
{
return hashId;
}
Resource* Resource::Clone() const
{
return new Resource(*this);
}
}