diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-08-07 12:34:45 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-08-07 12:34:45 +0200 |
| commit | 5d4192c73c72f29debe0f3b6e73889f0204ab74a (patch) | |
| tree | c3b0c1084e3e0642cb986522e6222239669d0f88 /modules/core/c++/abstract/data.hpp | |
| parent | a5c654598544f2a33289664ba73a77343d301ce2 (diff) | |
| parent | 7d094fe719923db5eb6b30edcc4fa01c6ce2cc2e (diff) | |
| download | libs-lbm-5d4192c73c72f29debe0f3b6e73889f0204ab74a.tar.gz | |
Merge branch 'dev'
Diffstat (limited to 'modules/core/c++/abstract/data.hpp')
| -rw-r--r-- | modules/core/c++/abstract/data.hpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/modules/core/c++/abstract/data.hpp b/modules/core/c++/abstract/data.hpp index f1ae5a7..327fb63 100644 --- a/modules/core/c++/abstract/data.hpp +++ b/modules/core/c++/abstract/data.hpp @@ -10,8 +10,97 @@ class data final {}; template<typename T, uint64_t N> class data<sch::Primitive<T,N>,Encode> final { +public: + using Schema = sch::Primitive<T,N>; + using Encode = Encode; private: + native_data_type<Schema>::type value_; public: + data(): + value_{} + {} + + data(native_data_type<Schema>::type value__): + value_{value__} + {} + + constexpr auto get() const { + return value_; + } + + void set(native_data_type value__){ + value_ = value__; + } + + constexpr bool operator==(const data<Schema,Encode>& rhs) const { + return value_ == rhs.value_; + } + + constexpr bool operator!=(const data<Schema,Encode>& rhs) const { + return value_ != rhs.value_; + } + + constexpr bool operator>(const data<Schema,Encode>& rhs) const { + return value_ > rhs.value_; + } + + constexpr bool operator<(const data<Schema,Encode>& rhs) const { + return value_ < rhs.value_; + } + + constexpr bool operator>=(const data<Schema,Encode>& rhs) const { + return value_ >= rhs.value_; + } + + constexpr bool operator<=(const data<Schema,Encode>& rhs) const { + return value_ >= rhs.value_; + } + + constexpr bool equals(const data<Schema,Encode>& rhs) const { + return (*this) == rhs; + } + + data<Schema,Encode> operator+(const data<Schema,Encode>& rhs) const { + return {value_ + rhs.value_}; + } + + data<Schema,Encode> operator-(const data<Schema,Encode>& rhs) const { + return {value_ - rhs.value_}; + } + + data<Schema,Encode> operator*(const data<Schema,Encode>& rhs) const { + return {value_ * rhs.value_}; + } + + data<Schema,Encode> operator/(const data<Schema,Encode>& rhs) const { + return {value_ / rhs.value_}; + } + + data<Schema,Encode>& operator+=(const data<Schema,Encode>& rhs) { + value_ += rhs.value_; + return *this + } + + data<Schema,Encode>& operator-=(const data<Schema,Encode>& rhs) { + value_ -= rhs.value_; + return *this + } + + data<Schema,Encode>& operator*=(const data<Schema,Encode>& rhs) { + value_ *= rhs.value_; + return *this + } + + data<Schema,Encode>& operator/=(const data<Schema,Encode>& rhs) { + value_ /= rhs.value_; + return *this + } + + template<typename T> + data<T,Encode> cast_to() const { + data<T,Encode> val{static_cast<typename native_data_type<T>::type>(value_)}; + return val; + } }; |
