Function visit

Summary

#include <src/entt/entity/registry.hpp>

(1) template <typename Func>
    void visit(entity_type entity, Func func) const

(2) template <typename Func>
    void visit(Func func) const

Function overload

Synopsis

#include <src/entt/entity/registry.hpp>

template <typename Func>
void visit(entity_type entity, Func func) const

Description

Visits an entity and returns the type info for its components.

The signature of the function should be equivalent to the following:

void(const type_info);

Returned identifiers are those of the components owned by the entity.

See
type_info
Warning
It's not specified whether a component attached to or removed from the given entity during the visit is returned or not to the caller.
Template Parameters

Func - Type of the function object to invoke.

Parameters

entity - A valid entity identifier.

func - A valid function object.

Source

Lines 1451-1458 in src/entt/entity/registry.hpp.

template<typename Func>
void visit(entity_type entity, Func func) const {
    for(auto pos = pools.size(); pos; --pos) {
        if(const auto &pdata = pools[pos-1]; pdata.pool && pdata.pool->contains(entity)) {
            func(pdata.info);
        }
    }
}

Synopsis

#include <src/entt/entity/registry.hpp>

template <typename Func>
void visit(Func func) const

Description

Visits a registry and returns the type info for its components.

The signature of the function should be equivalent to the following:

void(const type_info);

Returned identifiers are those of the components managed by the registry.

See
type_info
Warning
It's not specified whether a component for which a pool is created during the visit is returned or not to the caller.
Template Parameters

Func - Type of the function object to invoke.

Parameters

func - A valid function object.

Source

Lines 1480-1487 in src/entt/entity/registry.hpp.

template<typename Func>
void visit(Func func) const {
    for(auto pos = pools.size(); pos; --pos) {
        if(const auto &pdata = pools[pos-1]; pdata.pool) {
            func(pdata.info);
        }
    }
}





Add Discussion

Log in to comment