ALBA
Public Member Functions | Protected Types | Protected Attributes | List of all members
albaEventBroadcaster Class Reference

#include <albaEventBroadcaster.h>

Inheritance diagram for albaEventBroadcaster:
Inheritance graph
[legend]
Collaboration diagram for albaEventBroadcaster:
Collaboration graph
[legend]

Public Member Functions

 albaEventBroadcaster (void *owner=NULL)
 
virtual ~albaEventBroadcaster ()
 
 albaEventBroadcaster (const albaEventBroadcaster &c)
 
void AddObserver (albaObserver *obj)
 
void AddObserver (albaObserver &obj)
 
albaObserverCallbackAddObserverCallback (void(*f)(void *sender, albaID eid, void *clientdata, void *calldata))
 
bool RemoveObserver (albaObserver *obj)
 
void RemoveAllObservers ()
 
bool IsObserver (albaObserver *obj)
 
bool HasObservers ()
 
void GetObservers (std::vector< albaObserver * > &olist)
 
void InvokeEvent (albaEventBase &e)
 
void InvokeEvent (albaEventBase *e)
 
void InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
 
void SetChannel (albaID ch)
 
albaID GetChannel ()
 
virtual void SetListener (albaObserver *o)
 
- Public Member Functions inherited from albaEventSender
 albaEventSender ()
 
virtual void SetListener (albaObserver *o)
 
virtual albaObserverGetListener ()
 
virtual bool HasListener ()
 
virtual void InvokeEvent (albaEventBase &e)
 
virtual void InvokeEvent (albaEventBase *e)
 
virtual void InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
 

Protected Types

typedef std::list< albaObserver * > albaObserversList
 

Protected Attributes

albaObserversList m_Observers
 
albaID m_Channel
 
- Protected Attributes inherited from albaEventSender
albaObserverm_Listener
 

Detailed Description

This class inerith form albaEventSender and extends albaEventSender with the capacity of send events to multiple objects.

Set/Get listener are overridded, when you call set listener you also remove all other observers and get listener returns the first observer on the list. albaEventBroadcaster is a class implementing the "subject" in the Subject/Observer design pattern. Objective of this object is to generate events to be sent to observers. An observer must be registered to a subject to create the communication channel between the two.

See also
albaObserver albaObserverCallback

Definition at line 46 of file albaEventBroadcaster.h.

Member Typedef Documentation

◆ albaObserversList

typedef std::list<albaObserver *> albaEventBroadcaster::albaObserversList
protected

Definition at line 104 of file albaEventBroadcaster.h.

Constructor & Destructor Documentation

◆ albaEventBroadcaster() [1/2]

albaEventBroadcaster::albaEventBroadcaster ( void *  owner = NULL)

◆ ~albaEventBroadcaster()

virtual albaEventBroadcaster::~albaEventBroadcaster ( )
virtual

◆ albaEventBroadcaster() [2/2]

albaEventBroadcaster::albaEventBroadcaster ( const albaEventBroadcaster c)
inline

Definition at line 52 of file albaEventBroadcaster.h.

Member Function Documentation

◆ AddObserver() [1/2]

void albaEventBroadcaster::AddObserver ( albaObserver obj)

Register an observer of this subject.

◆ AddObserver() [2/2]

void albaEventBroadcaster::AddObserver ( albaObserver obj)

Register an observer of this subject.

◆ AddObserverCallback()

albaObserverCallback * albaEventBroadcaster::AddObserverCallback ( void(*)(void *sender, albaID eid, void *clientdata, void *calldata)  f)

Add as observer a callback function.

This function returns
pointer to an observer object that must be deleted by consumer after having detached it from the event source

◆ RemoveObserver()

bool albaEventBroadcaster::RemoveObserver ( albaObserver obj)

Unregister an observer.

Return false if object is not an observer

◆ RemoveAllObservers()

void albaEventBroadcaster::RemoveAllObservers ( )

remove all observers at once

◆ IsObserver()

bool albaEventBroadcaster::IsObserver ( albaObserver obj)

return true if object is an observer of this subject

◆ HasObservers()

bool albaEventBroadcaster::HasObservers ( )

return true if this class has observers

◆ GetObservers()

void albaEventBroadcaster::GetObservers ( std::vector< albaObserver * > &  olist)

return a vector with the list of observers of this event source

◆ InvokeEvent() [1/3]

void albaEventBroadcaster::InvokeEvent ( albaEventBase e)
virtual

invoke an event of this subject

Reimplemented from albaEventSender.

◆ InvokeEvent() [2/3]

void albaEventBroadcaster::InvokeEvent ( albaEventBase e)
virtual

invoke an event of this subject

Reimplemented from albaEventSender.

◆ InvokeEvent() [3/3]

void albaEventBroadcaster::InvokeEvent ( void *  sender,
albaID  id = ID_NO_EVENT,
void *  data = NULL 
)
virtual

invoke an event of this subject

Reimplemented from albaEventSender.

◆ SetChannel()

void albaEventBroadcaster::SetChannel ( albaID  ch)

set the channel Id assigned to this event source.

If set to <0 no channel is assigned

◆ GetChannel()

albaID albaEventBroadcaster::GetChannel ( )

return the channel assigned to this event source.

If <0 no channel has been assigned

◆ SetListener()

virtual void albaEventBroadcaster::SetListener ( albaObserver o)
virtual

Removes all the observer and add o to the observer list.

Reimplemented from albaEventSender.

Member Data Documentation

◆ m_Observers

albaObserversList albaEventBroadcaster::m_Observers
protected

list of observers

Definition at line 106 of file albaEventBroadcaster.h.

◆ m_Channel

albaID albaEventBroadcaster::m_Channel
protected

a channel assigned to this event source, if <0 no channel is assigned

Definition at line 107 of file albaEventBroadcaster.h.


The documentation for this class was generated from the following file: