From 188692a048b28361f91150b2e93804dfb944bf9c Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 11 Apr 2024 15:29:04 +0200 Subject: codec: Added mixed precision schema and implemented their native data type --- modules/codec/c++/data.hpp | 28 ++++++++++++++++++++++++++++ modules/codec/c++/rpc.hpp | 4 ++-- modules/codec/c++/schema.hpp | 11 ++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) (limited to 'modules/codec/c++') diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index a10ee9d..2adb5b7 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -126,8 +126,36 @@ public: bool operator<(const data, Enc>& rhs) const { return get() < rhs.get(); } + + /** + * Casts + */ + template + data cast_to(){ + auto raw_to = static_cast::type>(value_); + return {raw_to}; + } }; +template +class data, schema::Primitive>, encode::Native>{ +public: + using Schema = schema::MixedPrecision, schema::Primitive>; +private: + data value_; +public: + data():value_{}{} + + data(typename saw::native_data_type::type val__):value_{static_cast::type>(val__)}{} + + typename saw::native_data_type::type get() const { + return value_.template cast_to().get(); + } + + void set(typename saw::native_data_type::type val){ + value_.set(val.template cast_to().get()); + } +}; template class data...>, encode::Native> { diff --git a/modules/codec/c++/rpc.hpp b/modules/codec/c++/rpc.hpp index 9f59455..6b606e2 100644 --- a/modules/codec/c++/rpc.hpp +++ b/modules/codec/c++/rpc.hpp @@ -75,11 +75,11 @@ class remote_address { * Reference Backend structure */ template -class remote_context { +class remote_api { static_assert(always_false, "Type of backend not supported"); /** - * Resolves an address on the remote + * Resolves an address for the remote */ conveyor> resolve_address(); diff --git a/modules/codec/c++/schema.hpp b/modules/codec/c++/schema.hpp index 3c5bce5..3d20c10 100644 --- a/modules/codec/c++/schema.hpp +++ b/modules/codec/c++/schema.hpp @@ -102,7 +102,7 @@ using Float64 = Primitive; /** * Classes allowing to distinguish Ints from VarInts */ -template +template struct VariableLengthPrimitive { static constexpr string_literal name = "VariableLengthPrimitive"; }; @@ -110,6 +110,15 @@ struct VariableLengthPrimitive { using VarInt = VariableLengthPrimitive; using VarLong = VariableLengthPrimitive; +template +struct MixedPrecision { + using InterfaceSchema = PrimA; + using StorageSchema = PrimB; + + static_assert(is_primitive::value, "InterfaceSchema needs to be a Primitive"); + static_assert(is_primitive::value, "StorageSchema needs to be a Primitive"); +}; + /** * Classes enabling Rpc calls */ -- cgit v1.2.3