<commit_before>#include "pixelboost/db/entity.h"
#include "pixelboost/logic/component.h"

namespace pb
{

template<class T> const T* Entity::GetData() const
{
    if (!_CreationEntity)
        return 0;
        
    return _CreationEntity->GetData<T>();
}

template <class T>T* Entity::GetComponentByType()
{
    for (ComponentList::iterator componentIt = _Components.begin(); componentIt != _Components.end(); ++componentIt)
    {
        if ((*componentIt)->GetType() == T::GetStaticType())
        {
            return static_cast<T*>(*componentIt);
        }
    }
    
    return 0;
}

template <class T> Entity::ComponentList Entity::GetComponentsByType()
{
    ComponentList components;
    
    for (ComponentList::iterator componentIt = _Components.begin(); componentIt != _Components.end(); ++componentIt)
    {
        if ((*componentIt)->GetType() == T::GetStaticType())
        {
            components.push_back(*componentIt);
        }
    }
    
    return components;
}

template <class T> void Entity::RegisterMessageHandler(MessageHandler handler)
{
    if (_HandlingMessage)<commit_msg>Don't return destroyed components<commit_after>#include "pixelboost/db/entity.h"
#include "pixelboost/logic/component.h"

namespace pb
{

template<class T> const T* Entity::GetData() const
{
    if (!_CreationEntity)
        return 0;
        
    return _CreationEntity->GetData<T>();
}

template <class T>T* Entity::GetComponentByType()
{
    for (ComponentList::iterator componentIt = _Components.begin(); componentIt != _Components.end(); ++componentIt)
    {
        if ((*componentIt)->GetType() == T::GetStaticType() && (*componentIt)->_State != Component::kComponentDestroyed)
        {
            return static_cast<T*>(*componentIt);
        }
    }
    
    return 0;
}

template <class T> Entity::ComponentList Entity::GetComponentsByType()
{
    ComponentList components;
    
    for (ComponentList::iterator componentIt = _Components.begin(); componentIt != _Components.end(); ++componentIt)
    {
        if ((*componentIt)->GetType() == T::GetStaticType() && (*componentIt)->_State != Component::kComponentDestroyed)
        {
            components.push_back(*componentIt);
        }
    }
    
    return components;
}

template <class T> void Entity::RegisterMessageHandler(MessageHandler handler)
{
    if (_HandlingMessage)
{'fraction_non_alphanumeric': 0.13818027210884354, 'fraction_numerical': 0.0017006802721088435, 'mean_word_length': 3.473384030418251, 'pattern_counts': {'":': 0, '<': 15, '<?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': '5885628', 'n_tokens_mistral': 678, 'n_tokens_neox': 671, 'n_words': 134}