initial commit

This commit is contained in:
Kbz-8
2025-05-01 23:03:47 +02:00
commit 5eb5821c2a
200 changed files with 434542 additions and 0 deletions

44
ScopEngine/Runtime/Includes/Utils/Ansi.h git.filemode.normal_file
View File

@@ -0,0 +1,44 @@
#ifndef __SCOPE_UTILS_ANSI__
#define __SCOPE_UTILS_ANSI__
#include <cstdint>
#include <ostream>
namespace Scop
{
enum class Ansi : std::uint32_t
{
red = 31,
green = 32,
blue = 34,
def = 0,
black = 30,
yellow = 33,
magenta = 35,
cyan = 36,
white = 37,
bg_red = 41,
bg_green = 42,
bg_blue = 44,
bg_def = 0,
bg_black = 40,
bg_yellow = 43,
bg_magenta = 45,
bg_cyan = 46,
bg_white = 47,
reset = 0,
bold = 1,
underline = 4,
inverse = 7,
bold_off = 21,
underline_off = 24,
inverse_off = 27
};
}
inline std::ostream& operator<<(std::ostream& os, Scop::Ansi ansi)
{
return os << "\033[1;" << std::to_string(static_cast<std::uint32_t>(ansi)) << "m";
}
#endif

46
ScopEngine/Runtime/Includes/Utils/Buffer.h git.filemode.normal_file
View File

@@ -0,0 +1,46 @@
#ifndef __SCOP_CPU_BUFFER__
#define __SCOP_CPU_BUFFER__
#include <cstdint>
#include <cstring>
#include <memory>
#include <Core/Logs.h>
namespace Scop
{
class CPUBuffer
{
public:
CPUBuffer() {}
CPUBuffer(std::size_t size) try : m_data(new std::uint8_t[size]), m_size(size)
{}
catch(...)
{
FatalError("memory allocation for a CPU buffer failed");
}
[[nodiscard]] inline CPUBuffer Duplicate() const
{
CPUBuffer buffer(m_size);
std::memcpy(buffer.GetData(), m_data.get(), m_size);
return buffer;
}
inline bool Empty() const { return m_size == 0; }
[[nodiscard]] inline std::size_t GetSize() const noexcept { return m_size; }
template<typename T>
[[nodiscard]] inline T* GetDataAs() const { return reinterpret_cast<T*>(m_data.get()); }
[[nodiscard]] inline std::uint8_t* GetData() const { return m_data.get(); }
inline operator bool() const { return (bool)m_data; }
~CPUBuffer() = default;
private:
std::shared_ptr<std::uint8_t[]> m_data;
std::size_t m_size = 0;
};
}
#endif

View File

@@ -0,0 +1,20 @@
#ifndef __SCOPE_UTILS_NON_COPYABLE__
#define __SCOPE_UTILS_NON_COPYABLE__
namespace Scop
{
class NonCopyable
{
protected:
NonCopyable() = default;
virtual ~NonCopyable() = default;
public:
NonCopyable(const NonCopyable&) = delete;
NonCopyable(NonCopyable&&) noexcept = default;
NonCopyable& operator=(const NonCopyable&) = delete;
NonCopyable& operator=(NonCopyable&&) noexcept = default;
};
}
#endif

View File

@@ -0,0 +1,20 @@
#ifndef __SCOPE_UTILS_NON_MOVABLE__
#define __SCOPE_UTILS_NON_MOVABLE__
namespace Scop
{
class NonMovable
{
protected:
NonMovable() = default;
virtual ~NonMovable() = default;
public:
NonMovable(const NonMovable&) = default;
NonMovable(NonMovable&&) noexcept = delete;
NonMovable& operator=(const NonMovable&) = default;
NonMovable& operator=(NonMovable&&) noexcept = delete;
};
}
#endif

View File

@@ -0,0 +1,33 @@
#ifndef __SCOPE_UTILS_NON_OWNING_PTR__
#define __SCOPE_UTILS_NON_OWNING_PTR__
namespace Scop
{
template<typename T>
class NonOwningPtr
{
public:
NonOwningPtr(T* ptr = nullptr);
NonOwningPtr(const NonOwningPtr&) = default;
NonOwningPtr(NonOwningPtr&& ptr) noexcept;
NonOwningPtr& operator=(T* ptr);
NonOwningPtr& operator=(const NonOwningPtr&) = default;
NonOwningPtr& operator=(NonOwningPtr&& ptr) noexcept;
[[nodiscard]] inline operator bool() const noexcept;
[[nodiscard]] inline T* Get() const noexcept;
[[nodiscard]] inline T* operator->() const noexcept;
[[nodiscard]] inline T& operator*() const noexcept;
~NonOwningPtr() = default;
private:
T* m_ptr = nullptr;
};
}
#include <Utils/NonOwningPtr.inl>
#endif

View File

@@ -0,0 +1,53 @@
#pragma once
#include <Utils/NonOwningPtr.h>
namespace Scop
{
template<typename T>
NonOwningPtr<T>::NonOwningPtr(T* ptr) : m_ptr(ptr) {}
template<typename T>
NonOwningPtr<T>::NonOwningPtr(NonOwningPtr<T>&& ptr) noexcept : m_ptr(ptr.m_ptr)
{
ptr.m_ptr = nullptr;
}
template<typename T>
NonOwningPtr<T>& NonOwningPtr<T>::operator=(T* ptr)
{
m_ptr = ptr;
return *this;
}
template<typename T>
NonOwningPtr<T>& NonOwningPtr<T>::operator=(NonOwningPtr&& ptr) noexcept
{
m_ptr = ptr.m_ptr;
ptr.m_ptr = nullptr;
return *this;
}
template<typename T>
NonOwningPtr<T>::operator bool() const noexcept
{
return m_ptr != nullptr;
}
template<typename T>
T* NonOwningPtr<T>::Get() const noexcept
{
return m_ptr;
}
template<typename T>
T* NonOwningPtr<T>::operator->() const noexcept
{
return m_ptr;
}
template<typename T>
T& NonOwningPtr<T>::operator*() const noexcept
{
return *m_ptr;
}
}