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

fix/improve some comments, group add and remove functions #1054

Merged
merged 4 commits into from
Oct 3, 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
71 changes: 37 additions & 34 deletions flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19785,6 +19785,7 @@ struct world {
flecs::entity set_scope() const;

/** Set search path.
* @see ecs_set_lookup_path
*/
flecs::entity_t* set_lookup_path(const flecs::entity_t *search_path) const {
return ecs_set_lookup_path(m_world, search_path);
Expand Down Expand Up @@ -19948,23 +19949,23 @@ struct world {
template <typename T>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @tparam Second The second element of the pair
*/
template <typename First, typename Second>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
*/
template <typename First>
void remove(flecs::entity_t second) const;

/** Adds a pair to the singleton entity.
/** Removes the pair singleton component.
*
* @param first The first element of the pair
* @param second The second element of the pair
Expand Down Expand Up @@ -22384,6 +22385,23 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Add an entity to an entity.
* Add an entity to the entity. This is typically used for tagging.
*
Expand Down Expand Up @@ -22630,6 +22648,17 @@ struct entity_builder : entity_view {
return to_base();
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Remove an entity from an entity.
*
* @param entity The entity to remove.
Expand Down Expand Up @@ -22662,7 +22691,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
Expand All @@ -22684,7 +22713,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param constant the enum constant.
Expand Down Expand Up @@ -22856,34 +22885,6 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Enable an entity.
* Enabled entities are matched with systems and can be searched with
* queries.
Expand Down Expand Up @@ -23236,6 +23237,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have the current entity.
* This operation is thread safe.
*
* @param func The function to call.
*/
Expand All @@ -23260,6 +23262,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have (first, this).
* This operation is thread safe.
*
* @param first The first element of the pair.
* @param func The function to call.
Expand Down Expand Up @@ -23578,7 +23581,7 @@ struct entity : entity_builder<entity>
_::cpp_type<Second>::id(m_world))));
}

/** Get mutable pointer for a pair.
/** Get mutable pointer for the first element of a pair.
* This operation gets the value for a pair from the entity.
*
* @tparam First The first part of the pair.
Expand Down
2 changes: 1 addition & 1 deletion include/flecs/addons/cpp/entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct entity : entity_builder<entity>
_::cpp_type<Second>::id(m_world))));
}

/** Get mutable pointer for a pair.
/** Get mutable pointer for the first element of a pair.
* This operation gets the value for a pair from the entity.
*
* @tparam First The first part of the pair.
Expand Down
62 changes: 32 additions & 30 deletions include/flecs/addons/cpp/mixins/entity/builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Add an entity to an entity.
* Add an entity to the entity. This is typically used for tagging.
*
Expand Down Expand Up @@ -275,6 +292,17 @@ struct entity_builder : entity_view {
return to_base();
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Remove an entity from an entity.
*
* @param entity The entity to remove.
Expand Down Expand Up @@ -307,7 +335,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
Expand All @@ -329,7 +357,7 @@ struct entity_builder : entity_view {
}

/** Remove a pair.
* This operation adds a pair to the entity.
* This operation removes the pair from the entity.
*
* @tparam First The first element of the pair
* @param constant the enum constant.
Expand Down Expand Up @@ -501,34 +529,6 @@ struct entity_builder : entity_view {
return to_base();
}

/** Add pair for enum constant.
* This operation will add a pair to the entity where the first element is
* the enumeration type, and the second element the enumeration constant.
*
* The operation may be used with regular (C style) enumerations as well as
* enum classes.
*
* @param value The enumeration value.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
const auto& et = enum_type<E>(this->m_world);
flecs::entity_t second = et.entity(value);
return this->add(first, second);
}

/** Remove pair for enum.
* This operation will remove any (Enum, *) pair from the entity.
*
* @tparam E The enumeration type.
*/
template <typename E, if_t< is_enum<E>::value > = 0>
Self& remove() {
flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
return this->remove(first, flecs::Wildcard);
}

/** Enable an entity.
* Enabled entities are matched with systems and can be searched with
* queries.
Expand Down Expand Up @@ -881,6 +881,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have the current entity.
* This operation is thread safe.
*
* @param func The function to call.
*/
Expand All @@ -905,6 +906,7 @@ struct entity_builder : entity_view {
}

/** Entities created in function will have (first, this).
* This operation is thread safe.
*
* @param first The first element of the pair.
* @param func The function to call.
Expand Down
7 changes: 4 additions & 3 deletions include/flecs/addons/cpp/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ struct world {
flecs::entity set_scope() const;

/** Set search path.
* @see ecs_set_lookup_path
*/
flecs::entity_t* set_lookup_path(const flecs::entity_t *search_path) const {
return ecs_set_lookup_path(m_world, search_path);
Expand Down Expand Up @@ -706,23 +707,23 @@ struct world {
template <typename T>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @tparam Second The second element of the pair
*/
template <typename First, typename Second>
void remove() const;

/** Adds a pair to the singleton component.
/** Removes the pair singleton component.
*
* @tparam First The first element of the pair
* @param second The second element of the pair.
*/
template <typename First>
void remove(flecs::entity_t second) const;

/** Adds a pair to the singleton entity.
/** Removes the pair singleton component.
*
* @param first The first element of the pair
* @param second The second element of the pair
Expand Down