<commit_before>#ifndef ENTITYMANAGER_H
#define ENTITYMANAGER_H
#include "BaseEntity.h"
#include <map>
#include <memory>

/**
 * @brief The EntityManager class: It manages the removal, creation and processing of the entities.
 */
namespace zmc
{
class EntityManager
{
public:
    explicit EntityManager(ComponentManager *componentManager);
    ~EntityManager();
    template <class E>
    /**
     * @brief Creates an entity with the default component manager and gives it a unique ID. If you don't want any group, just pass -1
     * @param groupIdentifier
     * @return
     */
    E* createEntity(int groupIdentifier)
    {
        std::unique_ptr<BaseEntity> entity(new E());
        entity->setEntityID(mLastEntityID++);
        entity->setGroup(groupIdentifier);
        entity->setComponentManager(mComponentManager);
        mEntityMap.insert(std::make_pair(mLastEntityID , std::move(entity)));
        return dynamic_cast<E*>(mEntityMap.at(mLastEntityID).get());
    }

    /**
     * @brief Returns a pointer to the entity with the specified ID. Template is used for dynamic casting
     * @param entityID
     * @return
     */
    template <class Entity>
    BaseEntity* getEntity(int entityID)
    {
        return dynamic_cast<Entity*>(mEntityMap.at(entityID).get());
    }

    /**
     * @brief Returns the number of entites in the manager
     * @return
     */
    int getEntityCount();
    /**
     * @brief Removes the entity with the specified ID
     * @param entityID
     */
    void removeEntity(int entityID);
    /**
     * @brief Removes all of the entities that are in the specified group
     * @param groupIdentifier
     */
    void removeEntitiesInGroup(int groupIdentifier);
    /**
     * @brief Removes all of the entities that are in the specified group
     * @param groupIdentifier
     * @return
     */
    std::vector<BaseEntity*> getEntitiesInGroup(int groupIdentifier);

private:
    int mLastEntityID;
    std::map<int, std::unique_ptr<BaseEntity>> mEntityMap;
    ComponentManager *mComponentManager;
};
}
#endif // ENTITYMANAGER_H<commit_msg>Remove deconstructor and add assert to dynamic casting and return const address when creating entity.<commit_after>#ifndef ENTITYMANAGER_H
#define ENTITYMANAGER_H
#include "BaseEntity.h"
#include <map>
#include <memory>
#include <cassert>

/**
 * @brief The EntityManager class: It manages the removal, creation and processing of the entities.
 */
namespace zmc
{
class EntityManager
{
public:
    explicit EntityManager(ComponentManager *componentManager);
    /**
     * @brief Creates an entity with the default component manager and gives it a unique ID. If you don't want any group, just pass -1
     * @param groupIdentifier
     * @return
     */
    template <class E>
    E * const createEntity(int groupIdentifier)
    {
        std::unique_ptr<E> entity(new E());
        entity->setEntityID(mLastEntityID++);
        entity->setGroup(groupIdentifier);
        entity->setComponentManager(mComponentManager);
        mEntityMap.insert(std::make_pair(mLastEntityID , std::move(entity)));
        assert((void*)dynamic_cast<E*>(mEntityMap.at(mLastEntityID).get()) && "Member does not point to the wanted type!");
        return static_cast<E*>(mEntityMap.at(mLastEntityID).get());
    }

    /**
     * @brief Returns a pointer to the entity with the specified ID. Template is used for dynamic casting
     * @param entityID
     * @return
     */
    template <class Entity>
    Entity* const getEntity(int entityID)
    {
        assert((void*)dynamic_cast<Entity*>(mEntityMap.at(entityID).get()) && "Member does not point to the wanted type!");
        return static_cast<Entity*>(mEntityMap.at(entityID).get());
    }

    /**
     * @brief Returns the number of entites in the manager
     * @return
     */
    int getEntityCount();
    /**
     * @brief Removes the entity with the specified ID
     * @param entityID
     */
    void removeEntity(int entityID);
    /**
     * @brief Removes all of the entities that are in the specified group
     * @param groupIdentifier
     */
    void removeEntitiesInGroup(int groupIdentifier);
    /**
     * @brief Removes all of the entities that are in the specified group
     * @param groupIdentifier
     * @return
     */
    std::vector<BaseEntity*> getEntitiesInGroup(int groupIdentifier);

private:
    int mLastEntityID;
    /**
     * @brief int --> Entity ID
     */
    std::map<int, std::unique_ptr<BaseEntity>> mEntityMap;
    ComponentManager *mComponentManager;
};
}
#endif // ENTITYMANAGER_H
{'fraction_non_alphanumeric': 0.10621022602589422, 'fraction_numerical': 0.00043888523151195964, 'mean_word_length': 3.2047970479704797, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2796060', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1283, 'n_words': 386}