From 504df182744320a75b97020b2a302124736f1735 Mon Sep 17 00:00:00 2001 From: Arron Nelson Date: Sat, 11 Jan 2025 14:02:13 -0800 Subject: [PATCH] Backup. --- include/ehs/SPV.h | 140 ++++++++++++++++++++++++++++++++++++++++++--- include/ehs/SPVE.h | 38 ++++++++++-- 2 files changed, 163 insertions(+), 15 deletions(-) diff --git a/include/ehs/SPV.h b/include/ehs/SPV.h index 772ccb2..0e9617e 100644 --- a/include/ehs/SPV.h +++ b/include/ehs/SPV.h @@ -1,24 +1,146 @@ #pragma once + +#include "Log.h" #include "Types.h" +#include "Vector.h" +#include "SPVE.h" namespace ehs { - template - class SPVE; - - template + template class SPV { private: - Size size; - Size rawSize; - Size stride; + friend class SPVE; + + static Vector vectors; + + static bool HasVector(T *vector) + { + for (Size i = vectors.Size(); i; --i) + { + if (vectors[i] != vector) + continue; + + EHS_LOG_SUCCESS(); + + return true; + } + + EHS_LOG_SUCCESS(); + + return false; + } + + static bool AddVector(T *vector) + { + if (HasVector(vector)) + { + EHS_LOG_INT(LogType::ERR, 0, "SPV already exists, and is a critical error!"); + + return false; + } + + vectors.PushBack(vector); + + EHS_LOG_SUCCESS(); + + return true; + } + + static bool UpdateVector(T *oldVect, T *newVect) + { + for (Size i = vectors.Size(); i; --i) + { + if (vectors[i] != oldVect) + continue; + + vectors[i] = newVect; + + EHS_LOG_SUCCESS(); + + return true; + } + + EHS_LOG_INT(LogType::ERR, 0, "Attempted to update SPV but doesn't exist and is a critical error!"); + + return false; + } + + static bool RemoveVector(T *vector) + { + for (Size i = 0; i < vectors.Size(); ++i) + { + if (vectors[i] != vector) + continue; + + EHS_LOG_SUCCESS(); + + return true; + } + + EHS_LOG_SUCCESS(); + + return false; + } + + N size; + N stride; + N rawSize; T *data; public: - SPV(); + SPV() + { + } - SPVE operator[](Size index) + SPV(N size) + : size(size), stride(5), rawSize(size + stride), data(new T[rawSize]) + { + AddVector(data); + } + + SPV(N size, N stride) + : size(size), stride(stride), rawSize(size + stride), data(new T[rawSize]) + { + AddVector(data); + } + + SPV(SPV &&spv) noexcept + : size(spv.size), stride(spv.stride), rawSize(spv.rawSize), data(spv.data) + { + spv.size = 0; + spv.stride = 0; + spv.rawSize = 0; + spv.data = nullptr; + } + + SPV(const SPV &spv) + : size(spv.size), stride(spv.stride), rawSize(spv.rawSize), data(new T[rawSize]) + { + for (N i = 0; i < size; ++i) + data[i] = spv.data[i]; + + AddVector(data); + } + + SPV &operator=(SPV &&spv) noexcept + { + if (this == &spv) + return *this; + + return *this; + } + + SPV &operator=(const SPV &spv) + { + if (this == &spv) + return *this; + + return *this; + } + + SPVE operator[](N index) { return SPVE(data[index]); } diff --git a/include/ehs/SPVE.h b/include/ehs/SPVE.h index e6725ca..db13e9d 100644 --- a/include/ehs/SPVE.h +++ b/include/ehs/SPVE.h @@ -1,5 +1,7 @@ #pragma once +#include "SPV.h" + namespace ehs { template @@ -10,16 +12,40 @@ namespace ehs T *value; public: - SPVE(); + SPVE() + { + } - SPVE(T *value); + SPVE(T *value) + { + } - SPVE(SPVE &&spve) noexcept; + SPVE(SPVE &&spve) noexcept + { + } - SPVE(const SPVE &spve); + SPVE(const SPVE &spve) + { + } - SPVE &operator=(SPVE &&spve) noexcept; + SPVE &operator=(SPVE &&spve) noexcept + { + return *this; + } - SPVE &operator=(const SPVE &spve); + SPVE &operator=(const SPVE &spve) + { + return *this; + } + + SPV *GetOwner() const + { + return owner; + } + + T *GetValue() const + { + return value; + } }; } \ No newline at end of file