ALBA
albaEventBroadcaster.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaEventBroadcaster
5 Authors: Marco Petrone, Gianluigi Crimi
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 __albaEventBroadcaster_h
17#define __albaEventBroadcaster_h
18//----------------------------------------------------------------------------
19// includes :
20//----------------------------------------------------------------------------
21#include "albaEventSender.h"
22#include <vector>
23#include <list>
24
25//------------------------------------------------------------------------------
26// Forward declarations
27//------------------------------------------------------------------------------
28class albaObserver;
29class albaObserversList;
30class albaEventBase;
32
33//------------------------------------------------------------------------------
34// albaEventBroadcaster
35//------------------------------------------------------------------------------
46class ALBA_EXPORT albaEventBroadcaster : public albaEventSender
47{
48public:
49 albaEventBroadcaster(void *owner=NULL);
51
53
56
59
64 albaObserverCallback *AddObserverCallback(void (*f)(void *sender, albaID eid, void *clientdata, void *calldata));
65
68
71
74
77
79 void GetObservers(std::vector<albaObserver *> &olist);
80
83
86
88 void InvokeEvent(void *sender,albaID id = ID_NO_EVENT, void *data = NULL);
89
94
99
101 virtual void SetListener(albaObserver *o);
102
103protected:
104 typedef std::list<albaObserver *> albaObserversList;
105
108private:
109
110};
111
112#endif /* __albaEventBroadcaster_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
This class inerith form albaEventSender and extends albaEventSender with the capacity of send events ...
albaObserversList m_Observers
list of observers
albaEventBroadcaster(void *owner=NULL)
std::list< albaObserver * > albaObserversList
virtual ~albaEventBroadcaster()
void InvokeEvent(albaEventBase &e)
invoke an event of this subject
void InvokeEvent(void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
invoke an event of this subject
void AddObserver(albaObserver *obj)
Register an observer of this subject.
void GetObservers(std::vector< albaObserver * > &olist)
return a vector with the list of observers of this event source
albaEventBroadcaster(const albaEventBroadcaster &c)
albaID GetChannel()
return the channel assigned to this event source.
void RemoveAllObservers()
remove all observers at once
bool RemoveObserver(albaObserver *obj)
Unregister an observer.
void AddObserver(albaObserver &obj)
Register an observer of this subject.
virtual void SetListener(albaObserver *o)
Removes all the observer and add o to the observer list.
albaID m_Channel
a channel assigned to this event source, if <0 no channel is assigned
albaObserverCallback * AddObserverCallback(void(*f)(void *sender, albaID eid, void *clientdata, void *calldata))
Add as observer a callback function.
void SetChannel(albaID ch)
set the channel Id assigned to this event source.
bool HasObservers()
return true if this class has observers
void InvokeEvent(albaEventBase *e)
invoke an event of this subject
bool IsObserver(albaObserver *obj)
return true if object is an observer of this subject
class acting as an interface for objects using ALBA hierarchical event communication model This objec...
Concrete implementation of Observer calling a callback function.
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36