Skip to content

Commit

Permalink
fix: clarify copy constructor and assignment deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Mar 2, 2024
1 parent 741b8c8 commit 0ea463e
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 22 deletions.
4 changes: 2 additions & 2 deletions core/include/cubos/core/data/des/deserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ namespace cubos::core::data
/// @brief Constructs.
Deserializer() = default;

/// @name Deleted copy and move constructors.
/// @name Forbid any kind of copying.
/// @brief Deleted as the hooks may contain references to the deserializer.
/// @{
Deserializer(Deserializer&&) = delete;
Deserializer(const Deserializer&) = delete;
Deserializer& operator=(const Deserializer&) = delete;
/// @}

/// @brief Function type for deserialization hooks.
Expand Down
7 changes: 4 additions & 3 deletions core/include/cubos/core/data/ser/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ namespace cubos::core::data
/// @brief Default constructs.
Serializer() = default;

/// @brief Forbids copying.
/// @name Forbid any kind of copying.
/// @brief Deleted as the hooks may contain references to the serializer.
/// @{
Serializer(const Serializer&) = delete;

/// @brief Forbids copy assignment.
Serializer& operator=(const Serializer&) = delete;
/// @}

/// @brief Function type for serialization hooks.
using Hook = memory::Function<bool(const void*)>;
Expand Down
24 changes: 24 additions & 0 deletions core/include/cubos/core/ecs/cubos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ namespace cubos::core::ecs
/// @return Reference to this object, for chaining.
TagBuilder(World& world, core::ecs::Dispatcher& dispatcher, std::vector<std::string>& tags);

/// @name Forbid copying.
/// @{
TagBuilder(const TagBuilder&) = delete;
TagBuilder& operator=(const TagBuilder&) = delete;
/// @}

/// @brief Sets the current tag to be executed before another tag.
/// @param tag Tag to be executed before.
/// @return Reference to this object, for chaining.
Expand Down Expand Up @@ -114,6 +120,12 @@ namespace cubos::core::ecs
/// @param argv Argument array.
Cubos(int argc, char** argv);

/// @name Forbid copying.
/// @{
Cubos(const Cubos&) = delete;
Cubos& operator=(const Cubos&) = delete;
/// @}

/// @brief Adds a new plugin to the engine. If the plugin had already been added, nothing
/// happens. A plugin is just a function that operates on the Cubos object, further
/// configuring it. It is useful for separating the code into modules.
Expand Down Expand Up @@ -210,6 +222,12 @@ namespace cubos::core::ecs
/// @param name Debug name.
SystemBuilder(World& world, Dispatcher& dispatcher, std::string name);

/// @name Forbid copying.
/// @{
SystemBuilder(const SystemBuilder&) = delete;
SystemBuilder& operator=(const SystemBuilder&) = delete;
/// @}

/// @brief Adds a tag to the system.
/// @param tag Tag.
/// @return Builder.
Expand Down Expand Up @@ -339,6 +357,12 @@ namespace cubos::core::ecs
/// @param name Debug name.
ObserverBuilder(World& world, std::string name);

/// @name Forbid copying.
/// @{
ObserverBuilder(const ObserverBuilder&) = delete;
ObserverBuilder& operator=(const ObserverBuilder&) = delete;
/// @}

