<commit_before>#ifndef GAMELIB_EVENT_HPP
#define GAMELIB_EVENT_HPP

#include <memory>
#include "../Identifier.hpp"

namespace gamelib
{
    typedef ID EventID;
    constexpr EventID invalidEvent = invalidID;

    typedef Identifiable BaseEvent; // Event Interface

    typedef std::shared_ptr<BaseEvent> EventPtr;

    // Wrapper (see Identifier.hpp)
    template <ID id>
    using Event = Identifier<id, BaseEvent>;
}

#endif
<commit_msg>Add function to BaseEvent to cast to a given type<commit_after>#ifndef GAMELIB_EVENT_HPP
#define GAMELIB_EVENT_HPP

#include <memory>
#include "../Identifier.hpp"

namespace gamelib
{
    typedef ID EventID;
    constexpr EventID invalidEvent = invalidID;

    // typedef Identifiable BaseEvent; // Event Interface

    class BaseEvent : public Identifiable
    {
        public:
            virtual ~BaseEvent() {}

            // Returns a pointer T*.
            // Can be used to easily cast to the derived class.
            template <class T>
            const T* get() const
            {
                return static_cast<const T*>(this);
            }

            template <class T>
            T* get()
            {
                return static_cast<T*>(this);
            }
    };

    typedef std::shared_ptr<BaseEvent> EventPtr;

    // Wrapper (see Identifier.hpp)
    template <ID id>
    using Event = Identifier<id, BaseEvent>;
}

#endif

{'fraction_non_alphanumeric': 0.09084406294706723, 'fraction_numerical': 0.0, 'mean_word_length': 2.2995283018867925, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5085363', 'n_tokens_mistral': 409, 'n_tokens_neox': 395, 'n_words': 119}