minor changes
This commit is contained in:
@@ -620,7 +620,7 @@ Because of how the registry works internally, it stores a couple of signal
|
||||
handlers for each pool in order to notify some of its data structures on the
|
||||
construction and destruction of components.<br/>
|
||||
These signal handlers are also exposed and made available to users. This is the
|
||||
basic brick to build fancy things like blueprints and reactive systems.
|
||||
basic brick to build fancy things like dependencies and reactive systems.
|
||||
|
||||
To get a sink to be used to connect and disconnect listeners so as to be
|
||||
notified on the creation of a component, use the `construction` member function:
|
||||
|
||||
4
TODO
4
TODO
@@ -8,8 +8,8 @@
|
||||
* create dedicated flat map based on types implementation (sort of "type map") for types to use within the registry and so on...
|
||||
* does it worth it to add an optional functor to the member functions of snapshot so as to filter out instances and entities?
|
||||
* ease the assignment of tags as string (use a template class with a non-type template parameter behind the scene)
|
||||
* is it possible to reduce the storage used to manage empty components?
|
||||
* reintroduce meaningful copy/clone functionalities into the registry
|
||||
* reintroduce meaningful clone functionalities into the registry
|
||||
* improve CMake interface, see mail from Malte
|
||||
* is registry/utility.hpp really required?
|
||||
* "singleton mode" for tags (see #66)
|
||||
* AOB
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace entt {
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
template<typename Entity, typename... Component>
|
||||
void dependency(Registry<Entity> ®istry, Entity entity) {
|
||||
void dependency(Registry<Entity> ®istry, const Entity entity) {
|
||||
using accumulator_type = int[];
|
||||
accumulator_type accumulator = { ((registry.template has<Component>(entity) ? void() : (registry.template assign<Component>(entity), void())), 0)... };
|
||||
(void)accumulator;
|
||||
@@ -50,7 +50,7 @@ void dependency(Registry<Entity> ®istry, Entity entity) {
|
||||
* @param sink A sink object properly initialized.
|
||||
*/
|
||||
template<typename... Dependency, typename Entity>
|
||||
void dependency(Sink<void(Registry<Entity> &, Entity)> sink) {
|
||||
void dependency(Sink<void(Registry<Entity> &, const Entity)> sink) {
|
||||
sink.template connect<dependency<Entity, Dependency...>>();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ void dependency(Sink<void(Registry<Entity> &, Entity)> sink) {
|
||||
* @param sink A sink object properly initialized.
|
||||
*/
|
||||
template<typename... Dependency, typename Entity>
|
||||
void dependency(break_t, Sink<void(Registry<Entity> &, Entity)> sink) {
|
||||
void dependency(break_t, Sink<void(Registry<Entity> &, const Entity)> sink) {
|
||||
sink.template disconnect<dependency<Entity, Dependency...>>();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,18 +31,18 @@ namespace entt {
|
||||
template<typename Entity>
|
||||
class Prototype {
|
||||
using component_type = typename Registry<Entity>::component_type;
|
||||
using fn_type = void(*)(const void *, Registry<Entity> &, Entity);
|
||||
using fn_type = void(*)(Registry<Entity> &, const Entity, const void *);
|
||||
using deleter_type = void(*)(void *);
|
||||
using ptr_type = std::unique_ptr<void, deleter_type>;
|
||||
|
||||
template<typename Component>
|
||||
static void accommodate(const void *component, Registry<Entity> ®istry, Entity entity) {
|
||||
static void accommodate(Registry<Entity> ®istry, const Entity entity, const void *component) {
|
||||
const auto &ref = *static_cast<const Component *>(component);
|
||||
registry.template accommodate<Component>(entity, ref);
|
||||
}
|
||||
|
||||
template<typename Component>
|
||||
static void assign(const void *component, Registry<Entity> ®istry, Entity entity) {
|
||||
static void assign(Registry<Entity> ®istry, const Entity entity, const void *component) {
|
||||
if(!registry.template has<Component>(entity)) {
|
||||
const auto &ref = *static_cast<const Component *>(component);
|
||||
registry.template assign<Component>(entity, ref);
|
||||
@@ -50,7 +50,7 @@ class Prototype {
|
||||
}
|
||||
|
||||
struct Handler final {
|
||||
Handler(ptr_type component, fn_type accommodate, fn_type assign, component_type type)
|
||||
Handler(ptr_type component, const fn_type accommodate, const fn_type assign, const component_type type)
|
||||
: component{std::move(component)},
|
||||
accommodate{accommodate},
|
||||
assign{assign},
|
||||
@@ -245,9 +245,9 @@ public:
|
||||
* @param registry A valid reference to a registry.
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
void assign(registry_type ®istry, entity_type entity) {
|
||||
void assign(registry_type ®istry, const entity_type entity) {
|
||||
std::for_each(handlers.begin(), handlers.end(), [®istry, entity](auto &&handler) {
|
||||
handler.assign(handler.component.get(), registry, entity);
|
||||
handler.assign(registry, entity, handler.component.get());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,9 +265,9 @@ public:
|
||||
* @param registry A valid reference to a registry.
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
void accommodate(registry_type ®istry, entity_type entity) {
|
||||
void accommodate(registry_type ®istry, const entity_type entity) {
|
||||
std::for_each(handlers.begin(), handlers.end(), [®istry, entity](auto &&handler) {
|
||||
handler.accommodate(handler.component.get(), registry, entity);
|
||||
handler.accommodate(registry, entity, handler.component.get());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
* @param registry A valid reference to a registry.
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
inline void operator()(registry_type ®istry, entity_type entity) ENTT_NOEXCEPT {
|
||||
inline void operator()(registry_type ®istry, const entity_type entity) ENTT_NOEXCEPT {
|
||||
assign(registry, entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,24 +40,24 @@ class Registry {
|
||||
using tag_family = Family<struct InternalRegistryTagFamily>;
|
||||
using component_family = Family<struct InternalRegistryComponentFamily>;
|
||||
using handler_family = Family<struct InternalRegistryHandlerFamily>;
|
||||
using signal_type = SigH<void(Registry &, Entity)>;
|
||||
using signal_type = SigH<void(Registry &, const Entity)>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
template<typename... Component>
|
||||
static void creating(Registry ®istry, Entity entity) {
|
||||
static void creating(Registry ®istry, const Entity entity) {
|
||||
if(registry.has<Component...>(entity)) {
|
||||
registry.handlers[handler_family::type<Component...>()]->construct(entity);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Component>
|
||||
static void destroying(Registry ®istry, Entity entity) {
|
||||
static void destroying(Registry ®istry, const Entity entity) {
|
||||
auto &handler = *registry.handlers[handler_family::type<Component...>()];
|
||||
return handler.has(entity) ? handler.destroy(entity) : void();
|
||||
}
|
||||
|
||||
struct Attachee {
|
||||
Attachee(Entity entity): entity{entity} {}
|
||||
Attachee(const Entity entity): entity{entity} {}
|
||||
virtual ~Attachee() = default;
|
||||
Entity entity;
|
||||
};
|
||||
@@ -66,8 +66,8 @@ class Registry {
|
||||
struct Attaching: Attachee {
|
||||
// requirements for aggregates are relaxed only since C++17
|
||||
template<typename... Args>
|
||||
Attaching(Entity entity, Tag tag)
|
||||
: Attachee{entity}, tag{std::move(tag)}
|
||||
Attaching(const Entity entity, Args &&... args)
|
||||
: Attachee{entity}, tag{std::forward<Args>(args)...}
|
||||
{}
|
||||
|
||||
Tag tag;
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
* @param cap Desired capacity.
|
||||
*/
|
||||
template<typename Component>
|
||||
void reserve(size_type cap) {
|
||||
void reserve(const size_type cap) {
|
||||
assure<Component>();
|
||||
pool<Component>().reserve(cap);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
*
|
||||
* @param cap Desired capacity.
|
||||
*/
|
||||
void reserve(size_type cap) {
|
||||
void reserve(const size_type cap) {
|
||||
entities.reserve(cap);
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
* @param entity An entity identifier, either valid or not.
|
||||
* @return True if the identifier is valid, false otherwise.
|
||||
*/
|
||||
bool valid(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool valid(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
const auto pos = size_type(entity & traits_type::entity_mask);
|
||||
return (pos < entities.size() && entities[pos] == entity);
|
||||
}
|
||||
@@ -332,7 +332,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return True if the identifier is valid, false otherwise.
|
||||
*/
|
||||
bool fast(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool fast(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
const auto pos = size_type(entity & traits_type::entity_mask);
|
||||
assert(pos < entities.size());
|
||||
return (entities[pos] == entity);
|
||||
@@ -343,7 +343,7 @@ public:
|
||||
* @param entity An entity identifier, either valid or not.
|
||||
* @return Version stored along with the given entity identifier.
|
||||
*/
|
||||
version_type version(entity_type entity) const ENTT_NOEXCEPT {
|
||||
version_type version(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
return version_type((entity >> traits_type::entity_shift) & traits_type::version_mask);
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return Actual version for the given entity identifier.
|
||||
*/
|
||||
version_type current(entity_type entity) const ENTT_NOEXCEPT {
|
||||
version_type current(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
const auto pos = size_type(entity & traits_type::entity_mask);
|
||||
assert(pos < entities.size());
|
||||
return version_type((entities[pos] >> traits_type::entity_shift) & traits_type::version_mask);
|
||||
@@ -422,7 +422,7 @@ public:
|
||||
*
|
||||
* @param entity A valid entity identifier
|
||||
*/
|
||||
void destroy(entity_type entity) {
|
||||
void destroy(const entity_type entity) {
|
||||
assert(valid(entity));
|
||||
|
||||
for(auto pos = pools.size(); pos; --pos) {
|
||||
@@ -478,12 +478,12 @@ public:
|
||||
* @return A reference to the newly created tag.
|
||||
*/
|
||||
template<typename Tag, typename... Args>
|
||||
Tag & assign(tag_t, entity_type entity, Args &&... args) {
|
||||
Tag & assign(tag_t, const entity_type entity, Args &&... args) {
|
||||
assert(valid(entity));
|
||||
assert(!has<Tag>());
|
||||
assure<Tag>(tag_t{});
|
||||
auto &tup = tags[tag_family::type<Tag>()];
|
||||
std::get<0>(tup).reset(new Attaching<Tag>{entity, Tag{std::forward<Args>(args)...}});
|
||||
std::get<0>(tup).reset(new Attaching<Tag>{entity, std::forward<Args>(args)...});
|
||||
std::get<1>(tup).publish(*this, entity);
|
||||
return get<Tag>();
|
||||
}
|
||||
@@ -509,7 +509,7 @@ public:
|
||||
* @return A reference to the newly created component.
|
||||
*/
|
||||
template<typename Component, typename... Args>
|
||||
Component & assign(entity_type entity, Args &&... args) {
|
||||
Component & assign(const entity_type entity, Args &&... args) {
|
||||
assert(valid(entity));
|
||||
assure<Component>();
|
||||
pool<Component>().construct(entity, std::forward<Args>(args)...);
|
||||
@@ -545,7 +545,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
template<typename Component>
|
||||
void remove(entity_type entity) {
|
||||
void remove(const entity_type entity) {
|
||||
assert(valid(entity));
|
||||
assert(managed<Component>());
|
||||
const auto ctype = component_family::type<Component>();
|
||||
@@ -586,7 +586,7 @@ public:
|
||||
* @return True if the entity owns the tag, false otherwise.
|
||||
*/
|
||||
template<typename Tag>
|
||||
bool has(tag_t, entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool has(tag_t, const entity_type entity) const ENTT_NOEXCEPT {
|
||||
return has<Tag>() && attachee<Tag>() == entity;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ public:
|
||||
* @return True if the entity has all the components, false otherwise.
|
||||
*/
|
||||
template<typename... Component>
|
||||
bool has(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool has(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(valid(entity));
|
||||
bool all = true;
|
||||
using accumulator_type = bool[];
|
||||
@@ -662,7 +662,7 @@ public:
|
||||
* @return A reference to the component owned by the entity.
|
||||
*/
|
||||
template<typename Component>
|
||||
const Component & get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
const Component & get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(valid(entity));
|
||||
assert(managed<Component>());
|
||||
return pool<Component>().get(entity);
|
||||
@@ -683,7 +683,7 @@ public:
|
||||
* @return A reference to the component owned by the entity.
|
||||
*/
|
||||
template<typename Component>
|
||||
inline Component & get(entity_type entity) ENTT_NOEXCEPT {
|
||||
inline Component & get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
return const_cast<Component &>(const_cast<const Registry *>(this)->get<Component>(entity));
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
std::enable_if_t<(sizeof...(Component) > 1), std::tuple<const Component &...>>
|
||||
get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
return std::tuple<const Component &...>{get<Component>(entity)...};
|
||||
}
|
||||
|
||||
@@ -723,7 +723,7 @@ public:
|
||||
*/
|
||||
template<typename... Component>
|
||||
std::enable_if_t<(sizeof...(Component) > 1), std::tuple<Component &...>>
|
||||
get(entity_type entity) ENTT_NOEXCEPT {
|
||||
get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
return std::tuple<Component &...>{get<Component>(entity)...};
|
||||
}
|
||||
|
||||
@@ -771,7 +771,7 @@ public:
|
||||
* @return A reference to the newly created component.
|
||||
*/
|
||||
template<typename Component, typename... Args>
|
||||
Component & replace(entity_type entity, Args &&... args) {
|
||||
Component & replace(const entity_type entity, Args &&... args) {
|
||||
return (get<Component>(entity) = Component{std::forward<Args>(args)...});
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ public:
|
||||
* @return A valid entity identifier.
|
||||
*/
|
||||
template<typename Tag>
|
||||
entity_type move(entity_type entity) {
|
||||
entity_type move(const entity_type entity) {
|
||||
assert(valid(entity));
|
||||
assert(has<Tag>());
|
||||
auto &tag = std::get<0>(tags[tag_family::type<Tag>()]);
|
||||
@@ -846,7 +846,7 @@ public:
|
||||
* @return A reference to the newly created component.
|
||||
*/
|
||||
template<typename Component, typename... Args>
|
||||
Component & accommodate(entity_type entity, Args &&... args) {
|
||||
Component & accommodate(const entity_type entity, Args &&... args) {
|
||||
assure<Component>();
|
||||
auto &cpool = pool<Component>();
|
||||
|
||||
@@ -1068,7 +1068,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
template<typename Component>
|
||||
void reset(entity_type entity) {
|
||||
void reset(const entity_type entity) {
|
||||
assert(valid(entity));
|
||||
assure<Component>();
|
||||
const auto ctype = component_family::type<Component>();
|
||||
@@ -1110,7 +1110,7 @@ public:
|
||||
* to know if they are still valid.
|
||||
*/
|
||||
void reset() {
|
||||
each([this](auto entity) {
|
||||
each([this](const auto entity) {
|
||||
destroy(entity);
|
||||
});
|
||||
}
|
||||
@@ -1122,7 +1122,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type);
|
||||
* void(const entity_type);
|
||||
* @endcode
|
||||
*
|
||||
* This function is fairly slow and should not be used frequently.<br/>
|
||||
@@ -1163,7 +1163,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return True if the entity is an orphan, false otherwise.
|
||||
*/
|
||||
bool orphan(entity_type entity) const {
|
||||
bool orphan(const entity_type entity) const {
|
||||
assert(valid(entity));
|
||||
bool orphan = true;
|
||||
|
||||
@@ -1188,7 +1188,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type);
|
||||
* void(const entity_type);
|
||||
* @endcode
|
||||
*
|
||||
* This function can be very slow and should not be used frequently.
|
||||
@@ -1198,7 +1198,7 @@ public:
|
||||
*/
|
||||
template<typename Func>
|
||||
void orphans(Func func) const {
|
||||
each([func = std::move(func), this](auto entity) {
|
||||
each([func = std::move(func), this](const auto entity) {
|
||||
if(orphan(entity)) {
|
||||
func(entity);
|
||||
}
|
||||
@@ -1276,7 +1276,7 @@ public:
|
||||
handler->construct(entity);
|
||||
}
|
||||
|
||||
auto connect = [this](auto ctype) {
|
||||
auto connect = [this](const auto ctype) {
|
||||
auto &cpool = pools[ctype];
|
||||
std::get<1>(cpool).sink().template connect<&Registry::creating<Component...>>();
|
||||
std::get<2>(cpool).sink().template connect<&Registry::destroying<Component...>>();
|
||||
@@ -1308,7 +1308,7 @@ public:
|
||||
if(contains<Component...>()) {
|
||||
const auto htype = handler_family::type<Component...>();
|
||||
|
||||
auto disconnect = [this](auto ctype) {
|
||||
auto disconnect = [this](const auto ctype) {
|
||||
auto &cpool = pools[ctype];
|
||||
std::get<1>(cpool).sink().template disconnect<&Registry::creating<Component...>>();
|
||||
std::get<2>(cpool).sink().template disconnect<&Registry::destroying<Component...>>();
|
||||
@@ -1418,10 +1418,10 @@ public:
|
||||
* @return A temporary object to use to take snasphosts.
|
||||
*/
|
||||
Snapshot<Entity> snapshot() const {
|
||||
using follow_fn_type = entity_type(*)(const Registry &, entity_type);
|
||||
using follow_fn_type = entity_type(*)(const Registry &, const entity_type);
|
||||
const entity_type seed = available ? (next | (entities[next] & ~traits_type::entity_mask)) : next;
|
||||
|
||||
follow_fn_type follow = [](const Registry ®istry, entity_type entity) -> entity_type {
|
||||
follow_fn_type follow = [](const Registry ®istry, const entity_type entity) -> entity_type {
|
||||
const auto &entities = registry.entities;
|
||||
const auto entt = entity & traits_type::entity_mask;
|
||||
const auto next = entities[entt] & traits_type::entity_mask;
|
||||
@@ -1447,9 +1447,9 @@ public:
|
||||
* @return A temporary object to use to load snasphosts.
|
||||
*/
|
||||
SnapshotLoader<Entity> restore() {
|
||||
using assure_fn_type = void(*)(Registry &, entity_type, bool);
|
||||
using assure_fn_type = void(*)(Registry &, const entity_type, const bool);
|
||||
|
||||
assure_fn_type assure = [](Registry ®istry, entity_type entity, bool destroyed) {
|
||||
assure_fn_type assure = [](Registry ®istry, const entity_type entity, const bool destroyed) {
|
||||
using promotion_type = std::conditional_t<sizeof(size_type) >= sizeof(entity_type), size_type, entity_type>;
|
||||
// explicit promotion to avoid warnings with std::uint16_t
|
||||
const auto entt = promotion_type{entity} & traits_type::entity_mask;
|
||||
|
||||
@@ -39,7 +39,7 @@ class Snapshot final {
|
||||
/*! @brief A registry is allowed to create snapshots. */
|
||||
friend class Registry<Entity>;
|
||||
|
||||
using follow_fn_type = Entity(*)(const Registry<Entity> &, Entity);
|
||||
using follow_fn_type = Entity(*)(const Registry<Entity> &, const Entity);
|
||||
|
||||
Snapshot(const Registry<Entity> ®istry, Entity seed, std::size_t size, follow_fn_type follow) ENTT_NOEXCEPT
|
||||
: registry{registry},
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
template<typename Archive>
|
||||
Snapshot & entities(Archive &archive) {
|
||||
archive(static_cast<Entity>(registry.size()));
|
||||
registry.each([&archive](auto entity) { archive(entity); });
|
||||
registry.each([&archive](const auto entity) { archive(entity); });
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class SnapshotLoader final {
|
||||
/*! @brief A registry is allowed to create snapshot loaders. */
|
||||
friend class Registry<Entity>;
|
||||
|
||||
using assure_fn_type = void(*)(Registry<Entity> &, Entity, bool);
|
||||
using assure_fn_type = void(*)(Registry<Entity> &, const Entity, const bool);
|
||||
|
||||
SnapshotLoader(Registry<Entity> ®istry, assure_fn_type assure_fn) ENTT_NOEXCEPT
|
||||
: registry{registry},
|
||||
@@ -216,7 +216,7 @@ class SnapshotLoader final {
|
||||
|
||||
template<typename Type, typename Archive, typename... Args>
|
||||
void assign(Archive &archive, Args... args) {
|
||||
each(archive, [&archive, this, args...](auto entity) {
|
||||
each(archive, [&archive, this, args...](const auto entity) {
|
||||
static constexpr auto destroyed = false;
|
||||
assure_fn(registry, entity, destroyed);
|
||||
archive(registry.template assign<Type>(args..., entity));
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
*/
|
||||
template<typename Archive>
|
||||
SnapshotLoader & entities(Archive &archive) {
|
||||
each(archive, [this](auto entity) {
|
||||
each(archive, [this](const auto entity) {
|
||||
static constexpr auto destroyed = false;
|
||||
assure_fn(registry, entity, destroyed);
|
||||
});
|
||||
@@ -266,7 +266,7 @@ public:
|
||||
*/
|
||||
template<typename Archive>
|
||||
SnapshotLoader & destroyed(Archive &archive) {
|
||||
each(archive, [this](auto entity) {
|
||||
each(archive, [this](const auto entity) {
|
||||
static constexpr auto destroyed = true;
|
||||
assure_fn(registry, entity, destroyed);
|
||||
});
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
* @return A valid loader to continue restoring data.
|
||||
*/
|
||||
SnapshotLoader & orphans() {
|
||||
registry.orphans([this](auto entity) {
|
||||
registry.orphans([this](const auto entity) {
|
||||
registry.destroy(entity);
|
||||
});
|
||||
|
||||
@@ -360,7 +360,7 @@ template<typename Entity>
|
||||
class ContinuousLoader final {
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
Entity destroy(Entity entity) {
|
||||
Entity destroy(const Entity entity) {
|
||||
const auto it = remloc.find(entity);
|
||||
|
||||
if(it == remloc.cend()) {
|
||||
@@ -372,7 +372,7 @@ class ContinuousLoader final {
|
||||
return remloc[entity].first;
|
||||
}
|
||||
|
||||
Entity restore(Entity entity) {
|
||||
Entity restore(const Entity entity) {
|
||||
const auto it = remloc.find(entity);
|
||||
|
||||
if(it == remloc.cend()) {
|
||||
@@ -433,9 +433,9 @@ class ContinuousLoader final {
|
||||
void assign(Archive &archive) {
|
||||
reset<Component>();
|
||||
|
||||
each(archive, [&archive, this](auto entity) {
|
||||
entity = restore(entity);
|
||||
archive(registry.template accommodate<Component>(entity));
|
||||
each(archive, [&archive, this](const auto entity) {
|
||||
const auto local = restore(entity);
|
||||
archive(registry.template accommodate<Component>(local));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -443,9 +443,9 @@ class ContinuousLoader final {
|
||||
void assign(Archive &archive, Type Component::*... member) {
|
||||
reset<Component>();
|
||||
|
||||
each(archive, [&archive, member..., this](auto entity) {
|
||||
entity = restore(entity);
|
||||
auto &component = registry.template accommodate<Component>(entity);
|
||||
each(archive, [&archive, member..., this](const auto entity) {
|
||||
const auto local = restore(entity);
|
||||
auto &component = registry.template accommodate<Component>(local);
|
||||
archive(component);
|
||||
|
||||
using accumulator_type = int[];
|
||||
@@ -458,9 +458,9 @@ class ContinuousLoader final {
|
||||
void attach(Archive &archive) {
|
||||
registry.template remove<Tag>();
|
||||
|
||||
each(archive, [&archive, this](auto entity) {
|
||||
entity = restore(entity);
|
||||
archive(registry.template assign<Tag>(tag_t{}, entity));
|
||||
each(archive, [&archive, this](const auto entity) {
|
||||
const auto local = restore(entity);
|
||||
archive(registry.template assign<Tag>(tag_t{}, local));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -468,9 +468,9 @@ class ContinuousLoader final {
|
||||
void attach(Archive &archive, Type Tag::*... member) {
|
||||
registry.template remove<Tag>();
|
||||
|
||||
each(archive, [&archive, member..., this](auto entity) {
|
||||
entity = restore(entity);
|
||||
auto &tag = registry.template assign<Tag>(tag_t{}, entity);
|
||||
each(archive, [&archive, member..., this](const auto entity) {
|
||||
const auto local = restore(entity);
|
||||
auto &tag = registry.template assign<Tag>(tag_t{}, local);
|
||||
archive(tag);
|
||||
|
||||
using accumulator_type = int[];
|
||||
@@ -513,7 +513,7 @@ public:
|
||||
*/
|
||||
template<typename Archive>
|
||||
ContinuousLoader & entities(Archive &archive) {
|
||||
each(archive, [this](auto entity) { restore(entity); });
|
||||
each(archive, [this](const auto entity) { restore(entity); });
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ public:
|
||||
*/
|
||||
template<typename Archive>
|
||||
ContinuousLoader & destroyed(Archive &archive) {
|
||||
each(archive, [this](auto entity) { destroy(entity); });
|
||||
each(archive, [this](const auto entity) { destroy(entity); });
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ public:
|
||||
* @return A non-const reference to this loader.
|
||||
*/
|
||||
ContinuousLoader & orphans() {
|
||||
registry.orphans([this](auto entity) {
|
||||
registry.orphans([this](const auto entity) {
|
||||
registry.destroy(entity);
|
||||
});
|
||||
|
||||
|
||||
@@ -79,12 +79,12 @@ class SparseSet<Entity> {
|
||||
return ++(*this), orig;
|
||||
}
|
||||
|
||||
Iterator & operator+=(difference_type value) ENTT_NOEXCEPT {
|
||||
Iterator & operator+=(const difference_type value) ENTT_NOEXCEPT {
|
||||
pos -= value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator operator+(difference_type value) const ENTT_NOEXCEPT {
|
||||
Iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
|
||||
return Iterator{direct, pos-value};
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
*
|
||||
* @param cap Desired capacity.
|
||||
*/
|
||||
void reserve(size_type cap) {
|
||||
void reserve(const size_type cap) {
|
||||
direct.reserve(cap);
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
* internal packed array.
|
||||
*/
|
||||
const_iterator_type cend() const ENTT_NOEXCEPT {
|
||||
return const_iterator_type{direct.data(), 0};
|
||||
return const_iterator_type{direct.data(), {}};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +306,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return True if the sparse set contains the entity, false otherwise.
|
||||
*/
|
||||
bool has(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool has(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
const auto pos = size_type(entity & traits_type::entity_mask);
|
||||
// testing against pending permits to avoid accessing the direct vector
|
||||
return (pos < reverse.size()) && (reverse[pos] != pending);
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return True if the sparse set contains the entity, false otherwise.
|
||||
*/
|
||||
bool fast(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool fast(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
const auto pos = size_type(entity & traits_type::entity_mask);
|
||||
assert(pos < reverse.size());
|
||||
// testing against pending permits to avoid accessing the direct vector
|
||||
@@ -348,7 +348,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return The position of the entity in the sparse set.
|
||||
*/
|
||||
pos_type get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
pos_type get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(has(entity));
|
||||
return reverse[entity & traits_type::entity_mask];
|
||||
}
|
||||
@@ -364,7 +364,7 @@ public:
|
||||
*
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
void construct(entity_type entity) {
|
||||
void construct(const entity_type entity) {
|
||||
assert(!has(entity));
|
||||
const auto pos = size_type(entity & traits_type::entity_mask);
|
||||
|
||||
@@ -388,7 +388,7 @@ public:
|
||||
*
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
virtual void destroy(entity_type entity) {
|
||||
virtual void destroy(const entity_type entity) {
|
||||
assert(has(entity));
|
||||
const auto back = direct.back();
|
||||
auto &candidate = reverse[entity & traits_type::entity_mask];
|
||||
@@ -414,7 +414,7 @@ public:
|
||||
* @param lhs A valid position within the sparse set.
|
||||
* @param rhs A valid position within the sparse set.
|
||||
*/
|
||||
void swap(pos_type lhs, pos_type rhs) ENTT_NOEXCEPT {
|
||||
void swap(const pos_type lhs, const pos_type rhs) ENTT_NOEXCEPT {
|
||||
assert(lhs < direct.size());
|
||||
assert(rhs < direct.size());
|
||||
auto &src = direct[lhs];
|
||||
@@ -522,12 +522,12 @@ class SparseSet<Entity, Type>: public SparseSet<Entity> {
|
||||
return ++(*this), orig;
|
||||
}
|
||||
|
||||
Iterator & operator+=(difference_type value) ENTT_NOEXCEPT {
|
||||
Iterator & operator+=(const difference_type value) ENTT_NOEXCEPT {
|
||||
pos -= value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator operator+(difference_type value) const ENTT_NOEXCEPT {
|
||||
Iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
|
||||
return Iterator{instances, pos-value};
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ public:
|
||||
*
|
||||
* @param cap Desired capacity.
|
||||
*/
|
||||
void reserve(size_type cap) {
|
||||
void reserve(const size_type cap) {
|
||||
underlying_type::reserve(cap);
|
||||
instances.reserve(cap);
|
||||
}
|
||||
@@ -693,7 +693,7 @@ public:
|
||||
* given type.
|
||||
*/
|
||||
const_iterator_type cend() const ENTT_NOEXCEPT {
|
||||
return const_iterator_type{instances.data(), 0};
|
||||
return const_iterator_type{instances.data(), {}};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -729,7 +729,7 @@ public:
|
||||
* given type.
|
||||
*/
|
||||
iterator_type end() ENTT_NOEXCEPT {
|
||||
return iterator_type{instances.data(), 0};
|
||||
return iterator_type{instances.data(), {}};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -744,7 +744,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return The object associated to the entity.
|
||||
*/
|
||||
const object_type & get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
const object_type & get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
return instances[underlying_type::get(entity)];
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return The object associated to the entity.
|
||||
*/
|
||||
inline object_type & get(entity_type entity) ENTT_NOEXCEPT {
|
||||
inline object_type & get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
return const_cast<object_type &>(const_cast<const SparseSet *>(this)->get(entity));
|
||||
}
|
||||
|
||||
@@ -786,7 +786,7 @@ public:
|
||||
*/
|
||||
template<typename... Args>
|
||||
std::enable_if_t<std::is_constructible<Type, Args...>::value, object_type &>
|
||||
construct(entity_type entity, Args &&... args) {
|
||||
construct(const entity_type entity, Args &&... args) {
|
||||
underlying_type::construct(entity);
|
||||
instances.emplace_back(std::forward<Args>(args)...);
|
||||
return instances.back();
|
||||
@@ -814,7 +814,7 @@ public:
|
||||
*/
|
||||
template<typename... Args>
|
||||
std::enable_if_t<!std::is_constructible<Type, Args...>::value, object_type &>
|
||||
construct(entity_type entity, Args &&... args) {
|
||||
construct(const entity_type entity, Args &&... args) {
|
||||
underlying_type::construct(entity);
|
||||
instances.emplace_back(Type{std::forward<Args>(args)...});
|
||||
return instances.back();
|
||||
@@ -831,7 +831,7 @@ public:
|
||||
*
|
||||
* @param entity A valid entity identifier.
|
||||
*/
|
||||
void destroy(entity_type entity) override {
|
||||
void destroy(const entity_type entity) override {
|
||||
// swapping isn't required here, we are getting rid of the last element
|
||||
// however, we must protect ourselves from self assignments (see #37)
|
||||
auto tmp = std::move(instances.back());
|
||||
@@ -884,7 +884,7 @@ public:
|
||||
std::vector<pos_type> copy(instances.size());
|
||||
std::iota(copy.begin(), copy.end(), 0);
|
||||
|
||||
sort(copy.begin(), copy.end(), [this, compare = std::move(compare)](auto lhs, auto rhs) {
|
||||
sort(copy.begin(), copy.end(), [this, compare = std::move(compare)](const auto lhs, const auto rhs) {
|
||||
return compare(const_cast<const object_type &>(instances[rhs]), const_cast<const object_type &>(instances[lhs]));
|
||||
});
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return True if the view contains the given entity, false otherwise.
|
||||
*/
|
||||
bool contains(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
return view.has(entity) && (view.data()[view.get(entity)] == entity);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ public:
|
||||
* @return The component assigned to the entity.
|
||||
*/
|
||||
template<typename Comp>
|
||||
const Comp & get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
const Comp & get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(contains(entity));
|
||||
return std::get<pool_type<Comp> &>(pools).get(entity);
|
||||
}
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
* @return The component assigned to the entity.
|
||||
*/
|
||||
template<typename Comp>
|
||||
inline Comp & get(entity_type entity) ENTT_NOEXCEPT {
|
||||
inline Comp & get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
return const_cast<Comp &>(const_cast<const PersistentView *>(this)->get<Comp>(entity));
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ public:
|
||||
*/
|
||||
template<typename... Comp>
|
||||
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<const Comp &...>>
|
||||
get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(contains(entity));
|
||||
return std::tuple<const Comp &...>{get<Comp>(entity)...};
|
||||
}
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
*/
|
||||
template<typename... Comp>
|
||||
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<Comp &...>>
|
||||
get(entity_type entity) ENTT_NOEXCEPT {
|
||||
get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
assert(contains(entity));
|
||||
return std::tuple<Comp &...>{get<Comp>(entity)...};
|
||||
}
|
||||
@@ -346,7 +346,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type, const Component &...);
|
||||
* void(const entity_type, const Component &...);
|
||||
* @endcode
|
||||
*
|
||||
* @tparam Func Type of the function object to invoke.
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type, Component &...);
|
||||
* void(const entity_type, Component &...);
|
||||
* @endcode
|
||||
*
|
||||
* @tparam Func Type of the function object to invoke.
|
||||
@@ -377,7 +377,7 @@ public:
|
||||
*/
|
||||
template<typename Func>
|
||||
inline void each(Func func) {
|
||||
const_cast<const PersistentView *>(this)->each([&func](entity_type entity, const Component &... component) {
|
||||
const_cast<const PersistentView *>(this)->each([&func](const entity_type entity, const Component &... component) {
|
||||
func(entity, const_cast<Component &>(component)...);
|
||||
});
|
||||
}
|
||||
@@ -507,11 +507,11 @@ class View final {
|
||||
return ++(*this), orig;
|
||||
}
|
||||
|
||||
Iterator & operator+=(difference_type value) ENTT_NOEXCEPT {
|
||||
Iterator & operator+=(const difference_type value) ENTT_NOEXCEPT {
|
||||
return ((begin += value) != end && !valid()) ? ++(*this) : *this;
|
||||
}
|
||||
|
||||
Iterator operator+(difference_type value) const ENTT_NOEXCEPT {
|
||||
Iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
|
||||
return Iterator{unchecked, extent, begin+value, end};
|
||||
}
|
||||
|
||||
@@ -569,11 +569,11 @@ class View final {
|
||||
|
||||
template<typename Comp, typename Other>
|
||||
inline std::enable_if_t<std::is_same<Comp, Other>::value, const Other &>
|
||||
get(const component_iterator_type<Comp> &it, Entity) const ENTT_NOEXCEPT { return *it; }
|
||||
get(const component_iterator_type<Comp> &it, const Entity) const ENTT_NOEXCEPT { return *it; }
|
||||
|
||||
template<typename Comp, typename Other>
|
||||
inline std::enable_if_t<!std::is_same<Comp, Other>::value, const Other &>
|
||||
get(const component_iterator_type<Comp> &, Entity entity) const ENTT_NOEXCEPT { return pool<Other>().get(entity); }
|
||||
get(const component_iterator_type<Comp> &, const Entity entity) const ENTT_NOEXCEPT { return pool<Other>().get(entity); }
|
||||
|
||||
template<typename Comp, typename Func, std::size_t... Indexes>
|
||||
void each(const pool_type<Comp> &cpool, Func func, std::index_sequence<Indexes...>) const {
|
||||
@@ -751,7 +751,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return True if the view contains the given entity, false otherwise.
|
||||
*/
|
||||
bool contains(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
const auto sz = size_type(entity & traits_type::entity_mask);
|
||||
return sz < extent() && std::min({ (pool<Component>().has(entity) && (pool<Component>().data()[pool<Component>().view_type::get(entity)] == entity))... });
|
||||
}
|
||||
@@ -774,7 +774,7 @@ public:
|
||||
* @return The component assigned to the entity.
|
||||
*/
|
||||
template<typename Comp>
|
||||
const Comp & get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
const Comp & get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(contains(entity));
|
||||
return pool<Comp>().get(entity);
|
||||
}
|
||||
@@ -797,7 +797,7 @@ public:
|
||||
* @return The component assigned to the entity.
|
||||
*/
|
||||
template<typename Comp>
|
||||
inline Comp & get(entity_type entity) ENTT_NOEXCEPT {
|
||||
inline Comp & get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
return const_cast<Comp &>(const_cast<const View *>(this)->get<Comp>(entity));
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ public:
|
||||
*/
|
||||
template<typename... Comp>
|
||||
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<const Comp &...>>
|
||||
get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(contains(entity));
|
||||
return std::tuple<const Comp &...>{get<Comp>(entity)...};
|
||||
}
|
||||
@@ -844,7 +844,7 @@ public:
|
||||
*/
|
||||
template<typename... Comp>
|
||||
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<Comp &...>>
|
||||
get(entity_type entity) ENTT_NOEXCEPT {
|
||||
get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
assert(contains(entity));
|
||||
return std::tuple<Comp &...>{get<Comp>(entity)...};
|
||||
}
|
||||
@@ -859,7 +859,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type, const Component &...);
|
||||
* void(const entity_type, const Component &...);
|
||||
* @endcode
|
||||
*
|
||||
* @tparam Func Type of the function object to invoke.
|
||||
@@ -883,7 +883,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type, Component &...);
|
||||
* void(const entity_type, Component &...);
|
||||
* @endcode
|
||||
*
|
||||
* @tparam Func Type of the function object to invoke.
|
||||
@@ -891,7 +891,7 @@ public:
|
||||
*/
|
||||
template<typename Func>
|
||||
inline void each(Func func) {
|
||||
const_cast<const View *>(this)->each([&func](entity_type entity, const Component &... component) {
|
||||
const_cast<const View *>(this)->each([&func](const entity_type entity, const Component &... component) {
|
||||
func(entity, const_cast<Component &>(component)...);
|
||||
});
|
||||
}
|
||||
@@ -1142,7 +1142,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return True if the view contains the given entity, false otherwise.
|
||||
*/
|
||||
bool contains(entity_type entity) const ENTT_NOEXCEPT {
|
||||
bool contains(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
return pool.has(entity) && (pool.data()[pool.view_type::get(entity)] == entity);
|
||||
}
|
||||
|
||||
@@ -1161,7 +1161,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return The component assigned to the entity.
|
||||
*/
|
||||
const Component & get(entity_type entity) const ENTT_NOEXCEPT {
|
||||
const Component & get(const entity_type entity) const ENTT_NOEXCEPT {
|
||||
assert(contains(entity));
|
||||
return pool.get(entity);
|
||||
}
|
||||
@@ -1181,7 +1181,7 @@ public:
|
||||
* @param entity A valid entity identifier.
|
||||
* @return The component assigned to the entity.
|
||||
*/
|
||||
inline Component & get(entity_type entity) ENTT_NOEXCEPT {
|
||||
inline Component & get(const entity_type entity) ENTT_NOEXCEPT {
|
||||
return const_cast<Component &>(const_cast<const View *>(this)->get(entity));
|
||||
}
|
||||
|
||||
@@ -1194,7 +1194,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type, const Component &);
|
||||
* void(const entity_type, const Component &);
|
||||
* @endcode
|
||||
*
|
||||
* @tparam Func Type of the function object to invoke.
|
||||
@@ -1216,7 +1216,7 @@ public:
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(entity_type, Component &);
|
||||
* void(const entity_type, Component &);
|
||||
* @endcode
|
||||
*
|
||||
* @tparam Func Type of the function object to invoke.
|
||||
@@ -1224,7 +1224,7 @@ public:
|
||||
*/
|
||||
template<typename Func>
|
||||
inline void each(Func func) {
|
||||
const_cast<const View *>(this)->each([&func](entity_type entity, const Component &component) {
|
||||
const_cast<const View *>(this)->each([&func](const entity_type entity, const Component &component) {
|
||||
func(entity, const_cast<Component &>(component));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
*
|
||||
* @param immediately Requests an immediate operation.
|
||||
*/
|
||||
void abort(bool immediately = false) ENTT_NOEXCEPT {
|
||||
void abort(const bool immediately = false) ENTT_NOEXCEPT {
|
||||
if(alive()) {
|
||||
current = State::ABORTED;
|
||||
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
* @param delta Elapsed time.
|
||||
* @param data Optional data.
|
||||
*/
|
||||
void tick(Delta delta, void *data = nullptr) {
|
||||
void tick(const Delta delta, void *data = nullptr) {
|
||||
switch (current) {
|
||||
case State::UNINITIALIZED:
|
||||
tick(0, tag<State::UNINITIALIZED>{}, data);
|
||||
@@ -327,7 +327,7 @@ struct ProcessAdaptor: Process<ProcessAdaptor<Func, Delta>, Delta>, private Func
|
||||
* @param delta Elapsed time.
|
||||
* @param data Optional data.
|
||||
*/
|
||||
void update(Delta delta, void *data) {
|
||||
void update(const Delta delta, void *data) {
|
||||
Func::operator()(delta, data, [this]() { this->succeed(); }, [this]() { this->fail(); });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -82,7 +82,7 @@ class Scheduler final {
|
||||
};
|
||||
|
||||
template<typename Proc>
|
||||
static bool update(ProcessHandler &handler, Delta delta, void *data) {
|
||||
static bool update(ProcessHandler &handler, const Delta delta, void *data) {
|
||||
auto *process = static_cast<Proc *>(handler.instance.get());
|
||||
process->tick(delta, data);
|
||||
|
||||
@@ -101,7 +101,7 @@ class Scheduler final {
|
||||
}
|
||||
|
||||
template<typename Proc>
|
||||
static void abort(ProcessHandler &handler, bool immediately) {
|
||||
static void abort(ProcessHandler &handler, const bool immediately) {
|
||||
static_cast<Proc *>(handler.instance.get())->abort(immediately);
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ public:
|
||||
* @param delta Elapsed time.
|
||||
* @param data Optional data.
|
||||
*/
|
||||
void update(Delta delta, void *data = nullptr) {
|
||||
void update(const Delta delta, void *data = nullptr) {
|
||||
bool clean = false;
|
||||
|
||||
for(auto pos = handlers.size(); pos; --pos) {
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
*
|
||||
* @param immediately Requests an immediate operation.
|
||||
*/
|
||||
void abort(bool immediately = false) {
|
||||
void abort(const bool immediately = false) {
|
||||
decltype(handlers) exec;
|
||||
exec.swap(handlers);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
* @return True if the resource is ready to use, false otherwise.
|
||||
*/
|
||||
template<typename Loader, typename... Args>
|
||||
bool load(resource_type id, Args &&... args) {
|
||||
bool load(const resource_type id, Args &&... args) {
|
||||
static_assert(std::is_base_of<ResourceLoader<Loader, Resource>, Loader>::value, "!");
|
||||
|
||||
bool loaded = true;
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
* @return True if the resource is ready to use, false otherwise.
|
||||
*/
|
||||
template<typename Loader, typename... Args>
|
||||
bool reload(resource_type id, Args &&... args) {
|
||||
bool reload(const resource_type id, Args &&... args) {
|
||||
return (discard(id), load<Loader>(id, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
* @param id Unique resource identifier.
|
||||
* @return A handle for the given resource.
|
||||
*/
|
||||
ResourceHandle<Resource> handle(resource_type id) const {
|
||||
ResourceHandle<Resource> handle(const resource_type id) const {
|
||||
auto it = resources.find(id);
|
||||
return { it == resources.end() ? nullptr : it->second };
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
* @param id Unique resource identifier.
|
||||
* @return True if the cache contains the resource, false otherwise.
|
||||
*/
|
||||
bool contains(resource_type id) const ENTT_NOEXCEPT {
|
||||
bool contains(const resource_type id) const ENTT_NOEXCEPT {
|
||||
return (resources.find(id) != resources.cend());
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
*
|
||||
* @param id Unique resource identifier.
|
||||
*/
|
||||
void discard(resource_type id) ENTT_NOEXCEPT {
|
||||
void discard(const resource_type id) ENTT_NOEXCEPT {
|
||||
auto it = resources.find(id);
|
||||
|
||||
if(it != resources.end()) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
* An assertion will abort the execution at runtime in debug mode if the
|
||||
* handle is empty.
|
||||
*/
|
||||
inline operator const Resource & () const ENTT_NOEXCEPT { return get(); }
|
||||
inline operator const Resource &() const ENTT_NOEXCEPT { return get(); }
|
||||
|
||||
/**
|
||||
* @brief Dereferences a handle to obtain the managed resource.
|
||||
|
||||
@@ -271,7 +271,6 @@ TEST(SparseSetWithType, Functionalities) {
|
||||
|
||||
set.construct(42, 3);
|
||||
|
||||
ASSERT_EQ(set.get(42), 3);
|
||||
ASSERT_FALSE(set.empty());
|
||||
ASSERT_EQ(set.size(), 1u);
|
||||
ASSERT_NE(cset.begin(), cset.end());
|
||||
|
||||
@@ -135,7 +135,6 @@ duk_ret_t get<DuktapeRuntime>(duk_context *ctx, entt::DefaultRegistry ®istry)
|
||||
duk_push_string(ctx, runtime.components[type].c_str());
|
||||
duk_json_decode(ctx, -1);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user