Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move system stuff to the ecs/system directory #649

Merged
merged 7 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ set(CUBOS_CORE_SOURCE
"src/cubos/core/ecs/entity/manager.cpp"
"src/cubos/core/ecs/component/registry.cpp"
"src/cubos/core/ecs/component/manager.cpp"
"src/cubos/core/ecs/commands.cpp"
"src/cubos/core/ecs/system/system.cpp"
"src/cubos/core/ecs/system/dispatcher.cpp"
"src/cubos/core/ecs/system/commands.cpp"
"src/cubos/core/ecs/blueprint.cpp"
"src/cubos/core/ecs/world.cpp"
"src/cubos/core/ecs/system.cpp"
"src/cubos/core/ecs/dispatcher.cpp"
)

# Create core library
Expand Down
2 changes: 1 addition & 1 deletion core/include/cubos/core/ecs/blueprint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <cubos/core/data/old/binary_deserializer.hpp>
#include <cubos/core/data/old/binary_serializer.hpp>
#include <cubos/core/data/old/serialization_map.hpp>
#include <cubos/core/ecs/commands.hpp>
#include <cubos/core/ecs/entity/hash.hpp>
#include <cubos/core/ecs/system/commands.hpp>
#include <cubos/core/memory/buffer_stream.hpp>
#include <cubos/core/memory/type_map.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// @file
/// @brief Class @ref cubos::core::ecs::Read and related types.
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

