GridFormat 0.4.0
I/O-Library for grid-like data structures
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022-2023 Dennis Gläser <dennis.glaeser@iws.uni-stuttgart.de>
2// SPDX-License-Identifier: MIT
8#ifndef GRIDFORMAT_COMPRESSION_CONCEPTS_HPP_
9#define GRIDFORMAT_COMPRESSION_CONCEPTS_HPP_
10
11#include <span>
12#include <ranges>
13#include <concepts>
14#include <type_traits>
15
16#include <gridformat/common/serialization.hpp>
18
19namespace GridFormat::Concepts {
20
23
24#ifndef DOXYGEN
25namespace CompressionDetail {
26
27 template<typename T>
28 struct IsCompressedBlocks : public std::false_type {};
29 template<typename Header>
30 struct IsCompressedBlocks<Compression::CompressedBlocks<Header>> : public std::true_type {};
31
32 template<typename T>
33 concept ValidCompressionResult = IsCompressedBlocks<T>::value;
34
35} // namespace CompressionDetail
36#endif // DOXYGEN
37
39template<typename T>
40concept Compressor = requires(const T& t, Serialization& s) {
41 { t.compress(s) } -> CompressionDetail::ValidCompressionResult;
42};
43
45template<typename T>
46concept Decompressor = requires(const T& t,
47 Serialization& s,
48 const Compression::CompressedBlocks<std::size_t>& b) {
49 { t.decompress(s, b) };
50};
51
53template<typename T>
55 = requires { typename T::ByteType; }
56 and std::invocable<T, std::span<const typename T::ByteType>, std::span<typename T::ByteType>>;
57
59
60} // namespace GridFormat::Concepts
61
62#endif // GRIDFORMAT_COMPRESSION_CONCEPTS_HPP_
Common classes used in the context of data compression.
Concept that block decompressors must fulfill.
Definition: concepts.hpp:55
Concept that compressors must fulfill.
Definition: concepts.hpp:40
Concept that decompressors must fulfill.
Definition: concepts.hpp:46