StormByte C++ Library: Buffer module 1.2.0
StormByte-Buffer is the buffer module of the StormByte C++ suite.
Loading...
Searching...
No Matches
typedefs.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Buffer.
5 *
6 * StormByte-Buffer is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
9 *
10 * StormByte-Buffer is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte-Buffer. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
18 */
19
20#pragma once
21
23#include <StormByte/logger/log.hxx>
24#include <StormByte/expected.hxx>
25
26#include <cstddef>
27#include <functional>
28#include <memory>
29#include <span>
30#include <vector>
31
36namespace StormByte::Buffer {
37 class Consumer;
38 class Producer;
39 class ReadOnly;
40 class WriteOnly;
41
54
62 using DataType = std::vector<std::byte>;
63
91 enum class STORMBYTE_BUFFER_PUBLIC ExecutionMode : unsigned {
92 Sync = 0,
93 Async = 1u << 0,
94 Parallel = 1u << 1
95 };
96
103 inline constexpr ExecutionMode operator|(ExecutionMode a, ExecutionMode b) noexcept {
104 return static_cast<ExecutionMode>(
105 static_cast<unsigned>(a) | static_cast<unsigned>(b));
106 }
107
114 inline constexpr ExecutionMode operator&(ExecutionMode a, ExecutionMode b) noexcept {
115 return static_cast<ExecutionMode>(
116 static_cast<unsigned>(a) & static_cast<unsigned>(b));
117 }
118
125 inline constexpr ExecutionMode& operator|=(ExecutionMode& a, ExecutionMode b) noexcept {
126 a = a | b;
127 return a;
128 }
129
136 inline constexpr bool HasExecutionFlag(ExecutionMode mode, ExecutionMode flag) noexcept {
137 return (static_cast<unsigned>(mode) & static_cast<unsigned>(flag)) ==
138 static_cast<unsigned>(flag);
139 }
140}
Buffer module of the StormByte suite.
constexpr bool HasExecutionFlag(ExecutionMode mode, ExecutionMode flag) noexcept
Whether mode includes all bits of flag.
Definition typedefs.hxx:136
constexpr ExecutionMode operator|(ExecutionMode a, ExecutionMode b) noexcept
Bitwise OR of execution flags.
Definition typedefs.hxx:103
constexpr ExecutionMode operator&(ExecutionMode a, ExecutionMode b) noexcept
Bitwise AND of execution flags.
Definition typedefs.hxx:114
std::vector< std::byte > DataType
Primary byte storage type used throughout the buffer API.
Definition typedefs.hxx:62
ExecutionMode
Bitmask controlling how Pipeline::Process schedules work.
Definition typedefs.hxx:91
@ Async
Background execution; Process returns immediately.
@ Parallel
One thread per stage (pipeline parallelism).
@ Sync
Sequential on caller thread; Process blocks.
constexpr ExecutionMode & operator|=(ExecutionMode &a, ExecutionMode b) noexcept
Bitwise OR-assignment of execution flags.
Definition typedefs.hxx:125
Position
Forward declaration of the WriteOnly interface.
Definition typedefs.hxx:50
@ Relative
Offset from the current logical read position.
@ Absolute
Offset from the beginning of the buffer (position 0).
#define STORMBYTE_BUFFER_PUBLIC
Definition visibility.h:28