1#ifndef ENTT_ENTITY_OBSERVER_HPP
2#define ENTT_ENTITY_OBSERVER_HPP
9#include "../core/type_traits.hpp"
10#include "../signal/delegate.hpp"
55 template<
typename AnyOf>
90 template<
typename AnyOf>
161template<
typename Registry,
typename Mask,
typename Allocator>
166 struct matcher_handler;
170 template<std::
size_t Index>
181 template<std::
size_t Index>
188 template<std::
size_t Index>
209 if constexpr(
sizeof...(Ignore) == 0) {
225 template<std::
size_t Index>
232 template<std::
size_t Index>
254 (matcher_handler<Matcher>::disconnect(
obs, reg), ...);
258 void connect(
Registry ®, std::index_sequence<Index...>) {
259 static_assert(
sizeof...(Matcher) < std::numeric_limits<typename base_type::value_type>::digits,
"Too many matchers");
260 (matcher_handler<Matcher>::template
connect<Index>(*
this, reg), ...);
274 using iterator =
typename registry_type::common_type::iterator;
408 template<
typename Func>
410 for(
const auto entity: *
this) {
424 template<
typename Func>
426 std::as_const(*this).each(std::move(func));
void each(Func func)
Iterates entities and applies the given function object to them, then clears the observer.
basic_observer(const allocator_type &allocator)
Constructs an empty storage with a given allocator.
void disconnect()
Disconnects an observer from the registry it keeps track of.
const entity_type * data() const noexcept
Direct access to the list of entities of the observer.
iterator end() const noexcept
Returns an iterator that is past the last entity of the observer.
basic_observer & operator=(const basic_observer &)=delete
Default copy assignment operator, deleted on purpose.
iterator begin() const noexcept
Returns an iterator to the first entity of the observer.
basic_observer(basic_observer &&)=delete
Default move constructor, deleted on purpose.
typename registry_type::common_type::iterator iterator
Random access iterator type.
bool empty() const noexcept
Checks whether an observer is empty.
Allocator allocator_type
Allocator type.
basic_observer & operator=(basic_observer &&)=delete
Default move assignment operator, deleted on purpose.
basic_observer(registry_type ®, basic_collector< Matcher... >, const allocator_type &allocator=allocator_type{})
Creates an observer and connects it to a given registry.
void each(Func func) const
Iterates entities and applies the given function object to them.
basic_observer()
Default constructor.
size_type size() const noexcept
Returns the number of elements in an observer.
typename registry_type::entity_type entity_type
Underlying entity identifier.
void clear() noexcept
Clears the underlying container.
void connect(registry_type ®, basic_collector< Matcher... >)
Connects an observer to a given registry.
basic_observer(const basic_observer &)=delete
Default copy constructor, deleted on purpose.
std::size_t size_type
Unsigned integer type.
pointer data() const noexcept
Direct access to the internal packed array.
void clear()
Clears a sparse set.
size_type size() const noexcept
Returns the number of elements in a sparse set.
bool empty() const noexcept
Checks whether a sparse set is empty.
Basic storage implementation.
const_iterator end() const noexcept
Returns an iterator to the end.
const_iterator begin() const noexcept
Returns an iterator to the beginning.
Basic delegate implementation.
entity
Default entity identifier.
constexpr Type make_obj_using_allocator(const Allocator &allocator, Args &&...args)
Uses-allocator construction utility (waiting for C++20).
constexpr basic_collector collector
Variable template used to ease the definition of collectors.
static constexpr auto update() noexcept
Adds an observing matcher to the collector.
static constexpr auto group(exclude_t< NoneOf... >=exclude_t{}) noexcept
Adds a grouping matcher to the collector.
static constexpr auto where(exclude_t< NoneOf... >=exclude_t{}) noexcept
Updates the filter of the last added matcher.
static constexpr auto update() noexcept
Adds an observing matcher to the collector.
static constexpr auto group(exclude_t< NoneOf... >=exclude_t{}) noexcept
Adds a grouping matcher to the collector.
Alias for exclusion lists.
A class to use to push around lists of types, nothing more.