aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/matrix.hpp
blob: 5a7d893f1063fe6fac47bc959526eab559ff5f9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

#include "interfaces/matrix.hpp"

#include "engine/data/bounds.hpp"
#include "engine/data/vector2.hpp"
#include "engine/matrix_iterator.hpp"

#include <gsl/pointers>

#include <memory>

template <typename Element>
class Matrix : public IMatrix<Element>
{
public:
	explicit Matrix(const Bounds &bounds) noexcept;

	Matrix(const Matrix &matrix) noexcept;

	Matrix(Matrix &&matrix) noexcept;

	~Matrix() noexcept override;

	void fill(Element element) noexcept override;

	[[nodiscard]] auto get(const Vector2 &pos) const noexcept -> Element override;

	void set(const Vector2 &pos, Element element) noexcept override;

	[[nodiscard]] auto get_row_cnt() const noexcept -> uint32_t override;

	[[nodiscard]] auto get_column_cnt() const noexcept -> uint32_t override;

	[[nodiscard]] auto begin() const noexcept -> MatrixIterator<Element> override;

	[[nodiscard]] auto end() const noexcept -> MatrixIterator<Element> override;

	auto operator=(const Matrix &rhs) noexcept -> Matrix &;

	auto operator=(Matrix &&rhs) noexcept -> Matrix &;

private:
	gsl::owner<Element **> _matrix;

	uint32_t _row_cnt;
	uint32_t _column_cnt;

	void _delete_matrix() noexcept;

	void _copy_matrix_from(const Matrix &source) noexcept;
};

#include "matrix.tpp"