Skip to content

Commit

Permalink
Move matrix related types to base target
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Jul 10, 2024
1 parent 81e25ee commit c9578c3
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 76 deletions.
2 changes: 2 additions & 0 deletions source/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ target_sources(tactile-base
"${PROJECT_SOURCE_DIR}/inc/tactile/base/util/concepts.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/util/format.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/util/hash.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/util/matrix_extent.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/util/matrix_index.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/util/strong_type.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/id.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/int.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

#pragma once

#include <format> // formatter, format_to, formattable
#include <ostream> // ostream
#include <format> // formatter, format_to, formattable

#include "tactile/base/int.hpp"
#include "tactile/base/prelude.hpp"
Expand All @@ -27,18 +26,6 @@ struct MatrixExtent final
auto operator==(const MatrixExtent&) const noexcept -> bool = default;
};

/**
* Outputs a matrix extent to a stream.
*
* \param stream The output stream.
* \param extent The matrix extent to emit.
*
* \return
* The provided stream.
*/
auto operator<<(std::ostream& stream,
const MatrixExtent& extent) -> std::ostream&;

} // namespace tactile

template <>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <cstddef> // size_t
#include <format> // formatter, format_to, formattable
#include <functional> // hash
#include <ostream> // ostream

#include "tactile/base/int.hpp"
#include "tactile/base/prelude.hpp"
Expand All @@ -30,18 +29,6 @@ struct MatrixIndex final
-> bool = default;
};

/**
* Outputs a matrix index to a stream.
*
* \param stream The output stream.
* \param index The matrix index to emit.
*
* \return
* The provided stream.
*/
auto operator<<(std::ostream& stream,
const MatrixIndex& index) -> std::ostream&;

} // namespace tactile

template <>
Expand Down
2 changes: 2 additions & 0 deletions source/base/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ target_sources(tactile-base-test
"${PROJECT_SOURCE_DIR}/src/numeric/vec_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/buffer_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/format_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/matrix_extent_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/matrix_index_test.cpp"
"${PROJECT_SOURCE_DIR}/src/main.cpp"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/core/util/matrix_extent.hpp"
#include "tactile/base/util/matrix_extent.hpp"

#include <format> // format

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/core/util/matrix_index.hpp"
#include "tactile/base/util/matrix_index.hpp"

#include <format> // format

Expand Down
4 changes: 0 additions & 4 deletions source/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ target_sources(tactile-core
"${PROJECT_SOURCE_DIR}/inc/tactile/core/ui/widget_manager.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/core/ui/widget_manager.cpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/core/util/lookup.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/core/util/matrix_extent.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/core/util/matrix_extent.cpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/core/util/matrix_index.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/core/util/matrix_index.cpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/core/util/scope_guard.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/core/util/string_conv.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/core/util/string_conv.cpp"
Expand Down
4 changes: 2 additions & 2 deletions source/core/inc/tactile/core/layer/dense_tile_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "tactile/base/container/vector.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/util/matrix_extent.hpp"
#include "tactile/base/util/matrix_index.hpp"
#include "tactile/core/layer/tile_matrix.hpp"
#include "tactile/core/util/matrix_extent.hpp"
#include "tactile/core/util/matrix_index.hpp"

namespace tactile {

Expand Down
4 changes: 2 additions & 2 deletions source/core/inc/tactile/core/layer/sparse_tile_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "tactile/base/container/hash_map.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/util/matrix_extent.hpp"
#include "tactile/base/util/matrix_index.hpp"
#include "tactile/core/layer/tile_matrix.hpp"
#include "tactile/core/util/matrix_extent.hpp"
#include "tactile/core/util/matrix_index.hpp"

namespace tactile {

Expand Down
4 changes: 2 additions & 2 deletions source/core/inc/tactile/core/layer/tile_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include "tactile/base/container/variant.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/util/matrix_extent.hpp"
#include "tactile/base/util/matrix_index.hpp"
#include "tactile/core/entity/entity.hpp"
#include "tactile/core/layer/dense_tile_matrix.hpp"
#include "tactile/core/layer/sparse_tile_matrix.hpp"
#include "tactile/core/util/matrix_extent.hpp"
#include "tactile/core/util/matrix_index.hpp"

namespace tactile {

Expand Down
2 changes: 1 addition & 1 deletion source/core/inc/tactile/core/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "tactile/base/layer/tile_orientation.hpp"
#include "tactile/base/numeric/vec.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/util/matrix_extent.hpp"
#include "tactile/core/entity/entity.hpp"
#include "tactile/core/util/matrix_extent.hpp"

namespace tactile {

Expand Down
2 changes: 1 addition & 1 deletion source/core/inc/tactile/core/map/map_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "tactile/base/layer/tile_orientation.hpp"
#include "tactile/base/numeric/vec.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/core/util/matrix_extent.hpp"
#include "tactile/base/util/matrix_extent.hpp"

namespace tactile {

Expand Down
2 changes: 1 addition & 1 deletion source/core/inc/tactile/core/tile/tileset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "tactile/base/id.hpp"
#include "tactile/base/numeric/vec.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/util/matrix_extent.hpp"
#include "tactile/core/entity/entity.hpp"
#include "tactile/core/util/matrix_extent.hpp"
#include "tactile/core/util/uuid.hpp"

namespace tactile {
Expand Down
4 changes: 2 additions & 2 deletions source/core/inc/tactile/core/ui/canvas_renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "tactile/base/int.hpp"
#include "tactile/base/numeric/vec.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/util/matrix_extent.hpp"
#include "tactile/base/util/matrix_index.hpp"
#include "tactile/core/entity/entity.hpp"
#include "tactile/core/util/matrix_extent.hpp"
#include "tactile/core/util/matrix_index.hpp"

struct ImDrawList;

Expand Down
2 changes: 1 addition & 1 deletion source/core/inc/tactile/core/ui/render/hexagon_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "tactile/base/container/span.hpp"
#include "tactile/base/numeric/vec.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/core/util/matrix_index.hpp"
#include "tactile/base/util/matrix_index.hpp"

namespace tactile::ui {

Expand Down
14 changes: 0 additions & 14 deletions source/core/src/tactile/core/util/matrix_extent.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions source/core/src/tactile/core/util/matrix_index.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions source/core/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ target_sources(tactile-core-test
"${PROJECT_SOURCE_DIR}/src/ui/imgui_compat_test.cpp"
"${PROJECT_SOURCE_DIR}/src/ui/viewport_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/lookup_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/matrix_extent_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/matrix_index_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/scope_guard_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/string_conv_test.cpp"
"${PROJECT_SOURCE_DIR}/src/util/string_ops_test.cpp"
Expand Down
4 changes: 2 additions & 2 deletions source/core/test/src/layer/tile_matrix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void _validate_tiles(const ITileMatrix& tile_matrix,
for (MatrixExtent::value_type row = 0; row < expected_extent.rows; ++row) {
for (MatrixExtent::value_type col = 0; col < expected_extent.cols; ++col) {
const MatrixIndex index {row, col};
EXPECT_TRUE(tile_matrix.is_valid(index)) << "index is " << index;
EXPECT_TRUE(tile_matrix.is_valid(index));
}
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ TYPED_TEST(TileMatrixTest, SubscriptOperator)
const auto assign_and_check = [&](const MatrixIndex& index,
const TileID tile_id) {
tile_matrix[index] = tile_id;
EXPECT_EQ(tile_matrix[index], tile_id) << "index is " << index;
EXPECT_EQ(tile_matrix[index], tile_id);
};

assign_and_check({0, 0}, TileID {0});
Expand Down

0 comments on commit c9578c3

Please sign in to comment.