Browse Source

handle: rename ::has/::any to ::all_of/any_of

Michele Caini 5 years ago
parent
commit
e96ac1f6ff
2 changed files with 9 additions and 9 deletions
  1. 2 2
      src/entt/entity/handle.hpp
  2. 7 7
      test/entt/entity/handle.cpp

+ 2 - 2
src/entt/entity/handle.hpp

@@ -225,7 +225,7 @@ struct basic_handle {
      * @return True if the handle has all the components, false otherwise.
      */
     template<typename... Component>
-    [[nodiscard]] decltype(auto) has() const {
+    [[nodiscard]] decltype(auto) all_of() const {
         return reg->template all_of<Component...>(entt);
     }
 
@@ -237,7 +237,7 @@ struct basic_handle {
      * false otherwise.
      */
     template<typename... Component>
-    [[nodiscard]] decltype(auto) any() const {
+    [[nodiscard]] decltype(auto) any_of() const {
         return reg->template any_of<Component...>(entt);
     }
 

+ 7 - 7
test/entt/entity/handle.cpp

@@ -157,7 +157,7 @@ TEST(BasicHandle, Component) {
 
     ASSERT_EQ(42, patched);
     ASSERT_EQ('a', handle.replace<char>('a'));
-    ASSERT_TRUE((handle.has<int, char, double>()));
+    ASSERT_TRUE((handle.all_of<int, char, double>()));
     ASSERT_EQ((std::make_tuple(42, 'a', .3)), (handle.get<int, char, double>()));
 
     handle.remove<char, double>();
@@ -165,10 +165,10 @@ TEST(BasicHandle, Component) {
     ASSERT_TRUE((registry.empty<char, double>()));
     ASSERT_EQ(0u, (handle.remove_if_exists<char, double>()));
 
-    handle.visit([](auto info) { ASSERT_EQ(entt::type_hash<int>::value(), info.hash()); });
+    handle.visit([](auto info) { ASSERT_EQ(entt::type_id<int>(), info); });
 
-    ASSERT_TRUE((handle.any<int, char, double>()));
-    ASSERT_FALSE((handle.has<int, char, double>()));
+    ASSERT_TRUE((handle.any_of<int, char, double>()));
+    ASSERT_FALSE((handle.all_of<int, char, double>()));
     ASSERT_FALSE(handle.orphan());
 
     handle.remove<int>();
@@ -192,11 +192,11 @@ TEST(BasicHandle, RemoveAll) {
 
     ASSERT_EQ(3, handle.emplace<int>(3));
     ASSERT_EQ('c', handle.emplace_or_replace<char>('c'));
-    ASSERT_TRUE((handle.has<int, char>()));
+    ASSERT_TRUE((handle.all_of<int, char>()));
 
     handle.remove_all();
 
-    ASSERT_FALSE((handle.any<int, char>()));
+    ASSERT_FALSE((handle.any_of<int, char>()));
 }
 
 TEST(BasicHandle, FromEntity) {
@@ -210,7 +210,7 @@ TEST(BasicHandle, FromEntity) {
 
     ASSERT_TRUE(handle);
     ASSERT_EQ(entity, handle.entity());
-    ASSERT_TRUE((handle.has<int, char>()));
+    ASSERT_TRUE((handle.all_of<int, char>()));
     ASSERT_EQ(handle.get<int>(), 42);
     ASSERT_EQ(handle.get<char>(), 'c');
 }