From 6833531edb3d3cbb33e68786fcb934b488df8724 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 16 Dec 2023 19:58:17 +0300 Subject: [PATCH] More ecs::accessor docs --- libs/ecs/include/psemek/ecs/accessor.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/ecs/include/psemek/ecs/accessor.hpp b/libs/ecs/include/psemek/ecs/accessor.hpp index 03dbe071..768e5d37 100644 --- a/libs/ecs/include/psemek/ecs/accessor.hpp +++ b/libs/ecs/include/psemek/ecs/accessor.hpp @@ -38,9 +38,18 @@ namespace psemek::ecs struct accessor { + /** Create an invalid accessor, i.e. one that doesn't refer to an entity. + */ accessor() = default; + + /** Copy the accessor. + */ accessor(accessor const &) = default; + /** Check if this accessor is valid, i.e. refers to an entity. + * + * @return True if the accessor is valid, false otherwise + */ explicit operator bool() const; /** Obtain the component of the specified type of the accessed entity. @@ -48,6 +57,7 @@ namespace psemek::ecs * @tparam Component The type of component to obtain * @return A pointer to the component of the specified type, or a null * pointer if the entity doesn't contain a component of this type + * @pre The accessor is valid */ template Component * get_if(); @@ -58,6 +68,7 @@ namespace psemek::ecs * @return A reference to the component of the specified type * @throw component_not_found_exception if the entity doesn't * contain a component of this type + * @pre The accessor is valid */ template Component & get(); @@ -67,6 +78,7 @@ namespace psemek::ecs * @tparam Component The type of component to obtain * @return True if the entity contains a component of the specified * type, false otherwise + * @pre The accessor is valid */ template bool contains() const;