Browse Source

entity module: added utility.hpp, cleaned up fwd.hpp

Michele Caini 6 years ago
parent
commit
1e962754cc

+ 4 - 0
src/entt/entity/entity.hpp

@@ -159,6 +159,10 @@ constexpr bool operator!=(const Entity entity, null other) ENTT_NOEXCEPT {
  */
 
 
+/*! @brief Alias declaration for the most common use case. */
+ENTT_OPAQUE_TYPE(entity, ENTT_ID_TYPE);
+
+
 /**
  * @brief Compile-time constant for null entities.
  *

+ 1 - 34
src/entt/entity/fwd.hpp

@@ -3,44 +3,11 @@
 
 
 #include "../config/config.h"
-#include "../core/type_traits.hpp"
 
 
 namespace entt {
 
 
-/**
- * @brief Alias for exclusion lists.
- * @tparam Type List of types.
- */
-template<typename... Type>
-struct exclude_t: type_list<Type...> {};
-
-
-/**
- * @brief Variable template for exclusion lists.
- * @tparam Type List of types.
- */
-template<typename... Type>
-constexpr exclude_t<Type...> exclude{};
-
-
-/**
- * @brief Alias for lists of observed components.
- * @tparam Type List of types.
- */
-template<typename... Type>
-struct get_t: type_list<Type...>{};
-
-
-/**
- * @brief Variable template for lists of observed components.
- * @tparam Type List of types.
- */
-template<typename... Type>
-constexpr get_t<Type...> get{};
-
-
 /*! @class basic_registry */
 template <typename>
 class basic_registry;
@@ -78,7 +45,7 @@ template<typename>
 class basic_continuous_loader;
 
 /*! @brief Alias declaration for the most common use case. */
-ENTT_OPAQUE_TYPE(entity, ENTT_ID_TYPE);
+enum class entity: ENTT_ID_TYPE;
 
 /*! @brief Alias declaration for the most common use case. */
 using registry = basic_registry<entity>;

+ 2 - 0
src/entt/entity/group.hpp

@@ -9,6 +9,8 @@
 #include "../core/type_traits.hpp"
 #include "sparse_set.hpp"
 #include "storage.hpp"
+#include "utility.hpp"
+#include "entity.hpp"
 #include "fwd.hpp"
 
 

+ 1 - 0
src/entt/entity/observer.hpp

@@ -11,6 +11,7 @@
 #include "../core/type_traits.hpp"
 #include "registry.hpp"
 #include "storage.hpp"
+#include "utility.hpp"
 #include "entity.hpp"
 #include "fwd.hpp"
 

+ 1 - 0
src/entt/entity/registry.hpp

@@ -19,6 +19,7 @@
 #include "sparse_set.hpp"
 #include "snapshot.hpp"
 #include "storage.hpp"
+#include "utility.hpp"
 #include "entity.hpp"
 #include "group.hpp"
 #include "view.hpp"

+ 0 - 1
src/entt/entity/runtime_view.hpp

@@ -9,7 +9,6 @@
 #include <type_traits>
 #include "../config/config.h"
 #include "sparse_set.hpp"
-#include "entity.hpp"
 #include "fwd.hpp"
 
 

+ 46 - 0
src/entt/entity/utility.hpp

@@ -0,0 +1,46 @@
+#ifndef ENTT_ENTITY_UTILITY_HPP
+#define ENTT_ENTITY_UTILITY_HPP
+
+
+#include "../core/type_traits.hpp"
+
+
+namespace entt {
+
+
+/**
+ * @brief Alias for exclusion lists.
+ * @tparam Type List of types.
+ */
+template<typename... Type>
+struct exclude_t: type_list<Type...> {};
+
+
+/**
+ * @brief Variable template for exclusion lists.
+ * @tparam Type List of types.
+ */
+template<typename... Type>
+constexpr exclude_t<Type...> exclude{};
+
+
+/**
+ * @brief Alias for lists of observed components.
+ * @tparam Type List of types.
+ */
+template<typename... Type>
+struct get_t: type_list<Type...>{};
+
+
+/**
+ * @brief Variable template for lists of observed components.
+ * @tparam Type List of types.
+ */
+template<typename... Type>
+constexpr get_t<Type...> get{};
+
+
+}
+
+
+#endif

+ 1 - 1
src/entt/entity/view.hpp

@@ -12,6 +12,7 @@
 #include "../core/type_traits.hpp"
 #include "sparse_set.hpp"
 #include "storage.hpp"
+#include "utility.hpp"
 #include "entity.hpp"
 #include "fwd.hpp"
 
@@ -76,7 +77,6 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
     using underlying_iterator_type = typename sparse_set<Entity>::iterator_type;
     using unchecked_type = std::array<const sparse_set<Entity> *, (sizeof...(Component) - 1)>;
     using filter_type = std::array<const sparse_set<Entity> *, sizeof...(Exclude)>;
-    using traits_type = entt_traits<std::underlying_type_t<Entity>>;
 
     class iterator {
         friend class basic_view<Entity, exclude_t<Exclude...>, Component...>;

+ 1 - 0
src/entt/entt.hpp

@@ -17,6 +17,7 @@
 #include "entity/snapshot.hpp"
 #include "entity/sparse_set.hpp"
 #include "entity/storage.hpp"
+#include "entity/utility.hpp"
 #include "entity/view.hpp"
 #include "locator/locator.hpp"
 #include "meta/factory.hpp"