Expand All @@ -14,7 +14,7 @@ namespace cubos::core::ecs
/// Can be used as a pointer with both the `->` and `*` operators.
///
/// @tparam T Resource or component type.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename T>
class Read
{
Expand Down Expand Up @@ -50,7 +50,7 @@ namespace cubos::core::ecs
/// Can be used as a pointer with both the `->` and `*` operators.
///
/// @tparam T Resource or component type.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename T>
class Write
{
Expand Down Expand Up @@ -87,7 +87,7 @@ namespace cubos::core::ecs
/// Can be used as a pointer with both the `->` and `*` operators.
///
/// @tparam T Resource or component type.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename T>
class OptRead
{
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace cubos::core::ecs
/// Can be used as a pointer with both the `->` and `*` operators.
///
/// @tparam T Resource or component type.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename T>
class OptWrite
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// @file
/// @brief Class @ref cubos::core::ecs::Commands and related types.
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

Expand All @@ -18,7 +18,7 @@ namespace cubos::core::ecs
class Dispatcher;

/// @brief Allows editing an entity created by a @ref Commands object.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
class EntityBuilder final
{
public:
Expand Down Expand Up @@ -54,7 +54,7 @@ namespace cubos::core::ecs
};

/// @brief Used to edit a blueprint spawned by a @ref Commands object.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
class BlueprintBuilder final
{
public:
Expand Down Expand Up @@ -102,11 +102,11 @@ namespace cubos::core::ecs
BlueprintBuilder(data::old::SerializationMap<Entity, std::string, EntityHash>&& map, CommandBuffer& commands);
};

/// @brief Used to write ECS commands and execute them at a later time.
/// @brief System argument used to write ECS commands and execute them at a later time.
///
/// Internally wraps a reference to a CommandBuffer object.
///
/// @ingroup core-ecs
/// @ingroup core-ecs-system
class Commands final
{
public:
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace cubos::core::ecs
};

/// @brief Stores commands to execute them later.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
class CommandBuffer final
{
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// @file
/// @brief Class @ref cubos::core::ecs::Dispatcher.
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

Expand All @@ -10,7 +10,7 @@
#include <utility>
#include <vector>

#include <cubos/core/ecs/system.hpp>
#include <cubos/core/ecs/system/system.hpp>
#include <cubos/core/log.hpp>

#define ENSURE_CURR_SYSTEM() \
Expand Down Expand Up @@ -51,7 +51,7 @@
namespace cubos::core::ecs
{
/// @brief Used to add systems and relations between them and then dispatch them all at once.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
class Dispatcher
{
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// @file
/// @brief Resource @ref cubos::core::ecs::EventPipe.
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

Expand All @@ -15,7 +15,7 @@ namespace cubos::core::ecs
/// @brief Resource which stores events of type @p T.
/// @note This resource is meant to be used through @ref EventReader and @ref EventWriter.
/// @tparam T Event type.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename T>
class EventPipe
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/// @file
/// @brief Class @ref cubos::core::ecs::EventReader.
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

#include <optional>

#include <cubos/core/ecs/event_pipe.hpp>
#include <cubos/core/ecs/system/event/pipe.hpp>

namespace cubos::core::ecs
{
Expand All @@ -18,7 +18,7 @@ namespace cubos::core::ecs
/// @see Systems can send events using @ref EventWriter.
/// @tparam T Event.
/// @tparam M Filter mask.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename T, unsigned int M = DEFAULT_FILTER_MASK>
class EventReader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/// @file
/// @brief Class @ref cubos::core::ecs::EventWriter.
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

#include <cubos/core/ecs/event_pipe.hpp>
#include <cubos/core/ecs/system/event/pipe.hpp>

namespace cubos::core::ecs
{
/// @brief System argument which allows the system to send events of type @p T to other
/// systems.
/// @see Systems can read sent events using @ref EventReader.
/// @tparam T
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename T>
class EventWriter
{
Expand Down
12 changes: 12 additions & 0 deletions core/include/cubos/core/ecs/system/module.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// @dir
/// @brief @ref core-ecs-system directory.

/// @dir event
/// @brief Event system arguments directory.

namespace cubos::core::ecs
{
/// @defgroup core-ecs-system System
/// @ingroup core-ecs
/// @brief System part of the ECS.
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// This file is a bit scary, but it's not as bad as it looks. It's mostly template specializations
/// to handle the different types of arguments a query can take.
///
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

Expand All @@ -13,13 +13,13 @@
#include <unordered_set>
#include <utility>

#include <cubos/core/ecs/accessors.hpp>
#include <cubos/core/ecs/system/accessors.hpp>
#include <cubos/core/ecs/world.hpp>

namespace cubos::core::ecs
{
/// @brief Describes a query.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
struct QueryInfo
{
std::unordered_set<std::type_index> read; ///< Componenst read.
Expand Down Expand Up @@ -89,8 +89,8 @@ namespace cubos::core::ecs
};
} // namespace impl

/// @brief Holds the result of a query over all entities in world which match the given
/// arguments.
/// @brief System argument which holds the result of a query over all entities in world which
/// match the given arguments.
///
/// An example of a valid query is:
///
Expand All @@ -103,7 +103,7 @@ namespace cubos::core::ecs
/// not present in the entity. Whenever mutability is not needed, Read/OptRead should be used.
///
/// @tparam ComponentTypes Component accessor types to be queried.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename... ComponentTypes>
class Query
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
/// This file is a bit scary, but it's not as bad as it looks. It's mostly template specializations
/// to handle the different types of arguments a system can take.
///
/// @ingroup core-ecs
/// @ingroup core-ecs-system

#pragma once

#include <functional>
#include <typeindex>
#include <unordered_set>

#include <cubos/core/ecs/accessors.hpp>
#include <cubos/core/ecs/commands.hpp>
#include <cubos/core/ecs/event_reader.hpp>
#include <cubos/core/ecs/event_writer.hpp>
#include <cubos/core/ecs/query.hpp>
#include <cubos/core/ecs/system/accessors.hpp>
#include <cubos/core/ecs/system/commands.hpp>
#include <cubos/core/ecs/system/event/reader.hpp>
#include <cubos/core/ecs/system/event/writer.hpp>
#include <cubos/core/ecs/system/query.hpp>
#include <cubos/core/ecs/world.hpp>

namespace cubos::core::ecs
{
/// @brief Describes a system.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
struct SystemInfo
{
/// @brief Whether the system uses commands or not.
Expand Down Expand Up @@ -62,7 +62,7 @@ namespace cubos::core::ecs

/// @brief Base class for system wrappers.
/// @tparam R Return type of the wrapped system.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename R>
class AnySystemWrapper
{
Expand Down Expand Up @@ -304,7 +304,7 @@ namespace cubos::core::ecs

/// @brief Wrapper for a system of type @p F.
/// @tparam F Type of the system function/method/lambda.
/// @ingroup core-ecs
/// @ingroup core-ecs-system
template <typename F>
class SystemWrapper final : public AnySystemWrapper<typename impl::SystemTraits<F>::Return>
{
Expand Down
6 changes: 3 additions & 3 deletions core/samples/ecs/events/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cubos/core/ecs/event_pipe.hpp>
#include <cubos/core/ecs/event_reader.hpp>
#include <cubos/core/ecs/event_writer.hpp>
#include <cubos/core/ecs/system/event/pipe.hpp>
#include <cubos/core/ecs/system/event/reader.hpp>
#include <cubos/core/ecs/system/event/writer.hpp>
#include <cubos/core/log.hpp>
#include <cubos/core/memory/stream.hpp>

Expand Down
6 changes: 3 additions & 3 deletions core/samples/ecs/general/main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <iostream>

#include <cubos/core/ecs/blueprint.hpp>
#include <cubos/core/ecs/commands.hpp>
#include <cubos/core/ecs/component/map_storage.hpp>
#include <cubos/core/ecs/component/null_storage.hpp>
#include <cubos/core/ecs/component/registry.hpp>
#include <cubos/core/ecs/component/vec_storage.hpp>
#include <cubos/core/ecs/dispatcher.hpp>
#include <cubos/core/ecs/system.hpp>
#include <cubos/core/ecs/system/commands.hpp>
#include <cubos/core/ecs/system/dispatcher.hpp>
#include <cubos/core/ecs/system/system.hpp>
#include <cubos/core/ecs/world.hpp>

using namespace cubos::core;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <cubos/core/ecs/blueprint.hpp>
#include <cubos/core/ecs/commands.hpp>
#include <cubos/core/ecs/system/commands.hpp>

using namespace cubos::core::ecs;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <algorithm>

#include <cubos/core/ecs/dispatcher.hpp>
#include <cubos/core/ecs/system/dispatcher.hpp>

using namespace cubos::core::ecs;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <cubos/core/ecs/system.hpp>
#include <cubos/core/ecs/system/system.hpp>

using namespace cubos::core::ecs;

Expand Down
2 changes: 1 addition & 1 deletion core/tests/ecs/commands.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <doctest/doctest.h>

#include <cubos/core/ecs/commands.hpp>
#include <cubos/core/ecs/system/commands.hpp>

#include "utils.hpp"

Expand Down
2 changes: 1 addition & 1 deletion core/tests/ecs/dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <doctest/doctest.h>

#include <cubos/core/ecs/dispatcher.hpp>
#include <cubos/core/ecs/system/dispatcher.hpp>

#include "utils.hpp"

Expand Down
2 changes: 1 addition & 1 deletion core/tests/ecs/query.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <doctest/doctest.h>

#include <cubos/core/ecs/query.hpp>
#include <cubos/core/ecs/system/query.hpp>

#include "utils.hpp"

Expand Down
2 changes: 1 addition & 1 deletion core/tests/ecs/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <doctest/doctest.h>

#include <cubos/core/ecs/system.hpp>
#include <cubos/core/ecs/system/system.hpp>

#include "utils.hpp"

Expand Down
Loading
Loading