aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-06 13:16:05 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:54 +0200
commit0e40bc7ce8c3b3be083002f88c3317d65f6570ad (patch)
tree2fcc470a0f1ce1d51ff26c53c8a9a890b3f31b3b /src/interfaces
parentf4d812a5b9131e65bb55db7211dc68fc453792df (diff)
refactor: make vector2 & bounds data classes
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/bounds.hpp41
-rw-r--r--src/interfaces/matrix.hpp10
-rw-r--r--src/interfaces/vector2.hpp44
3 files changed, 5 insertions, 90 deletions
diff --git a/src/interfaces/bounds.hpp b/src/interfaces/bounds.hpp
deleted file mode 100644
index b431874..0000000
--- a/src/interfaces/bounds.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#pragma once
-
-#include "interfaces/vector2.hpp"
-
-#include <memory>
-
-enum CoordsValidation
-{
- VALID,
- X_HIGH,
- Y_HIGH
-};
-
-class IBounds
-{
-public:
- virtual ~IBounds() = default;
-
- [[nodiscard]] virtual unsigned int width() const = 0;
-
- virtual void width(unsigned int width) = 0;
-
- [[nodiscard]] virtual unsigned int height() const = 0;
-
- virtual void height(unsigned int height) = 0;
-
- [[nodiscard]] virtual CoordsValidation
- validate_coords(const IVector2 &coords) const = 0;
-
- virtual const IBounds &operator*=(const IBounds &bounds) = 0;
- virtual const IBounds &operator+=(const IBounds &bounds) = 0;
- virtual const IBounds &operator-=(const IBounds &bounds) = 0;
-};
-
-struct IBoundsOptions
-{
- unsigned int width;
- unsigned int height;
-};
-
-using IBoundsFactory = std::shared_ptr<IBounds> (*)(const IBoundsOptions &options);
diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp
index 72d18d9..8242b18 100644
--- a/src/interfaces/matrix.hpp
+++ b/src/interfaces/matrix.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include "interfaces/bounds.hpp"
-#include "interfaces/vector2.hpp"
+#include "engine/data/bounds.hpp"
+#include "engine/data/vector2.hpp"
#include <memory>
@@ -23,7 +23,7 @@ public:
*
* @param pos The position of a element
*/
- [[nodiscard]] virtual Element get(const IVector2 &pos) const = 0;
+ [[nodiscard]] virtual Element get(const Vector2 &pos) const = 0;
/**
* Sets a element of the matrix.
@@ -31,7 +31,7 @@ public:
* @param pos The position of a element
* @param element A new element
*/
- virtual void set(const IVector2 &pos, Element element) = 0;
+ virtual void set(const Vector2 &pos, Element element) = 0;
/**
* Returns the number of rows the matrix has.
@@ -45,4 +45,4 @@ public:
};
template <typename Element>
-using IMatrixFactory = std::shared_ptr<IMatrix<Element>> (*)(const IBounds &bounds);
+using IMatrixFactory = std::shared_ptr<IMatrix<Element>> (*)(const Bounds &bounds);
diff --git a/src/interfaces/vector2.hpp b/src/interfaces/vector2.hpp
deleted file mode 100644
index dfd369f..0000000
--- a/src/interfaces/vector2.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma once
-
-#include <memory>
-
-class IVector2
-{
-public:
- virtual ~IVector2() = default;
-
- /**
- * Returns the X coordinate.
- */
- [[nodiscard]] virtual unsigned int x() const = 0;
-
- /**
- * Sets the X coordinate.
- *
- * @param x A new X coordinate
- */
- virtual void x(unsigned int x) = 0;
-
- /**
- * Returns the Y coordinate.
- */
- [[nodiscard]] virtual unsigned int y() const = 0;
-
- /**
- * Sets the Y coordinate.
- *
- * @param Y A new Y coordinate
- */
- virtual void y(unsigned int y) = 0;
-
- virtual const IVector2 &operator+=(const IVector2 &vector2) = 0;
- virtual const IVector2 &operator-=(const IVector2 &vector2) = 0;
-};
-
-struct IVector2Options
-{
- unsigned int x;
- unsigned int y;
-};
-
-using IVector2Factory = std::shared_ptr<IVector2> (*)(const IVector2Options &options);