class
SparseRelationTableRegistryStores all of the sparse relation tables.
Public types
- 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(std::size_t counter, auto func) const -> std::size_t
- Calls the given function for each new table.
- 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. |
std::size_t cubos:: core:: ecs:: SparseRelationTableRegistry:: forEach(std::size_t counter,
auto func) const
Calls the given function for each new table.
Parameters | |
---|---|
counter | Counter previously returned by this function. Zero should be used for the first call. |
func | Function which receives a table identifier. |
Returns | Counter to be passed to this function in a future call. |