aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/matrix_iterator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/graphics/matrix_iterator.hpp')
-rw-r--r--src/engine/graphics/matrix_iterator.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/engine/graphics/matrix_iterator.hpp b/src/engine/graphics/matrix_iterator.hpp
new file mode 100644
index 0000000..70a59bf
--- /dev/null
+++ b/src/engine/graphics/matrix_iterator.hpp
@@ -0,0 +1,65 @@
+#pragma once
+
+#include <gsl/pointers>
+
+template <typename Element>
+class MatrixRowIterator
+{
+public:
+ using ColumnPtr = gsl::owner<Element *>;
+
+ explicit MatrixRowIterator(ColumnPtr column_ptr) noexcept;
+
+ auto operator++() noexcept -> MatrixRowIterator &;
+ auto operator++(int) noexcept -> MatrixRowIterator;
+
+ auto operator*() const noexcept -> Element &;
+
+ auto operator==(const MatrixRowIterator &rhs) const noexcept -> bool;
+ auto operator!=(const MatrixRowIterator &rhs) const noexcept -> bool;
+
+private:
+ ColumnPtr _column_ptr;
+};
+
+template <typename Element>
+class MatrixRow
+{
+public:
+ using RowPtr = gsl::owner<Element *>;
+
+ explicit MatrixRow(RowPtr row_ptr, const uint32_t &column_cnt) noexcept;
+
+ [[nodiscard]] auto begin() const noexcept -> MatrixRowIterator<Element>;
+
+ [[nodiscard]] auto end() const noexcept -> MatrixRowIterator<Element>;
+
+private:
+ RowPtr _row_ptr;
+
+ const uint32_t &_column_cnt;
+};
+
+template <typename Element>
+class MatrixIterator
+{
+public:
+ using RowPtr = gsl::owner<Element **>;
+
+ explicit MatrixIterator(RowPtr row_ptr, const uint32_t &column_cnt) noexcept;
+
+ auto operator++() noexcept -> MatrixIterator &;
+ auto operator++(int) noexcept -> MatrixIterator;
+
+ auto operator*() const noexcept -> MatrixRow<Element>;
+
+ auto operator==(const MatrixIterator &rhs) const noexcept -> bool;
+ auto operator!=(const MatrixIterator &rhs) const noexcept -> bool;
+
+private:
+ RowPtr _row_ptr;
+
+ const uint32_t &_column_cnt;
+};
+
+#include "matrix_iterator_impl.hpp"