class
SparseRelationTableRegistryStores all of the sparse relation tables.
Public types
- struct CacheCursor
- Used by queries to track their state of the cache of calls to forEach.
- class TypeIndex
- Stores the ids of tables of a given type.
- using Iterator = std::unordered_map<DataTypeId, TypeIndex, DataTypeIdHash>::const_iterator
- Used to iterate over type indices in the registry.
Constructors, destructors, conversion operators
- SparseRelationTableRegistry()
- Constructs.
Public functions
- void reset()
- Resets the registry to its initial state.
- auto contains(SparseRelationTableId id) const -> bool
- Checks if there's a table with the given identifier.
- auto create(SparseRelationTableId id, Types& types) -> SparseRelationTable&
- Returns a reference to the table with the given identifier.
- auto at(SparseRelationTableId id) -> SparseRelationTable&
- Returns a reference to the table with the given identifier.
- auto at(SparseRelationTableId id) const -> const SparseRelationTable&
- Returns a reference to the table with the given identifier.
- auto type(DataTypeId type) const -> const TypeIndex&
- Returns the index used to search for tables of relations with a given type.
- void erase(DataTypeId type)
- Removes all relations of the given type.
- auto forEach(CacheCursor& cursor, auto func) const -> bool
- Calls the given function for each new table.
- void cleanUp()
- Cleans up the registry, removing all tables which do not hold any entities.
- auto begin() const -> Iterator
- Gets an iterator to the start of the type indices of this registry.
- auto end() const -> Iterator
- Gets an iterator to the end of the type indices of this registry.
Function documentation
void cubos:: core:: ecs:: SparseRelationTableRegistry:: reset()
Resets the registry to its initial state.
Previously returned identifiers become invalid, as they might be reused.
bool cubos:: core:: ecs:: SparseRelationTableRegistry:: contains(SparseRelationTableId id) const
Checks if there's a table with the given identifier.
Parameters | |
---|---|
id | Identifier. |
Returns | Whether it contains the table or not. |
SparseRelationTable& cubos:: core:: ecs:: SparseRelationTableRegistry:: create(SparseRelationTableId id,
Types& types)
Returns a reference to the table with the given identifier.
Parameters | |
---|---|
id | Identifier. |
types | Type registry used to initialize the table, if necessary. |
Returns | Reference to table. |
Creates the table if it doesn't exist already.
SparseRelationTable& cubos:: core:: ecs:: SparseRelationTableRegistry:: at(SparseRelationTableId id)
Returns a reference to the table with the given identifier.
Parameters | |
---|---|
id | Identifier. |
Returns | Reference to table. |
Aborts if the table doesn't exist.
const SparseRelationTable& cubos:: core:: ecs:: SparseRelationTableRegistry:: at(SparseRelationTableId id) const
Returns a reference to the table with the given identifier.
Parameters | |
---|---|
id | Identifier. |
Returns | Reference to table. |
Aborts if the table doesn't exist.
const TypeIndex& cubos:: core:: ecs:: SparseRelationTableRegistry:: type(DataTypeId type) const
Returns the index used to search for tables of relations with a given type.
Parameters | |
---|---|
type | Type identifier. |
Returns | Type index. |
void cubos:: core:: ecs:: SparseRelationTableRegistry:: erase(DataTypeId type)
Removes all relations of the given type.
Parameters | |
---|---|
type | Type identifier. |
bool cubos:: core:: ecs:: SparseRelationTableRegistry:: forEach(CacheCursor& cursor,
auto func) const
Calls the given function for each new table.
Parameters | |
---|---|
cursor | Cursor used to track the state of the cache. |
func | Function which receives a table identifier. |
Returns | Whether the cache should be cleaned up. |
void cubos:: core:: ecs:: SparseRelationTableRegistry:: cleanUp()
Cleans up the registry, removing all tables which do not hold any entities.