|
|
@@ -13,6 +13,13 @@
|
|
|
namespace entt {
|
|
|
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Forward declaration of the registry class.
|
|
|
+ */
|
|
|
+template<typename>
|
|
|
+class Registry;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @brief Persistent view.
|
|
|
*
|
|
|
@@ -56,12 +63,19 @@ template<typename Entity, typename... Component>
|
|
|
class PersistentView final {
|
|
|
static_assert(sizeof...(Component) > 1, "!");
|
|
|
|
|
|
+ /*! @brief A registry is allowed to create views. */
|
|
|
+ friend class Registry<Entity>;
|
|
|
+
|
|
|
template<typename Comp>
|
|
|
using pool_type = SparseSet<Entity, Comp>;
|
|
|
|
|
|
using view_type = SparseSet<Entity>;
|
|
|
using pattern_type = std::tuple<pool_type<Component> &...>;
|
|
|
|
|
|
+ PersistentView(view_type &view, pool_type<Component> &... pools) noexcept
|
|
|
+ : view{view}, pools{pools...}
|
|
|
+ {}
|
|
|
+
|
|
|
public:
|
|
|
/*! Input iterator type. */
|
|
|
using iterator_type = typename view_type::iterator_type;
|
|
|
@@ -70,22 +84,6 @@ public:
|
|
|
/*! @brief Unsigned integer type. */
|
|
|
using size_type = typename view_type::size_type;
|
|
|
|
|
|
- /**
|
|
|
- * @brief Constructs a persistent view around a dedicated pool of entities.
|
|
|
- *
|
|
|
- * A persistent view is created out of:
|
|
|
- *
|
|
|
- * * A dedicated pool of entities that is shared between all the persistent
|
|
|
- * views of the same type.
|
|
|
- * * A bunch of pools of components to which to refer to get instances.
|
|
|
- *
|
|
|
- * @param view Shared reference to a dedicated pool of entities.
|
|
|
- * @param pools References to pools of components.
|
|
|
- */
|
|
|
- PersistentView(view_type &view, pool_type<Component> &... pools) noexcept
|
|
|
- : view{view}, pools{pools...}
|
|
|
- {}
|
|
|
-
|
|
|
/**
|
|
|
* @brief Returns the number of entities that have the given components.
|
|
|
* @return Number of entities that have the given components.
|
|
|
@@ -350,6 +348,9 @@ template<typename Entity, typename... Component>
|
|
|
class View final {
|
|
|
static_assert(sizeof...(Component) > 1, "!");
|
|
|
|
|
|
+ /*! @brief A registry is allowed to create views. */
|
|
|
+ friend class Registry<Entity>;
|
|
|
+
|
|
|
template<typename Comp>
|
|
|
using pool_type = SparseSet<Entity, Comp>;
|
|
|
|
|
|
@@ -413,6 +414,12 @@ class View final {
|
|
|
underlying_iterator_type end;
|
|
|
};
|
|
|
|
|
|
+ View(pool_type<Component> &... pools) noexcept
|
|
|
+ : pools{pools...}, view{nullptr}, unchecked{}
|
|
|
+ {
|
|
|
+ reset();
|
|
|
+ }
|
|
|
+
|
|
|
public:
|
|
|
/*! Input iterator type. */
|
|
|
using iterator_type = Iterator;
|
|
|
@@ -421,16 +428,6 @@ public:
|
|
|
/*! @brief Unsigned integer type. */
|
|
|
using size_type = typename view_type::size_type;
|
|
|
|
|
|
- /**
|
|
|
- * @brief Constructs a view out of a bunch of pools of components.
|
|
|
- * @param pools References to pools of components.
|
|
|
- */
|
|
|
- View(pool_type<Component> &... pools) noexcept
|
|
|
- : pools{pools...}, view{nullptr}, unchecked{}
|
|
|
- {
|
|
|
- reset();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @brief Returns an iterator to the first entity that has the given
|
|
|
* components.
|
|
|
@@ -677,8 +674,15 @@ private:
|
|
|
*/
|
|
|
template<typename Entity, typename Component>
|
|
|
class View<Entity, Component> final {
|
|
|
+ /*! @brief A registry is allowed to create views. */
|
|
|
+ friend class Registry<Entity>;
|
|
|
+
|
|
|
using pool_type = SparseSet<Entity, Component>;
|
|
|
|
|
|
+ View(pool_type &pool) noexcept
|
|
|
+ : pool{pool}
|
|
|
+ {}
|
|
|
+
|
|
|
public:
|
|
|
/*! Input iterator type. */
|
|
|
using iterator_type = typename pool_type::iterator_type;
|
|
|
@@ -689,14 +693,6 @@ public:
|
|
|
/*! Type of the component iterated by the view. */
|
|
|
using raw_type = typename pool_type::object_type;
|
|
|
|
|
|
- /**
|
|
|
- * @brief Constructs a view out of a pool of components.
|
|
|
- * @param pool A reference to a pool of components.
|
|
|
- */
|
|
|
- View(pool_type &pool) noexcept
|
|
|
- : pool{pool}
|
|
|
- {}
|
|
|
-
|
|
|
/**
|
|
|
* @brief Returns the number of entities that have the given component.
|
|
|
* @return Number of entities that have the given component.
|