/// @brief Triggers the observer whenever the given component is added to an entity.
/// @param type Component type.
/// @param target Target index. By default, the last specified target or 0.
Expand Down
10 changes: 9 additions & 1 deletion core/include/cubos/core/ecs/resource/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,17 @@ namespace cubos::core::ecs
class CUBOS_CORE_API ResourceManager final
{
public:
ResourceManager() = default;
~ResourceManager();

/// @brief Constructs.
ResourceManager() = default;

/// @name Forbid copying.
/// @{
ResourceManager(const ResourceManager&) = delete;
ResourceManager& operator=(const ResourceManager&) = delete;
/// @}

/// @brief Registers a new resource type in the resource manager.
///
/// This function is not thread-safe and should be called before any other function.
Expand Down
9 changes: 9 additions & 0 deletions core/include/cubos/core/ecs/system/dispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ namespace cubos::core::ecs
public:
~Dispatcher();

/// @brief Constructs.
Dispatcher() = default;

/// @name Forbid copying.
/// @{
Dispatcher(const Dispatcher&) = delete;
Dispatcher& operator=(const Dispatcher&) = delete;
/// @}

/// @brief Adds a tag, and sets it as the current tag for further settings.
/// @param tag Tag to add.
void addTag(const std::string& tag);
Expand Down
6 changes: 6 additions & 0 deletions core/include/cubos/core/ecs/table/dense/registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace cubos::core::ecs
/// @brief Constructs.
DenseTableRegistry();

/// @name Forbid any kind of copying.
/// @{
DenseTableRegistry(const DenseTableRegistry&) = delete;
DenseTableRegistry& operator=(const DenseTableRegistry&) = delete;
/// @}

/// @brief Checks if the given archetype has a dense table.
/// @param archetype Archetype identifier.
/// @return WHether it contains a table or not.
Expand Down
7 changes: 5 additions & 2 deletions core/include/cubos/core/ecs/table/dense/table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ namespace cubos::core::ecs
/// @brief Constructs a table without columns.
DenseTable() = default;

/// @brief Forbid move construction.
DenseTable(DenseTable&&) noexcept = delete;
/// @name Forbid any kind of copying.
/// @{
DenseTable(const DenseTable&) = delete;
DenseTable& operator=(const DenseTable&) = delete;
/// @}

/// @brief Adds a new column to the table.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ namespace cubos::core::ecs
/// @brief Constructs.
SparseRelationTableRegistry();

/// @name Forbid any kind of copying.
/// @{
SparseRelationTableRegistry(const SparseRelationTableRegistry&) = delete;
SparseRelationTableRegistry& operator=(const SparseRelationTableRegistry&) = delete;
/// @}

/// @brief Checks if there's a table with the given identifier.
/// @param id Identifier.
/// @return Whether it contains the table or not.
Expand Down
9 changes: 9 additions & 0 deletions core/include/cubos/core/ecs/table/tables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ namespace cubos::core::ecs
class CUBOS_CORE_API Tables final
{
public:
/// @brief Constructs.
Tables() = default;

/// @name Forbid any kind of copying.
/// @{
Tables(const Tables&) = delete;
Tables& operator=(const Tables&) = delete;
/// @}

/// @brief Gets a reference to the dense table registry.
/// @return Reference to dense table registry.
DenseTableRegistry& dense();
Expand Down
8 changes: 7 additions & 1 deletion core/include/cubos/core/ecs/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ namespace cubos::core::ecs
public:
~World();

/// @brief World constructor.
/// @brief Constructs.
World();

/// @name Forbid copying.
/// @{
World(const World&) = delete;
World& operator=(const World&) = delete;
/// @}

/// @brief Used to access the components in an entity.
class Components;

Expand Down
5 changes: 4 additions & 1 deletion core/include/cubos/core/gl/render_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,11 @@ namespace cubos::core::gl
virtual ~RenderDevice() = default;
RenderDevice() = default;

/// @brief Forbid copy construction.
/// @name Forbid any kind of copying.
/// @{
RenderDevice(const RenderDevice&) = delete;
RenderDevice& operator=(const RenderDevice&) = delete;
/// @}

/// @brief Creates a new framebuffer.
/// @param desc Framebuffer description.
Expand Down
5 changes: 4 additions & 1 deletion core/include/cubos/core/memory/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ namespace cubos::core::memory
/// @brief Move constructs.
Stream(Stream&&) = default;

/// @brief Forbid copy construction.
/// @name Forbid any kind of copying.
/// @{
Stream(const Stream&) = delete;
Stream& operator=(const Stream&) = delete;
/// @}

static Stream& stdIn; ///< Stream wrapper for `stdin`.
static Stream& stdOut; ///< Stream wrapper for `stdout`.
Expand Down
5 changes: 4 additions & 1 deletion core/include/cubos/core/reflection/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ namespace cubos::core::reflection
class CUBOS_CORE_API Type final
{
public:
/// @name Forbid any kind of copying.
/// @{
Type(const Type&) = delete;
Type(Type&&) = delete;
Type& operator=(const Type&) = delete;
/// @}

/// @brief Constructs with a type the given name.
/// @param name Name of the type.
Expand Down
8 changes: 4 additions & 4 deletions core/include/cubos/core/thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ namespace cubos::core
/// @param numThreads Number of threads to create.
ThreadPool(std::size_t numThreads);

/// @brief Forbid copy construction.
/// @name Forbid any kind of copying.
/// @{
ThreadPool(const ThreadPool&) = delete;

/// @brief Forbid move construction.
ThreadPool(ThreadPool&&) = delete;
ThreadPool& operator=(const ThreadPool&) = delete;
/// @}

/// @brief Adds a task to the thread pool. Starts when a thread becomes available.
/// @param task Task to add.
Expand Down
8 changes: 4 additions & 4 deletions engine/include/cubos/engine/assets/assets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ namespace cubos::engine
/// @brief Constructs an empty manager without any bridges or metadata.
Assets();

/// @brief Forbid copying.
/// @name Forbid any kind of copying.
/// @{
Assets(const Assets&) = delete;

/// @brief Forbid moving.
Assets(Assets&&) = delete;
Assets& operator=(const Assets&) = delete;
/// @}

/// @brief Registers a new bridge for the given extension.
///
Expand Down
5 changes: 4 additions & 1 deletion engine/include/cubos/engine/renderer/pps/pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ namespace cubos::engine
/// @param renderDevice Render device to use.
PostProcessingPass(core::gl::RenderDevice& renderDevice);

/// @brief Deleted copy constructor.
/// @name Forbid any kind of copying.
/// @{
PostProcessingPass(const PostProcessingPass&) = delete;
PostProcessingPass& operator=(const PostProcessingPass&) = delete;
/// @}

/// @brief Called when the window framebuffer size changes.
/// @param size New size of the window.
Expand Down
5 changes: 4 additions & 1 deletion engine/include/cubos/engine/renderer/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ namespace cubos::engine
/// @param size Size of the window.
BaseRenderer(core::gl::RenderDevice& renderDevice, glm::uvec2 size);

/// @brief Deleted copy constructor.
/// @name Forbid any kind of copying.
/// @{
BaseRenderer(const BaseRenderer&) = delete;
BaseRenderer& operator=(const BaseRenderer&) = delete;
/// @}

/// @brief Uploads a grid to the GPU and returns an handle which can be used to draw it.
/// @param grid Grid to upload.
Expand Down

0 comments on commit 0ea463e

Please sign in to comment.