Esempio n. 1
0
void EntityMap::insert(auto_release_ptr<Entity> entity)
{
    // Retrieve the entity.
    Entity* entity_ptr = entity.release();
    assert(entity_ptr);

    // The entity shouldn't already be in the container.
    assert(impl->m_storage.find(entity_ptr->get_uid()) == impl->m_storage.end());
    assert(impl->m_index.find(entity_ptr->get_name()) == impl->m_index.end());

    // Insert the entity into the container.
    impl->m_storage[entity_ptr->get_uid()] = entity_ptr;
    impl->m_index[entity_ptr->get_name()] = entity_ptr;
}
Esempio n. 2
0
size_t EntityVector::insert(auto_release_ptr<Entity> entity)
{
    // Retrieve the entity.
    Entity* entity_ptr = entity.release();
    assert(entity_ptr);

    // The entity shouldn't already be in the container.
    assert(impl->m_id_index.find(entity_ptr->get_uid()) == impl->m_id_index.end());
    assert(impl->m_name_index.find(entity_ptr->get_name()) == impl->m_name_index.end());

    // Insert the entity into the container.
    const size_t entity_index = impl->m_storage.size();
    impl->m_storage.push_back(entity_ptr);
    impl->m_id_index[entity_ptr->get_uid()] = entity_index;
    impl->m_name_index[entity_ptr->get_name()] = entity_index;

    // Link the entity to its parent.
    entity_ptr->set_parent(m_parent);

    return entity_index;
}