Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct CEvent
- {
- enum class CType
- {
- EVENT_1,
- EVENT_2,
- EVENT_3,
- } m_Type;
- union
- {
- struct
- {
- unsigned int m_X;
- unsigned int m_Y;
- int m_State
- } m_Event1;
- struct
- {
- /* ... */
- } m_Event2;
- struct
- {
- /* ... */
- } m_Event3;
- };
- };
- class IObserver
- {
- public:
- virtual ~IObserver(){}
- virtual void onEvent(const CEvent& Event) = 0;
- }
- /* obserwowany obiekt */
- CEvent e;
- // odpowiednio wypelnij zdarzenie
- notifyAll(e);
- /* obserwator */
- void CEventHandler::onEvent(const CEvent& Event)
- {
- switch(Event.m_Type)
- {
- /* odczytaj dane w zaleznosci od typu */
- }
- // ...
- }
Add Comment
Please, Sign In to add comment