Parcourir la source

doc: reserved identifiers

Michele Caini il y a 1 an
Parent
commit
217bd07634
2 fichiers modifiés avec 19 ajouts et 4 suppressions
  1. 1 4
      TODO
  2. 18 0
      docs/md/entity.md

+ 1 - 4
TODO

@@ -19,10 +19,6 @@ TODO:
 * self contained entity traits to avoid explicit specializations (ie enum constants)
 * auto type info data from types if present
 * test: push sharing types further
-* after non-continuous generation for entity storage:
-  - get/reset placeholder to position after saving/loading (avoid long lookup)
-  - allow skipping/reserving entity identifiers
-  - documentation for reserved entities
 * storage entity: fast range-push from above
 * table: pop back to support swap and pop, single column access, empty type optimization
 * review cmake warning about FetchContent_Populate (need .28 and EXCLUDE_FROM_ALL for FetchContent)
@@ -35,3 +31,4 @@ TODO:
 * any cdynamic to support const ownership construction
 * allow passing arguments to meta setter/getter (we can fallback on meta invoke probably)
 * meta: review/update rebind policy for handles and arguments
+* try to specialize things like is_pointer_like from the type directly if possible

+ 18 - 0
docs/md/entity.md

@@ -36,6 +36,7 @@
   * [Empty type optimization](#empty-type-optimization)
   * [Void storage](#void-storage)
   * [Entity storage](#entity-storage)
+    * [Reserved identifiers](#reserved-identifiers)
     * [One of a kind to the registry](#one-of-a-kind-to-the-registry)
   * [Pointer stability](#pointer-stability)
     * [In-place delete](#in-place-delete)
@@ -1387,6 +1388,23 @@ fact, entities are subject to different rules with respect to components
 This kind of storage is designed to be used where any other storage is fine and
 can therefore be combined with views, groups and so on.
 
+### Reserved identifiers
+
+Since the entity storage is the one in charge of generating identifiers, it is
+also possible to request that some of them be reserved and never returned.<br/>
+By doing so, users can then generate and manage them autonomously, as needed.
+
+To set a starting identifier, the `start_from` function is invoked as follows:
+
+```cpp
+storage.start_from(entt::entity{100});
+```
+
+Note that the version is irrelevant and is ignored in all cases. Identifiers are
+always generated with default version.<br/>
+By calling `start_from` as above, the first 100 elements are discarded and the
+first identifier returned is the one with entity 100 and version 0.
+
 ### One of a kind to the registry
 
 Within the registry, an entity storage is treated in all respects like any other