#pragma once

#include "event_manager.hpp"

namespace VE
{
  class connector
  {
    protected:
      template <typename T>
      void CONNECT(T* obj) 
      {
        if (!m_key.empty())
        {
          hack::warn()("key not empty", m_key);
          return;
        }
        m_key = event_manager::instance().connect(obj, &T::on_event);
      }

      inline void DISCONNECT() 
      {
        if (m_key.empty())
        {
          hack::warn()("key is empty", m_key);
          return;
        }
        event_manager::instance().disconnect(m_key);
        m_key.clear();
      }

    public:
      static void EMIT(event& e)
      {
        event_manager::instance().emit(e);
      }

      virtual void on_event(event& e) {};

    private:
      std::string m_key;
  };
}
