<commit_before>/**
 * @file    ComponentStore.h
 * @ingroup ecs
 * @brief   A ecs::ComponentStore keep the data of a certain type of ecs::Component for all concerned Entities.
 *
 * Copyright (c) 2014 <NAME> (<EMAIL>)
 *
 * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
 * or copy at http://opensource.org/licenses/MIT)
 */
#pragma once

#include <ecs/Entity.h>
#include <ecs/Component.h>

#include <unordered_map>
#include <memory>

namespace ecs {

/**
 * @brief   Abstract base class for all templated ComponentStore.
 * @ingroup ecs
 */
class IComponentStore {
public:
    /// Unique pointer to a ComponentStore
    typedef std::unique_ptr<IComponentStore> Ptr;
};

/**
 * @brief   A ComponentStore keep all the data of a certain type of Component for all concerned Entities.
 * @ingroup ecs
 *
 * @tparam C    A structure derived from Component, of a certain type of Component.
 */
template<typename C>
class ComponentStore : public IComponentStore {
    static_assert(std::is_base_of<Component, C>::value, "C must derived from the Component struct");
    static_assert(C::_mType != _invalidComponentType, "C must define a valid non-zero _mType");

public:
    /// Constructor.
    ComponentStore() {
    }
    /// Destructor.
    ~ComponentStore() {
    }

    /**
     * @brief Add an Component (of a certain type Component corresponding to the store type) associated to an Entity.
     *
     * @param[in] aEntity       Id of the Entity with the Component to add.
     * @param[in] aComponent    Component of a certain Component to add.
     *
     * @return true if insertion succeeded
     */
    inline bool add(Entity aEntity, C&& aComponent) {
        return mStore.insert(std::make_pair(aEntity, aComponent)).second;
    }

    /**
     * @brief Remove the specified Component associated to an Entity.
     *
     * @param[in] aEntity   Id of the Entity to remove.
     *
     * @return true if finding and removing the Entity succeeded.
     */
    inline bool remove(Entity aEntity) {
        return (0 < mStore.erase(aEntity));
    }

    /**
     * @brief Test if the store contains a Component for the specified Entity.
     *
     * @param[in] aEntity   Id of the Entity to find.
     *
     * @return true if finding the Entity succeeded.
     */
    inline bool has(Entity aEntity) {
        return (mStore.end() != mStore.find(aEntity));
    }

private:
    std::unordered_map<Entity, C>   mStore;
};

} // namespace ecs<commit_msg>Added the type of the Components stored in a static member<commit_after>/**
 * @file    ComponentStore.h
 * @ingroup ecs
 * @brief   A ecs::ComponentStore keep the data of a certain type of ecs::Component for all concerned Entities.
 *
 * Copyright (c) 2014 <NAME> (<EMAIL>)
 *
 * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
 * or copy at http://opensource.org/licenses/MIT)
 */
#pragma once

#include <ecs/Entity.h>
#include <ecs/Component.h>

#include <unordered_map>
#include <memory>

namespace ecs {

/**
 * @brief   Abstract base class for all templated ComponentStore.
 * @ingroup ecs
 */
class IComponentStore {
public:
    /// Unique pointer to a ComponentStore
    typedef std::unique_ptr<IComponentStore> Ptr;
};

/**
 * @brief   A ComponentStore keep all the data of a certain type of Component for all concerned Entities.
 * @ingroup ecs
 *
 * @tparam C    A structure derived from Component, of a certain type of Component.
 */
template<typename C>
class ComponentStore : public IComponentStore {
    static_assert(std::is_base_of<Component, C>::value, "C must derived from the Component struct");
    static_assert(C::_mType != _invalidComponentType, "C must define a valid non-zero _mType");

public:
    /// Constructor.
    ComponentStore() {
    }
    /// Destructor.
    ~ComponentStore() {
    }

    /**
     * @brief Add an Component (of a certain type Component corresponding to the store type) associated to an Entity.
     *
     * @param[in] aEntity       Id of the Entity with the Component to add.
     * @param[in] aComponent    Component of a certain Component to add.
     *
     * @return true if insertion succeeded
     */
    inline bool add(Entity aEntity, C&& aComponent) {
        return mStore.insert(std::make_pair(aEntity, aComponent)).second;
    }

    /**
     * @brief Remove the specified Component associated to an Entity.
     *
     * @param[in] aEntity   Id of the Entity to remove.
     *
     * @return true if finding and removing the Entity succeeded.
     */
    inline bool remove(Entity aEntity) {
        return (0 < mStore.erase(aEntity));
    }

    /**
     * @brief Test if the store contains a Component for the specified Entity.
     *
     * @param[in] aEntity   Id of the Entity to find.
     *
     * @return true if finding the Entity succeeded.
     */
    inline bool has(Entity aEntity) {
        return (mStore.end() != mStore.find(aEntity));
    }

private:
    std::unordered_map<Entity, C>   mStore;             ///< Hash map of stored Components
    static const ComponentType      _mType = C::_mType; ///< Type of stored Components
};

} // namespace ecs
{'fraction_non_alphanumeric': 0.10336118127064309, 'fraction_numerical': 0.0019428793471925393, 'mean_word_length': 2.902956785443518, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 23, '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': '2617676', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1493, 'n_words': 541}