diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-09-01 15:05:08 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-09-01 15:05:08 +0200 |
commit | f5c90428f833a0af26d20488f230a69e82891673 (patch) | |
tree | 56370aff52fbd2d67385748e4e64307af4d63909 /modules/codec-unit | |
parent | 55f9635f8818614d1c0e5f2dbfc6eb3de18a7107 (diff) |
Fixing deps on modules and adding minor unit logic
Diffstat (limited to 'modules/codec-unit')
-rw-r--r-- | modules/codec-unit/.nix/derivation.nix | 1 | ||||
-rw-r--r-- | modules/codec-unit/c++/unit.hpp | 25 | ||||
-rw-r--r-- | modules/codec-unit/c++/unit.tmpl.hpp | 1 | ||||
-rw-r--r-- | modules/codec-unit/c++/unit_schema.hpp | 16 | ||||
-rw-r--r-- | modules/codec-unit/c++/unit_transform.hpp | 19 |
5 files changed, 61 insertions, 1 deletions
diff --git a/modules/codec-unit/.nix/derivation.nix b/modules/codec-unit/.nix/derivation.nix index a66450e..eaba6bc 100644 --- a/modules/codec-unit/.nix/derivation.nix +++ b/modules/codec-unit/.nix/derivation.nix @@ -22,7 +22,6 @@ in stdenv.mkDerivation { buildInputs = [ forstio.core - forstio.async forstio.codec ]; diff --git a/modules/codec-unit/c++/unit.hpp b/modules/codec-unit/c++/unit.hpp new file mode 100644 index 0000000..986ca8f --- /dev/null +++ b/modules/codec-unit/c++/unit.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "unit_schema.hpp" +#include "unit_transform.hpp" + +namespace saw { +template<typename BaseSchema, typename... Elements> +class data<schema::Unit<BaseSchema, Elements...>, encode::Native> { +public: + using Schema = schema::Unit<BaseSchema, Elements...>; +private: + data<BaseSchema, encode::Native> dat_; +public: + data() = default; + + data(data<BaseSchema, encode::Native>&& dat__): + dat_{std::move(dat__)} + {} + + data<Schema, encode::Native> operator+(const data<Schema, encode::Native>& rhs) const; + data<Schema, encode::Native> operator-(const data<Schema, encode::Native>& rhs) const; +}; +} + +#include "unit.tmpl.h" diff --git a/modules/codec-unit/c++/unit.tmpl.hpp b/modules/codec-unit/c++/unit.tmpl.hpp new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/modules/codec-unit/c++/unit.tmpl.hpp @@ -0,0 +1 @@ + diff --git a/modules/codec-unit/c++/unit_schema.hpp b/modules/codec-unit/c++/unit_schema.hpp new file mode 100644 index 0000000..9ad173f --- /dev/null +++ b/modules/codec-unit/c++/unit_schema.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include <forstio/codec/schema.hpp> + +namespace saw { +namespace schema { +template<typename Unit, int64_t Exponent> +struct UnitElement {}; + +template<typename BaseSchema, typename ... Components> +struct Unit {}; + +template<typename BaseSchema> +using Scalar = Unit<BaseSchema>; +} +} diff --git a/modules/codec-unit/c++/unit_transform.hpp b/modules/codec-unit/c++/unit_transform.hpp new file mode 100644 index 0000000..6f40df5 --- /dev/null +++ b/modules/codec-unit/c++/unit_transform.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include <type_traits> +#include "unit_schema.hpp" + +namespace saw { +namespace impl { + +template<typename T, typename U> +class unit_matching; + +template<typename... T> +class unit_redux_list { + static_assert(sizeof...(T) == 0u, "Template type not supported"); + + using reduced_type = unit_redux_list<>; +}; +} +} |