class ecs::TMultiStorageViewCommon

template<u32 IncludedTypeCount, u32 ExcludedTypeCount, bool InPlaceDelete>

Provides helper functionality for a view containing multiple (more than one) included or excluded types.

Template parameters

IncludedTypeCount

Number of types in the included type filter.

ExcludedTypeCount

Number of types in the excluded type filter.

InPlaceDelete

True if the storages support in-place delete policy.

Public

Methods

GetLeadingTypeStorage

const SparseSet *GetLeadingTypeStorage() const

Returns pointer to the storage that is considered the leading storage.

Leading storage is the storage that's primarily iterated over when looking for elements matching the view filter.

GetSizeEstimate

u64 GetSizeEstimate() const

Returns a rough number of elements in the view, based on the number of elements in the leading storage.

Begin

Iterator Begin() const

Iterator to the first entity matching the view filter.

End

Iterator End() const

Iterator past the last entity matching the view filter.

Front

Entity Front() const

Reference to the first entity matching the view filter, or null if none matches.

Back

Entity Back() const

Reference to the last entity matching the view filter, or null if none matches.

Find

Iterator Find(Entity entity)

Returns an iterator to the entity in the view, or End() iterator if no entity is found.

Contains

bool Contains(Entity entity)

Returns true if the provided entity matches the view filter.

IsValid

bool IsValid()

Returns true if all included and excluded storage pointer are initializes.

View is not usable unless this returns true.

begin

iterator begin()

end

iterator end()

Protected

Constructors

TMultiStorageViewCommon<IncludedTypeCount, ExcludedTypeCount, InPlaceDelete>

TMultiStorageViewCommon<IncludedTypeCount, ExcludedTypeCount, InPlaceDelete>()

TMultiStorageViewCommon<IncludedTypeCount, ExcludedTypeCount, InPlaceDelete>

TMultiStorageViewCommon<IncludedTypeCount, ExcludedTypeCount, InPlaceDelete>(std::array<const SparseSet *, IncludedTypeCount> &includedTypeStorage, std::array<const SparseSet *, ExcludedTypeCount> excludedTypeStorage)

Methods

RefreshLeadingTypeIndex

void RefreshLeadingTypeIndex()

Scans the included type storage list for smallest storage, and marks it as the leading storage.

RefreshLeadingTypeIndexIfNeeded

void RefreshLeadingTypeIndexIfNeeded()

Refreshes the leading type index, but only if all included type storage pointers were assigned.

GetIncludedTypeStorage

const SparseSet *GetIncludedTypeStorage(u32 index) const

Returns the included type storage pointer at the provided index.

SetIncludedTypeStorage

void SetIncludedTypeStorage(u32 index, const SparseSet *storage)

Assigns the included type storage pointer at the provided index.

You must assign all storages before using the view.

GetExcludedTypeStorage

const SparseSet *GetExcludedTypeStorage(u32 index) const

Returns the excluded type storage pointer at the provided index.

SetExcludedTypeStorage

void SetExcludedTypeStorage(u32 index, const SparseSet *storage)

Assigns the excluded type storage pointer at the provided index.

If excluded type storage is unassigned, it will be ignored by the view filter.

SetExplicitLeadingTypeIndex

void SetExplicitLeadingTypeIndex(u32 index)

Sets leading type index explicitly to the specific included type index.

By default the smallest storage is used.

GetLeadingTypeStorageSize

u64 GetLeadingTypeStorageSize() const

Returns the number of elements in the leading storage.

If leading storage uses in-place deletion policy, this number will also contain invalid elements.

staticGetPlaceholderStorage

static const SparseSet *GetPlaceholderStorage()

Returns empty storage that can be used for excluded type filter when no storage is assigned yet.

Fields

mIncludedTypeStorage

std::array<const SparseSet *, IncludedTypeCount> mIncludedTypeStorage

mExcludedTypeStorage

std::array<const SparseSet *, ExcludedTypeCount> mExcludedTypeStorage

mLeadingTypeIndex

u32 mLeadingTypeIndex