Răsfoiți Sursa

observer: when -> where (close #265)

Michele Caini 6 ani în urmă
părinte
comite
e088f0f31e
3 a modificat fișierele cu 8 adăugiri și 8 ștergeri
  1. 3 3
      docs/md/entity.md
  2. 3 3
      src/entt/entity/observer.hpp
  3. 2 2
      test/entt/entity/observer.cpp

+ 3 - 3
docs/md/entity.md

@@ -512,10 +512,10 @@ last time one asked.<br/>
 Note that, for a grouping matcher, if an entity already has all the components
 Note that, for a grouping matcher, if an entity already has all the components
 except one and the missing type is assigned to it, it is intercepted.
 except one and the missing type is assigned to it, it is intercepted.
 
 
-In addition, a matcher can be filtered with a `when` clause:
+In addition, a matcher can be filtered with a `where` clause:
 
 
 ```cpp
 ```cpp
-entt::collector.replace<sprite>().when<position>(entt::exclude<velocity>);
+entt::collector.replace<sprite>().where<position>(entt::exclude<velocity>);
 ```
 ```
 
 
 This clause introduces a way to intercept entities if and only if they are
 This clause introduces a way to intercept entities if and only if they are
@@ -526,7 +526,7 @@ the observer probes the entity itself to verify that it has at least `position`
 and has not `velocity` before to store it aside. If one of the two conditions of
 and has not `velocity` before to store it aside. If one of the two conditions of
 the filter isn't respected, the entity is discared, no matter what.
 the filter isn't respected, the entity is discared, no matter what.
 
 
-A `when` clause accepts a theoretically unlimited number of types as well as
+A `where` clause accepts a theoretically unlimited number of types as well as
 multiple elements in the exclusion list. Moreover, every matcher can have it's
 multiple elements in the exclusion list. Moreover, every matcher can have it's
 own clause and multiple clauses for the same matcher are combined in a single
 own clause and multiple clauses for the same matcher are combined in a single
 one.
 one.

+ 3 - 3
src/entt/entity/observer.hpp

@@ -104,7 +104,7 @@ struct basic_collector<matcher<matcher<type_list<Reject...>, type_list<Require..
      * @return The updated collector.
      * @return The updated collector.
      */
      */
     template<typename... AllOf, typename... NoneOf>
     template<typename... AllOf, typename... NoneOf>
-    static constexpr auto when(exclude_t<NoneOf...> = {}) ENTT_NOEXCEPT {
+    static constexpr auto where(exclude_t<NoneOf...> = {}) ENTT_NOEXCEPT {
         return basic_collector<matcher<matcher<type_list<Reject..., NoneOf...>, type_list<Require..., AllOf...>>, Rule...>, Other...>{};
         return basic_collector<matcher<matcher<type_list<Reject..., NoneOf...>, type_list<Require..., AllOf...>>, Rule...>, Other...>{};
     }
     }
 };
 };
@@ -135,8 +135,8 @@ constexpr basic_collector<> collector{};
  * If an entity respects the requirements of multiple matchers, it will be
  * If an entity respects the requirements of multiple matchers, it will be
  * returned once and only once by the observer in any case.
  * returned once and only once by the observer in any case.
  *
  *
- * Matchers support also filtering by means of a _when_ clause that accepts both
- * a list of types and an exclusion list.<br/>
+ * Matchers support also filtering by means of a _where_ clause that accepts
+ * both a list of types and an exclusion list.<br/>
  * Whenever a matcher finds that an entity matches its requirements, the
  * Whenever a matcher finds that an entity matches its requirements, the
  * condition of the filter is verified before to register the entity itself.
  * condition of the filter is verified before to register the entity itself.
  * Moreover, a registered entity isn't returned by the observer if the condition
  * Moreover, a registered entity isn't returned by the observer if the condition

+ 2 - 2
test/entt/entity/observer.cpp

@@ -86,7 +86,7 @@ TEST(Observer, AllOf) {
 
 
 TEST(Observer, AllOfFiltered) {
 TEST(Observer, AllOfFiltered) {
     constexpr auto collector =  entt::collector
     constexpr auto collector =  entt::collector
-            .group<int>().when<char>(entt::exclude<double>);
+            .group<int>().where<char>(entt::exclude<double>);
 
 
     entt::registry registry;
     entt::registry registry;
     entt::observer observer{registry, collector};
     entt::observer observer{registry, collector};
@@ -160,7 +160,7 @@ TEST(Observer, Observe) {
 
 
 TEST(Observer, ObserveFiltered) {
 TEST(Observer, ObserveFiltered) {
     constexpr auto collector =  entt::collector
     constexpr auto collector =  entt::collector
-            .replace<int>().when<char>(entt::exclude<double>);
+            .replace<int>().where<char>(entt::exclude<double>);
 
 
     entt::registry registry;
     entt::registry registry;
     entt::observer observer{registry, collector};
     entt::observer observer{registry, collector};