ALBA
albaEventSender.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaEventSender
5 Authors: Marco Petrone
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaEventSender_h
17#define __albaEventSender_h
18//----------------------------------------------------------------------------
19// includes :
20//----------------------------------------------------------------------------
21#include "albaObserver.h"
22#include "albaEventBase.h"
23//------------------------------------------------------------------------------
24// albaEventSender
25//------------------------------------------------------------------------------
34class ALBA_EXPORT albaEventSender
35{
36public:
37 albaEventSender() {m_Listener = NULL;}
38
40 virtual void SetListener(albaObserver *o) {m_Listener = o;}
41
43 virtual albaObserver *GetListener() {return m_Listener;}
44
46 virtual bool HasListener() {return m_Listener!=NULL;}
47
49 virtual void InvokeEvent(albaEventBase &e) {if (m_Listener) m_Listener->OnEvent(&e);}
50
52 virtual void InvokeEvent(albaEventBase *e) {if (m_Listener) m_Listener->OnEvent(e);}
53
55 virtual void InvokeEvent(void *sender, albaID id=ID_NO_EVENT, void *data=NULL) {if (m_Listener) m_Listener->OnEvent(&albaEventBase(sender,id,data));}
56
57protected:
59private:
60
61};
62
63#endif /* __albaEventSender_h */
long albaID
type for IDs inside ALBA
Definition: albaDefines.h:58
#define ID_NO_EVENT
Definition: albaDefines.h:71
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
class acting as an interface for objects using ALBA hierarchical event communication model This objec...
virtual void InvokeEvent(albaEventBase *e)
invoke an event of this subject
virtual void InvokeEvent(albaEventBase &e)
invoke an event of this subject
virtual bool HasListener()
return true if this class has observers
albaObserver * m_Listener
object to which events issued by this object are sent
virtual albaObserver * GetListener()
Return the listener object, i.e.
virtual void SetListener(albaObserver *o)
Set the listener object, i.e.
virtual void InvokeEvent(void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
invoke an event of this subject
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36