Backup.
This commit is contained in:
95
src/io/Resource.cpp
Normal file
95
src/io/Resource.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
#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);
|
||||
}
|
||||
}
|
@@ -51,14 +51,14 @@ namespace ehs
|
||||
}
|
||||
|
||||
Audio::Audio()
|
||||
: hashId(0), sampleRate(0), dataType(DataType::FLOAT), byteDepth(0), channels(0), frames(0),
|
||||
length(0.0f), data(nullptr), peak(nullptr)
|
||||
: sampleRate(0), dataType(DataType::FLOAT), byteDepth(0), channels(0), frames(0), length(0.0f), data(nullptr),
|
||||
peak(nullptr)
|
||||
{
|
||||
AddType("Audio");
|
||||
}
|
||||
|
||||
Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames, const Byte* const data)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id), dataType(dataType), byteDepth(ToByteDepth(dataType)), sampleRate(sampleRate),
|
||||
: Resource((Str_8&&)id), dataType(dataType), byteDepth(ToByteDepth(dataType)), sampleRate(sampleRate),
|
||||
channels(channels), frames(frames), length((float)frames / (float)sampleRate),
|
||||
data(new Byte[GetSize()]), peak(new Byte[byteDepth])
|
||||
{
|
||||
@@ -68,7 +68,7 @@ namespace ehs
|
||||
}
|
||||
|
||||
Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Serializer<UInt_64>& data)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
: Resource((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
channels(channels), frames(data.Size() / channels / byteDepth), length((float)frames / (float)sampleRate),
|
||||
data(new Byte[data.Size()]), peak(new Byte[byteDepth])
|
||||
{
|
||||
@@ -78,7 +78,7 @@ namespace ehs
|
||||
}
|
||||
|
||||
Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Vector<Byte>& data)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
: Resource((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
channels(channels), frames(data.Size() / channels / byteDepth), length((float)frames / (float)sampleRate),
|
||||
data(new Byte[data.Size()]), peak(new Byte[byteDepth])
|
||||
{
|
||||
@@ -88,7 +88,7 @@ namespace ehs
|
||||
}
|
||||
|
||||
Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Array<Byte>& data)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
: Resource((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
channels(channels), frames(data.Size() / channels / byteDepth), length((float)frames / (float)sampleRate),
|
||||
data(new Byte[data.Size()]), peak(new Byte[byteDepth])
|
||||
{
|
||||
@@ -98,7 +98,7 @@ namespace ehs
|
||||
}
|
||||
|
||||
Audio::Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
: Resource((Str_8&&)id), sampleRate(sampleRate), dataType(dataType), byteDepth(ToByteDepth(dataType)),
|
||||
channels(channels), frames(frames), length((float)frames / (float)sampleRate),
|
||||
data(new Byte[GetSize()]), peak(new Byte[byteDepth])
|
||||
{
|
||||
@@ -106,18 +106,17 @@ namespace ehs
|
||||
}
|
||||
|
||||
Audio::Audio(Str_8 id)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id), sampleRate(0), dataType(DataType::FLOAT), byteDepth(0), channels(0),
|
||||
: Resource((Str_8&&)id), sampleRate(0), dataType(DataType::FLOAT), byteDepth(0), channels(0),
|
||||
frames(0), length(0.0f), data(nullptr), peak(nullptr)
|
||||
{
|
||||
AddType("Audio");
|
||||
}
|
||||
|
||||
Audio::Audio(Audio&& audio) noexcept
|
||||
: BaseObj((BaseObj&&)audio), hashId(audio.hashId), id((Str_8&&)id), sampleRate(audio.sampleRate),
|
||||
dataType(audio.dataType), byteDepth(audio.byteDepth), channels(audio.channels), frames(audio.frames),
|
||||
length(audio.length), data(audio.data), peak(audio.peak)
|
||||
: Resource((Resource&&)audio), sampleRate(audio.sampleRate), dataType(audio.dataType),
|
||||
byteDepth(audio.byteDepth), channels(audio.channels), frames(audio.frames), length(audio.length),
|
||||
data(audio.data), peak(audio.peak)
|
||||
{
|
||||
audio.hashId = 0;
|
||||
audio.sampleRate = 0;
|
||||
audio.dataType = DataType::FLOAT;
|
||||
audio.byteDepth = ToByteDepth(audio.dataType);
|
||||
@@ -129,9 +128,9 @@ namespace ehs
|
||||
}
|
||||
|
||||
Audio::Audio(const Audio& audio)
|
||||
: BaseObj(audio), hashId(audio.hashId), id(audio.id), sampleRate(audio.sampleRate), dataType(audio.dataType),
|
||||
byteDepth(audio.byteDepth), channels(audio.channels), frames(audio.frames), length(audio.length),
|
||||
data(new Byte[GetSize()]), peak(new Byte[audio.byteDepth])
|
||||
: Resource(audio), sampleRate(audio.sampleRate), dataType(audio.dataType), byteDepth(audio.byteDepth),
|
||||
channels(audio.channels), frames(audio.frames), length(audio.length), data(new Byte[GetSize()]),
|
||||
peak(new Byte[audio.byteDepth])
|
||||
{
|
||||
Util::Copy(data, audio.data, GetSize());
|
||||
}
|
||||
@@ -141,10 +140,8 @@ namespace ehs
|
||||
if (this == &audio)
|
||||
return *this;
|
||||
|
||||
BaseObj::operator=((BaseObj&&)audio);
|
||||
Resource::operator=((Resource&&)audio);
|
||||
|
||||
hashId = audio.hashId;
|
||||
id = (Str_8&&)audio.id;
|
||||
sampleRate = audio.sampleRate;
|
||||
dataType = audio.dataType;
|
||||
byteDepth = audio.byteDepth;
|
||||
@@ -156,7 +153,6 @@ namespace ehs
|
||||
delete[] peak;
|
||||
peak = audio.peak;
|
||||
|
||||
audio.hashId = 0;
|
||||
audio.sampleRate = 0;
|
||||
audio.dataType = DataType::FLOAT;
|
||||
audio.byteDepth = ToByteDepth(audio.dataType);
|
||||
@@ -174,10 +170,8 @@ namespace ehs
|
||||
if (this == &audio)
|
||||
return *this;
|
||||
|
||||
BaseObj::operator=(audio);
|
||||
Resource::operator=(audio);
|
||||
|
||||
hashId = audio.hashId;
|
||||
id = audio.id;
|
||||
sampleRate = audio.sampleRate;
|
||||
dataType = audio.dataType;
|
||||
byteDepth = audio.byteDepth;
|
||||
@@ -220,22 +214,6 @@ namespace ehs
|
||||
peak = nullptr;
|
||||
}
|
||||
|
||||
UInt_64 Audio::GetHashId() const
|
||||
{
|
||||
return hashId;
|
||||
}
|
||||
|
||||
void Audio::SetId(Str_8 newId)
|
||||
{
|
||||
hashId = newId.Hash_64();
|
||||
id = (Str_8&&)newId;
|
||||
}
|
||||
|
||||
Str_8 Audio::GetId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
UInt_64 Audio::GetSampleRate() const
|
||||
{
|
||||
return sampleRate;
|
||||
|
Reference in New Issue
Block a user