Fixed all errors.

This commit is contained in:
2023-12-18 02:13:20 -08:00
parent 3acb78f247
commit 0a6f5533ee
37 changed files with 950 additions and 1090 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include "EHS.h"
#include "Types.h"
#include "BaseObj.h"
#include <initializer_list>
#include <algorithm>
@@ -11,7 +12,7 @@ namespace ehs
/// @tparam T Array data type to use.
/// @tparam N Number data type to use.
template<typename T, typename N = UInt_64>
class Array
class Array : public BaseObj
{
protected:
T* data;
@@ -19,7 +20,7 @@ namespace ehs
public:
/// Frees any data created on the heap.
~Array()
~Array() override
{
delete[] data;
}
@@ -28,20 +29,24 @@ namespace ehs
Array()
: data(nullptr), size(0)
{
AddType("Array");
}
/// Initializes an empty array with the given size.
/// @note Data must be assigned manually using an index.
explicit Array(const N size)
: data(new T[size]), size(size)
: data(new T[size]), size(size)
{
AddType("Array");
}
/// Initializes this array with an initializer list object.
/// @param [in] list The given initializer list.
Array(std::initializer_list<T> list)
: data(new T[list.size()]), size(list.size())
: data(new T[list.size()]), size(list.size())
{
AddType("Array");
N i = 0;
for (auto v = list.begin(); v != list.end(); ++v)
data[i++] = std::move(*v);
@@ -51,27 +56,46 @@ namespace ehs
/// @param [in] data The C-style array.
/// @param [in] size The size of the given C-style array.
Array(const T* const data, const N size)
: data(new T[size]), size(size)
: data(new T[size]), size(size)
{
AddType("Array");
for (N i = 0; i < size; ++i)
this->data[i] = data[i];
}
Array(Array&& array) noexcept
: BaseObj(array), data(array.data), size(array.size)
{
array.data = nullptr;
array.size = 0;
}
/// Copies all members from the given array object.
/// @param [in] array The array object to copy from.
Array(const Array& array)
: data(new T[array.size]), size(array.size)
: BaseObj((BaseObj&&)array), data(new T[array.size]), size(array.size)
{
for (N i = 0; i < size; ++i)
data[i] = array.data[i];
}
Array(Array&& array) noexcept
: data(array.data), size(array.size)
{
array.data = nullptr;
array.size = 0;
}
Array<T, N>& operator=(Array&& array) noexcept
{
if (this == &array)
return *this;
BaseObj::operator=((BaseObj&&)array);
delete[] data;
data = array.data;
size = array.size;
array.data = nullptr;
array.size = 0;
return *this;
}
/// Copies all members from the given array object.
/// @param [in] array The array object to copy from.
@@ -81,6 +105,8 @@ namespace ehs
if (this == &array)
return *this;
BaseObj::operator=(array);
delete[] data;
data = new T[array.size];
for (N i = 0; i < array.size; ++i)
@@ -91,21 +117,6 @@ namespace ehs
return *this;
}
Array<T, N>& operator=(Array&& array) noexcept
{
if (this == &array)
return *this;
delete[] data;
data = array.data;
size = array.size;
array.data = nullptr;
array.size = 0;
return *this;
}
/// Copies all members from the given initializer list object.
/// @param [in] list The initializer list object to copy from.
/// @returns The array that has been assigned to.

View File

@@ -1,95 +1,52 @@
#pragma once
#include "EHS.h"
#include "Types.h"
#include "Type.h"
#include "Array.h"
#include "Log.h"
namespace ehs
{
class BaseObj
{
private:
Array<Type> hierarchy;
BaseObj* parent;
Type* hierarchy;
UInt_64 hierarchySize;
public:
virtual ~BaseObj();
BaseObj();
BaseObj(BaseObj&& base) noexcept;
BaseObj(const BaseObj& base);
BaseObj(BaseObj&& base) noexcept;
BaseObj& operator=(BaseObj&& base) noexcept;
BaseObj& operator=(const BaseObj& base);
BaseObj& operator=(BaseObj&& base) noexcept;
bool operator!() const;
bool operator==(const BaseObj& base) const;
bool operator!=(const BaseObj& base) const;
bool HasType(const UInt_64 hashType) const;
const Type* GetHierarchy() const;
bool HasType(const Str_8& type) const;
UInt_64 GetHierarchySize() const;
protected:
bool AddType(Str_8 type);
bool HasType(UInt_64 typeHashId) const;
bool HasType(const Char_8* typeId) const;
public:
Type GetType() const;
Type GetType(const UInt_64 hashType) const;
Type GetType(const Str_8& type) const;
UInt_64 GetTypeIdSize() const;
const Char_8* GetTypeId() const;
UInt_64 GetTypeHashId() const;
const Array<Type>& GetHierarchy() const;
void SetParent(BaseObj* newParent);
BaseObj* GetParent();
BaseObj* GetParent(const UInt_64 hashType);
BaseObj* GetParent(const Str_8& type);
virtual BaseObj* Clone() const;
virtual bool IsValid() const;
protected:
void AddType(const Char_8* id);
};
inline bool BaseObj::HasType(const UInt_64 hashType) const
{
for (UInt_64 i = 0; i < hierarchy.Size(); ++i)
if (hashType == hierarchy[i].GetHashId())
return true;
return false;
}
inline Type BaseObj::GetType(const UInt_64 hashType) const
{
for (UInt_64 i = 0; i < hierarchy.Size(); ++i)
if (hashType == hierarchy[i].GetHashId())
return hierarchy[i];
return {};
}
inline BaseObj* BaseObj::GetParent(const UInt_64 hashType)
{
BaseObj* result = GetParent();
while (result && !result->HasType(hashType))
result = result->GetParent();
return result;
}
}

View File

@@ -60,4 +60,4 @@ namespace ehs
Version GetAppVersion();
};
extern lwe::SInt_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVer);
extern ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer);

