more on prototype

This commit is contained in:
Michele Caini
2018-06-08 23:03:05 +02:00
parent 9feef11d6f
commit d7394a8369
2 changed files with 8 additions and 14 deletions

View File

@@ -279,10 +279,8 @@ public:
*
* @return A valid entity identifier.
*/
entity_type create() const {
const auto entity = registry->create();
assign(*registry, entity);
return entity;
inline entity_type create() const {
return create(*registry);
}
/**
@@ -332,10 +330,8 @@ public:
*
* @param dst A valid entity identifier.
*/
void assign(const entity_type dst) const {
for(auto &handler: handlers) {
handler.second.assign(*this, *registry, dst);
}
inline void assign(const entity_type dst) const {
assign(*registry, dst);
}
/**
@@ -381,10 +377,8 @@ public:
*
* @param dst A valid entity identifier.
*/
void accommodate(const entity_type dst) const {
for(auto &handler: handlers) {
handler.second.accommodate(*this, *registry, dst);
}
inline void accommodate(const entity_type dst) const {
accommodate(*registry, dst);
}
/**

View File

@@ -19,7 +19,7 @@ TEST(Prototype, SameRegistry) {
ASSERT_EQ(std::get<0>(prototype.get<int, char>()), 3);
ASSERT_EQ(std::get<1>(cprototype.get<int, char>()), 'c');
const auto e0 = prototype();
const auto e0 = prototype.create();
ASSERT_TRUE((prototype.has<int, char>()));
ASSERT_FALSE(registry.orphan(e0));
@@ -79,7 +79,7 @@ TEST(Prototype, OtherRegistry) {
ASSERT_EQ(std::get<0>(prototype.get<int, char>()), 3);
ASSERT_EQ(std::get<1>(cprototype.get<int, char>()), 'c');
const auto e0 = prototype(registry);
const auto e0 = prototype.create(registry);
ASSERT_TRUE((prototype.has<int, char>()));
ASSERT_FALSE(registry.orphan(e0));