//C_Event.h
template <typename EventArg>
class C_Event
{
public:
virtual void run(EventArg e) = 0;
};
//C_EventHandler.h
#include <list>
#include "C_Event.h"
template <typename EventArg>
class C_EventHandler
{
protected:
std::list<C_Event<EventArg>*>m_listEvent;
public:
void operator+=(C_Event<EventArg>* pEvent)
{
m_listEvent.push_back(pEvent);
}
void operator()(EventArg e)
{
std::list<C_Event<EventArg>*>::iterator itor = m_listEvent.begin();
while (itor != m_listEvent.end())
{
(*itor)->run(e);
++itor;
}
}
};
//C_Sender.h
#include "C_EventHandler.h"
//void 와 int
class C_Sender1
{
private:
C_EventHandler<int> m_eventAboutInt;
//C_EventHandler<void>m_eventAboutVoid;
public:
C_Sender1();
~C_Sender1();
void addEventAboutInt(C_Event<int> * pEventInt);
//void addEventAboutVoid(C_EventVoidArgs * pEventVoid);
void eventOccurAboutInt();
//void eventOccurAboutVoid();
};
//C_Receive.h
#pragma once
#include "C_EventHandler.h"
#include "C_EventVoidArgs.h"
class C_Receive2 :
public C_Event<int> ,public C_EventVoidArgs
{
public:
C_Receive2();
~C_Receive2();
public:
void run() override;
void run(int nInt) override;
};
==============================================
주석 지웠을 때 문제 없이 하고 싶은데..
보이드형 클래스는 따로 만들어서 사용해야해?
댓글 0