View File

@@ -109,8 +109,8 @@ namespace ehs
#ifndef EHS_LOG
#ifdef EHS_DEBUG
#define EHS_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), EHS_FILE, EHS_FUNC, lwe::Str_8::FromNum((lwe::UInt_32)EHS_LINE)}, code, msg})
#define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg})
#else
#define EHS_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), EHS_FUNC}, code, msg})
#define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FUNC}, code, msg})
#endif
#endif

View File

@@ -1,6 +1,7 @@
#pragma once
#include "EHS.h"
#include "Types.h"
#include "BaseObj.h"
#include "Util.h"
#include "Array.h"
#include "Vector.h"
@@ -20,7 +21,7 @@
namespace ehs
{
template<typename N = UInt_64>
class Serializer
class Serializer : public BaseObj
{
private:
Endianness endianness;
@@ -29,7 +30,7 @@ namespace ehs
N offset;
public:
~Serializer()
~Serializer() override
{
delete[] data;
}
@@ -37,45 +38,74 @@ namespace ehs
Serializer()
: endianness(Endianness::BE), data(nullptr), size(0), offset(0)
{
AddType("Serializer");
}
Serializer(const Endianness endianness)
: endianness(endianness), data(nullptr), size(0), offset(0)
{
AddType("Serializer");
}
Serializer(const Endianness endianness, const N size)
: endianness(endianness), data(new Byte[size]), size(size), offset(0)
{
AddType("Serializer");
}
Serializer(const Endianness endianness, const Byte* const data, const N size, const N offset = 0)
: endianness(endianness), data(new Byte[size]), size(size), offset(offset)
{
AddType("Serializer");
for (N i = 0; i < size; ++i)
this->data[i] = data[i];
}
Serializer(const Serializer& serializer)
: endianness(serializer.endianness), data(new Byte[serializer.size]), size(serializer.size), offset(serializer.offset)
{
for (N i = 0; i < serializer.size; ++i)
data[i] = serializer.data[i];
}
Serializer(Serializer&& serializer) noexcept
: endianness(serializer.endianness), data(serializer.data), size(serializer.size), offset(serializer.offset)
: BaseObj((BaseObj&&)serializer), endianness(serializer.endianness), data(serializer.data),
size(serializer.size), offset(serializer.offset)
{
serializer.data = nullptr;
serializer.size = 0;
serializer.offset = 0;
}
Serializer(const Serializer& serializer)
: BaseObj(serializer), endianness(serializer.endianness), data(new Byte[serializer.size]),
size(serializer.size), offset(serializer.offset)
{
for (N i = 0; i < serializer.size; ++i)
data[i] = serializer.data[i];
}
Serializer& operator=(Serializer&& serializer) noexcept
{
if (this == &serializer)
return *this;
BaseObj::operator=((Serializer&&)serializer);
endianness = serializer.endianness;
delete[] data;
data = serializer.data;
size = serializer.size;
offset = serializer.offset;
serializer.data = nullptr;
serializer.size = 0;
serializer.offset = 0;
return *this;
}
Serializer& operator=(const Serializer& serializer)
{
if (this == &serializer)
return *this;
BaseObj::operator=(serializer);
endianness = serializer.endianness;
delete[] data;
@@ -89,24 +119,6 @@ namespace ehs
return *this;
}
Serializer& operator=(Serializer&& serializer) noexcept
{
if (this == &serializer)
return *this;
endianness = serializer.endianness;
delete[] data;
data = serializer.data;
size = serializer.size;
offset = serializer.offset;
serializer.data = nullptr;
serializer.size = 0;
serializer.offset = 0;
return *this;
}
bool operator==(const Serializer& in) const
{
if (size != in.size)

View File

@@ -1,6 +1,7 @@
#pragma once
#include "Types.h"
#include "BaseObj.h"
#include "Util.h"
#include "Vector.h"
@@ -24,7 +25,7 @@ namespace ehs
/// @tparam T The character's data type to use.
/// @tparam N The number data type to use.
template<typename T = Char_8, typename N = UInt_64>
class Str
class Str : public BaseObj
{
private:
N size;
@@ -41,6 +42,7 @@ namespace ehs
Str()
: size(0), data(nullptr)
{
AddType("Str");
}
/// Initializes members with given C-style string.
@@ -54,6 +56,8 @@ namespace ehs
Util::Copy(data, str, Size(true));
data[this->size] = 0;
AddType("Str");
}
/// Initializes members with given C-style string.
@@ -66,6 +70,8 @@ namespace ehs
Util::Copy(data, str, Size(true));
data[size] = 0;
AddType("Str");
}
/// Initializes string with the given size.
@@ -74,33 +80,54 @@ namespace ehs
: size(size), data(new T[size + 1])
{
data[size] = 0;
AddType("Str");
}
Str(Str&& str) noexcept
: BaseObj((BaseObj&&)str), size(str.size), data(str.data)
{
str.size = 0;
str.data = nullptr;
}
/// Copies all members from the given string object.
/// @param [in] str The string object to copy from.
Str(const Str& str)
: size(str.size), data(new T[size + 1])
: BaseObj(str), size(str.size), data(new T[size + 1])
{
Util::Copy(data, str.data, Size(true));
data[size] = 0;
}
Str(Str&& str) noexcept
: size(str.size), data(str.data)
{
str.size = 0;
str.data = nullptr;
}
Str& operator=(Str&& str) noexcept
{
if (this == &str)
return *this;
BaseObj::operator=((BaseObj&&)str);
size = str.size;
delete[] data;
data = str.data;
str.size = 0;
str.data = nullptr;
return *this;
}
/// Copies all members from the given string object.
/// @param [in] str The string object to copy from.
/// @returns The string that has been assigned to.
Str<T, N>& operator=(const Str<T, N>& str)
Str& operator=(const Str& str)
{
if (&str == this)
return *this;
BaseObj::operator=(str);
size = str.size;
delete[] data;
@@ -111,21 +138,6 @@ namespace ehs
return *this;
}
Str& operator=(Str&& str) noexcept
{
if (this == &str)
return *this;
size = str.size;
delete[] data;
data = str.data;
str.size = 0;
str.data = nullptr;
return *this;
}
/// Copies the given C-style string and retrieves the size.
/// @param [in] str The C-style string to copy from.
/// @returns The string object that has been assigned to.
@@ -1823,39 +1835,39 @@ namespace ehs
typedef Str<Char_8, UInt_64> Str_8;
}
template<typename T = lwe::Char_8, typename N = lwe::UInt_64>
bool operator==(const T* const first, const lwe::Str<T, N>& second)
template<typename T = ehs::Char_8, typename N = ehs::UInt_64>
bool operator==(const T* const first, const ehs::Str<T, N>& second)
{
N inSize = lwe::Str<T, N>::Len(first);
N inSize = ehs::Str<T, N>::Len(first);
if (second.Size() != inSize)
return false;
return lwe::Util::IsEqual(first, second, second.Size(true));
return ehs::Util::IsEqual(first, second, second.Size(true));
}
template<typename T = lwe::Char_8, typename N = lwe::UInt_64>
bool operator!=(const T* const first, const lwe::Str<T, N>& second)
template<typename T = ehs::Char_8, typename N = ehs::UInt_64>
bool operator!=(const T* const first, const ehs::Str<T, N>& second)
{
N inSize = lwe::Str<T, N>::Len(first);
N inSize = ehs::Str<T, N>::Len(first);
if (second.Size() != inSize)
return true;
return !lwe::Util::IsEqual(first, second, second.Size(true));
return !ehs::Util::IsEqual(first, second, second.Size(true));
}
/// Concatenates a C-style string with a string.
/// @param [in] first The given C-style string.
/// @param [in] second The given string.
/// @returns The result.
template<typename T = lwe::Char_8, typename N = lwe::UInt_64>
lwe::Str<T, N> operator+(const T* const first, const lwe::Str<T, N>& second)
template<typename T = ehs::Char_8, typename N = ehs::UInt_64>
ehs::Str<T, N> operator+(const T* const first, const ehs::Str<T, N>& second)
{
N inSize = lwe::Str<T, N>::Len(first);
N inSize = ehs::Str<T, N>::Len(first);
lwe::Str<T, N> result(inSize + second.Size());
ehs::Str<T, N> result(inSize + second.Size());
lwe::Util::Copy(result, first, inSize * sizeof(T));
lwe::Util::Copy(&result[inSize], &second[0], second.Size(true));
ehs::Util::Copy(result, first, inSize * sizeof(T));
ehs::Util::Copy(&result[inSize], &second[0], second.Size(true));
result[inSize + second.Size()] = 0;

View File

@@ -1,47 +1,55 @@
#pragma once
#include "EHS.h"
#include "Str.h"
#include "Types.h"
#include "Util.h"
namespace ehs
{
class Type
{
private:
friend class BaseObj;
UInt_64 size;
const Char_8* id;
UInt_64 hashId;
Str_8 id;
public:
Type();
Type(Str_8 id);
explicit Type(const Char_8* id);
Type(Type&& type) noexcept = default;
Type(const Type& type) = default;
Type(Type&& type) noexcept;
Type& operator=(Type&& type) noexcept = default;
Type& operator=(const Type& type);
Type& operator=(Type&& type) noexcept;
bool operator!() const;
Type& operator=(const Type& type) = default;
bool operator==(const Type& type) const;
bool operator!=(const Type& type) const;
bool operator==(const UInt_64 hashId) const;
bool operator==(UInt_64 inHashId) const;
bool operator!=(const UInt_64 hashId) const;
bool operator!=(UInt_64 inHashId) const;
bool operator==(const Str_8& type) const;
bool operator==(const Char_8* inStr) const;
bool operator!=(const Str_8& type) const;
bool operator!=(const Char_8* inStr) const;
UInt_64 GetSize() const;
const Char_8* GetId() const;
UInt_64 GetHashId() const;
Str_8 GetId() const;
bool IsValid() const;
private:
static UInt_64 CalcSize(const Char_8* id);
static UInt_64 GenHash(const Char_8* id, UInt_64 size);
};
}

View File

@@ -1,12 +1,12 @@
#pragma once
#include "BaseObj.h"
#include "Types.h"
#include "Util.h"
#include <initializer_list>
#include <utility>
#include "Util.h"
namespace ehs
{
/// An array with extra memory pre-allocated for fast pushes.
@@ -14,7 +14,7 @@ namespace ehs
/// @tparam N Number data type to use.
/// @note If extra memory is set to five then each time that memory is filled it will add five extra.
template<typename T, typename N = UInt_64>
class Vector
class Vector : public BaseObj
{
protected:
N rawSize;
@@ -24,7 +24,7 @@ namespace ehs
public:
/// Frees any data created on the heap.
~Vector()
~Vector() override
{
delete[] data;
}
@@ -33,6 +33,7 @@ namespace ehs
Vector()
: rawSize(0), size(0), stride(5), data(nullptr)
{
AddType("Vector");
}
/// Initializes members for pre-allocated memory to write to later.
@@ -41,14 +42,17 @@ namespace ehs
Vector(const N size, const N stride)
: rawSize(size + stride), size(size), stride(stride), data(new T[rawSize])
{
AddType("Vector");
}
/// Initializes this vector with an initializer list object.
/// @param [in] list The given initializer list.
/// @param [in] stride The extra amount of memory to allocate.
Vector(std::initializer_list<T> list, const N stride = 5)
: rawSize(0), size(list.size()), stride(stride), data(nullptr)
: rawSize(0), size(list.size()), stride(stride), data(nullptr)
{
AddType("Vector");
if (stride)
{
rawSize = list.size() / stride * stride;
@@ -74,6 +78,8 @@ namespace ehs
Vector(const T* data, const N size, const N stride)
: rawSize(0), size(size), stride(stride), data(nullptr)
{
AddType("Vector");
if (stride)
{
rawSize = size / stride * stride;
@@ -94,14 +100,14 @@ namespace ehs
/// Copies all members from the given vector object.
/// @param [in] vec The vector object to copy from.
Vector(const Vector& vec)
: rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(new T[rawSize])
: BaseObj(vec), rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(new T[rawSize])
{
for (N i = 0; i < size; ++i)
data[i] = vec.data[i];
}
Vector(Vector&& vec) noexcept
: rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(vec.data)
: BaseObj((BaseObj&&)vec), rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(vec.data)
{
vec.rawSize = 0;
vec.size = 0;
@@ -117,6 +123,8 @@ namespace ehs
if (this == &vec)
return *this;
BaseObj::operator=(vec);
rawSize = vec.rawSize;
size = vec.size;
stride = vec.stride;
@@ -135,6 +143,8 @@ namespace ehs
if (this == &vec)
return *this;
BaseObj::operator=((BaseObj&&)vec);
rawSize = vec.rawSize;
size = vec.size;
stride = vec.stride;
@@ -268,9 +278,12 @@ namespace ehs
/// @param [in] dstOffset The offset index to copy the given C-style array to.
/// @param [in] src The given C-style array.
/// @param [in] size The size from the given C-style array to copy.
void Copy(const N dstOffset, const T* src, const N size)
void Copy(const N dstOffset, const T* src, const N inSize)
{
for (N i = 0; i < size; ++i)
if (dstOffset + inSize > size)
return;
for (N i = 0; i < inSize; ++i)
data[i + dstOffset] = src[i];
}

View File

@@ -31,7 +31,7 @@ namespace ehs
UInt_64 GetGlyphScale() const;
Glyph GetGlyph(const Char_32 code) const;
Glyph GetGlyph(Char_32 code) const;
Vec2_f CalculateSize(const Str_8& text) const;
@@ -41,8 +41,6 @@ namespace ehs
UInt_64 CalculateIndexAtPoint(const Str_8& text, const Vec2_f& point) const;
Mesh Generate(const Anchor anchor, const Str_8& text) const;
FontAtlas* Clone() const override;
Mesh Generate(Anchor anchor, const Str_8& text) const;
};
}

View File

@@ -1,6 +1,7 @@
#pragma once
#include "EHS.h"
#include "Types.h"
#include "BaseObj.h"
#include "DataType.h"
#include "Str.h"
#include "Serializer.h"
@@ -10,10 +11,12 @@
namespace ehs
{
class Audio : public Resource
class Audio : public BaseObj
{
private:
static Array<AudioCodec> codecs;
UInt_64 hashId;
Str_8 id;
UInt_64 sampleRate;
DataType dataType;
UInt_8 byteDepth;
@@ -24,29 +27,31 @@ namespace ehs
Byte* peak;
public:
static bool HasCodec(const UInt_64 hashExt);
static bool HasCodec(UInt_64 hashExt);
static bool HasCodec(const Str_8& ext);
static bool AddCodec(AudioCodec codec);
static const AudioCodec* GetCodec(const UInt_64 hashExt);
static const AudioCodec* GetCodec(UInt_64 hashExt);
static const AudioCodec* GetCodec(const Str_8& ext);
~Audio() override;
~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);
Audio(Str_8 id);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Serializer<UInt_64>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames, const Byte* data);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Vector<Byte>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Serializer<UInt_64>& data);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const Array<Byte>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Vector<Byte>& data);
Audio(Str_8 id, const UInt_64 sampleRate, const DataType dataType, const UInt_8 channels, const UInt_64 frames);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, const Array<Byte>& data);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames);
Audio(Audio&& audio) noexcept;
@@ -60,6 +65,14 @@ namespace ehs
operator Byte*();
void Release();
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
UInt_64 GetSampleRate() const;
DataType GetDataType() const;
@@ -78,23 +91,23 @@ namespace ehs
float GetLength() const;
Array<Byte> FrameAsMono(const UInt_64 frameIndex) const;
Array<Byte> FrameAsMono(UInt_64 frameIndex) const;
Array<Byte> FrameAsStereo(const UInt_64 frameIndex) const;
Array<Byte> FrameAsStereo(UInt_64 frameIndex) const;
Array<Byte> FrameAsFive_One(const UInt_64 frameIndex) const;
Array<Byte> FrameAsFive_One(UInt_64 frameIndex) const;
Array<Byte> FrameAsSeven_One(const UInt_64 frameIndex) const;
Array<Byte> FrameAsSeven_One(UInt_64 frameIndex) const;
SInt_8 SampleAsSInt_8(const UInt_64 sampleIndex) const;
SInt_8 SampleAsSInt_8(UInt_64 sampleIndex) const;
SInt_16 SampleAsSInt_16(const UInt_64 sampleIndex) const;
SInt_16 SampleAsSInt_16(UInt_64 sampleIndex) const;
float SampleAsFloat(const UInt_64 sampleIndex) const;
float SampleAsFloat(UInt_64 sampleIndex) const;
SInt_32 SampleAsSInt_32(const UInt_64 sampleIndex) const;
SInt_32 SampleAsSInt_32(UInt_64 sampleIndex) const;
SInt_64 SampleAsSInt_64(const UInt_64 sampleIndex) const;
SInt_64 SampleAsSInt_64(UInt_64 sampleIndex) const;
SInt_8 PeakAsSInt_8() const;
@@ -106,17 +119,17 @@ namespace ehs
SInt_64 PeakAsSInt_64() const;
void SetPeak(const UInt_64 size, const Byte* newPeak);
void SetPeak(UInt_64 size, const Byte* newPeak);
const Byte* GetPeak() const;
void ToDataType(const DataType newDataType);
void ToDataType(DataType newDataType);
Audio GetAsDataType(const DataType newDataType) const;
Audio GetAsDataType(DataType newDataType) const;
void ToChannels(const UInt_8 newChannels);
void ToChannels(UInt_8 newChannels);
Audio GetAsChannels(const UInt_8 newChannels) const;
Audio GetAsChannels(UInt_8 newChannels) const;
bool ToFile(const Str_8& filePath) const;
@@ -124,32 +137,32 @@ namespace ehs
static Audio* FromFile_Heap(const Str_8& filePath);
static Audio FromFile(const Str_8& filePath, const DataType required);
static Audio FromFile(const Str_8& filePath, DataType required);
static Audio* FromFile_Heap(const Str_8& filePath, const DataType required);
static Audio* FromFile_Heap(const Str_8& filePath, DataType required);
static Audio FromData(const Str_8& ext, const Str_8& id, Serializer<UInt_64>& data);
static Audio FromData(Str_8 id, const Str_8& ext, Serializer<UInt_64>& data);
private:
void ToMono(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void ToMono(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Mono_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Mono_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Five_One_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Five_One_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Seven_One_to_Stereo(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Seven_One_to_Stereo(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Mono_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Mono_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Stereo_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Stereo_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Seven_One_to_Five_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Seven_One_to_Five_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Mono_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Mono_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Stereo_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Stereo_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
void Five_One_to_Seven_One(const UInt_64 newFrameCount, Byte* newData, const UInt_64 frameOffset) const;
void Five_One_to_Seven_One(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
// To SInt_8
void SInt_16_to_SInt_8(Byte* newData, Byte* newPeak) const;

View File

@@ -1,6 +1,7 @@
#pragma once
#include "EHS.h"
#include "Types.h"
#include "BaseObj.h"
#include "Str.h"
#include "ImgCodec.h"
@@ -12,12 +13,14 @@ namespace ehs
NEAREST_NEIGHBOR
};
class Img
class Img : public BaseObj
{
private:
static Array<ImgCodec> codecs;
protected:
UInt_64 hashId;
Str_8 id;
UInt_8 bitDepth;
UInt_8 channels;
UInt_64 width;
@@ -40,9 +43,11 @@ namespace ehs
Img();
Img(UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height, const Byte* data);
Img(Str_8 id);
Img(UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height);
Img(Str_8 id, UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height, const Byte* data);
Img(Str_8 id, UInt_8 bitDepth, UInt_8 channels, UInt_64 width, UInt_64 height);
Img(Img&& img) noexcept;
@@ -58,6 +63,12 @@ namespace ehs
void Release();
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
UInt_8 BitDepth() const;
UInt_8 Channels() const;
@@ -120,7 +131,7 @@ namespace ehs
static Img* FromFile_Heap(const Str_8& filePath);
static Img FromData(const Str_8& ext, Serializer<UInt_64>& data);
static Img FromData(Str_8 id, const Str_8& ext, Serializer<UInt_64>& data);
private:
Img GetNearestNeighbor(UInt_64 newWidth, UInt_64 newHeight) const;

View File

@@ -3,6 +3,7 @@
#include "EHS.h"
#include "Array.h"
#include "Vertex.h"
#include "BaseObj.h"
namespace ehs
{
@@ -38,15 +39,13 @@ namespace ehs
1
});
class Mesh : public Resource
class Mesh final : public BaseObj
{
protected:
UInt_64 hashId;
Str_8 id;
Array<Vertex_f> vertices;
Array<UInt_32> indices;
GpuBuffer srcVertBuffer;
GpuBuffer dstVertBuffer;
GpuBuffer srcIndBuffer;
GpuBuffer dstIndBuffer;
public:
Mesh();
@@ -55,8 +54,6 @@ namespace ehs
Mesh(Str_8 id, Array<Vertex_f> vertices);
Mesh(Str_8 id);
Mesh(Mesh&& mesh) noexcept;
Mesh(const Mesh& mesh);
@@ -65,19 +62,13 @@ namespace ehs
Mesh& operator=(const Mesh& mesh);
bool UploadToGpu(GpuCmdBuffer* cmdBuffer) override;
void Release();
bool PostGpuUpload() override;
UInt_64 GetHashId() const;
bool HasPostGpuUploaded() const override;
void SetId(Str_8 newId);
bool ReleaseFromGpu() override;
bool IsUploaded() const override;
void Bind(GpuCmdBuffer* cmdBuffer);
void Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances = 1);
Str_8 GetId() const;
void SetVertices(const Array<Vertex_f>& newVertices);

View File

@@ -14,9 +14,11 @@ namespace ehs
EHM
};
class Model : public Resource
class Model : public BaseObj
{
protected:
UInt_64 hashId;
Str_8 id;
Array<Mesh> meshes;
Bone skeleton;
Array<Animation> animations;
@@ -40,29 +42,27 @@ namespace ehs
Model& operator=(const Model& model) = default;
bool UploadToGpu(GpuCmdBuffer* cmdBuffer) override;
void Release();
bool PostGpuUpload() override;
UInt_64 GetHashId() const;
bool ReleaseFromGpu() override;
void SetId(Str_8 newId);
bool IsUploaded() const override;
void Draw(GpuCmdBuffer* cmdBuffer, const UInt_32 instances = 1);
Str_8 GetId() const;
Array<Mesh> GetMeshes() const;
Array<Mesh>& GetMeshes();
Mesh* GetMesh(const UInt_64 hashId);
Mesh* GetMesh(UInt_64 inHashId);
Mesh* GetMesh(const Str_8& id);
Mesh* GetMesh(const Str_8& inId);
Bone GetSkeleton() const;
Bone& GetSkeleton();
Animation* GetAnimation(const UInt_64 hashId);
Animation* GetAnimation(UInt_64 inHashId);
Array<Animation> GetAnimations() const;
@@ -70,7 +70,7 @@ namespace ehs
void Calculate();
void Export(const Str_8& filePath, const ModelEncoding encoding);
void Export(const Str_8& filePath, ModelEncoding encoding);
private:
void ToEHM(File& file);

View File

@@ -1,6 +1,7 @@
#pragma once
#include "EHS.h"
#include "Vec4.h"
#include "Vec3.h"
#include "Vec2.h"
#include "Color4.h"

View File

@@ -19,6 +19,8 @@ namespace ehs
class Comms : public BaseObj
{
private:
friend class Endpoint;
static const Version ver;
static const UInt_64 internalSys;
static const UInt_64 connectOp;

View File

@@ -17,7 +17,7 @@ namespace ehs
class Endpoint : public BaseObj
{
private:
Socket hdl;
Comms* owner;
EndDisp disposition;
Status status;
Architecture arch;
@@ -40,10 +40,10 @@ namespace ehs
public:
Endpoint();
Endpoint(const Socket hdl, const EndDisp disposition, const Architecture arch, const Str_8& id,
Endpoint(Comms* owner, const EndDisp disposition, const Architecture arch, const Str_8& id,
const AddrType& type, const Str_8& address, const UInt_16 port);
Endpoint(const Socket hdl, const AddrType& type, const Str_8& address, const UInt_16 port);
Endpoint(Comms* owner, const AddrType& type, const Str_8& address, const UInt_16 port);
Endpoint(const Endpoint& end);