Files
LearningOpenGL/EventManager.h
2025-08-15 16:12:18 -04:00

41 lines
1.1 KiB
C++

#pragma once
#include <strstream>
#include <FastDelegate.h>
// {29A32703-A3DB-4E7C-B275-3FBA7F78FE51}
// DEFINE_GUID(<< name >> ,
// 0x29a32703, 0xa3db, 0x4e7c, 0xb2, 0x75, 0x3f, 0xba, 0x7f, 0x78, 0xfe, 0x51);
class IEventData;
typedef unsigned long EventType;
typedef std::shared_ptr<IEventData> IEventDataPtr;
typedef fastdelegate::FastDelegate1<IEventDataPtr> EventListenerDelegate;
class IEventData
{
public:
virtual const EventType& VGetEventType(void) const = 0;
virtual float VGetTimeStamp(void) const = 0;
virtual void VSerialize(std::ostrstream& out) const = 0;
virtual IEventDataPtr VCopy(void) = 0;
virtual const char* GetName(void) = 0;
};
class BaseEventData : public IEventData
{
const float m_TimeStamp;
public:
explicit BaseEventData(const float timeStamp = 0.0f) :
m_TimeStamp(timeStamp) {}
virtual ~BaseEventData(void) {}
// Returns the type of the event
virtual const EventType& VGetEventType(void) const = 0;
float VGetTimeStamp(void) const { return m_TimeStamp; }
// Serializing for network out
virtual void VSerialized(std::ostrstream& out) const {}
};