From e16ebb88229b24397c8a3cb44a4f7562890ddea4 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 26 Aug 2023 22:12:25 +0300 Subject: [PATCH] Add some ECS API todo's --- .../include/psemek/ecs/entity_container.hpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/libs/ecs/include/psemek/ecs/entity_container.hpp b/libs/ecs/include/psemek/ecs/entity_container.hpp index f23153a5..7a91b908 100644 --- a/libs/ecs/include/psemek/ecs/entity_container.hpp +++ b/libs/ecs/include/psemek/ecs/entity_container.hpp @@ -19,6 +19,13 @@ namespace psemek::ecs { using query_cache = std::shared_ptr; + using registration_token = std::shared_ptr; + + // TODO: + // - Modification callbacks API + // - Modification callbacks implementation + // - Index API + // - Index implementation struct entity_container { @@ -141,6 +148,36 @@ namespace psemek::ecs template void batch_apply(Function && function, query_cache cache = {}); + /** Register a constructor. Each time an entity is created that has + * the specified set of components (including attaching components), + * the constructor is called for this entity immediately after + * it is created. + * The constructor function must have the same signature as a function + * passed to the `apply()` call. + * The returned value is an ownerwhip token. Destroying it removes + * the constructor from the entity_container. + * If any two of the passed component types are equal, the call fails with + * a compilation error. + */ + // TODO: implement + template + registration_token constructor(Function && function); + + /** Register a destructor. Each time an entity is destroyed that has + * the specified set of components (including detaching components), + * the destructor is called for this entity immediately before + * it will be destroyed. + * The destructor function must have the same signature as a function + * passed to the `apply()` call. + * The returned value is an ownerwhip token. Destroying it removes + * the destructor from the entity_container. + * If any two of the passed component types are equal, the call fails with + * a compilation error. + */ + // TODO: implement + template + registration_token destructor(Function && function); + private: detail::entity_list entity_list_; detail::table_container table_container_;