Program Listing for File Event.hpp

Return to documentation for file (engine/include/Cacao/Event.hpp)

#pragma once

#include "DllHelper.hpp"

#include <string>

namespace Cacao {
    class CACAO_API Event {
      public:
        Event(std::string eventType) {
            type = eventType;
        }

        const std::string GetType() const {
            return type;
        }

      protected:
        std::string type;
    };

    template<typename T>
        requires std::is_trivially_copy_constructible_v<T>
    class CACAO_API DataEvent : public Event {
      public:
        DataEvent(std::string eventType, T eventData)
          : Event(eventType), data(eventData) {}

        T GetData() const {
            return data;
        }

      private:
        T data;
    };
}