summaryrefslogtreecommitdiff
path: root/modules/core/c++/abstract/data.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/c++/abstract/data.hpp')
-rw-r--r--modules/core/c++/abstract/data.hpp89
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;
+ }
};