NLMISC::CEventEmitterMulti Class Reference

#include <event_emitter_multi.h>

Inheritance diagram for NLMISC::CEventEmitterMulti:

NLMISC::IEventEmitter NLMISC::CRefCount

Detailed Description

The composite pattern applied to events emmitters. This is useful when you don't have the opportunity to register more than one event emitter to an event server.

Definition at line 41 of file event_emitter_multi.h.

Public Member Functions

void addEmitter (IEventEmitter *e, bool mustDelete)
 ============================================================

const IEventEmittergetEmitter (uint index) const
 ============================================================

IEventEmittergetEmitter (uint index)
 ============================================================

uint getNumEmitters () const
const sintgetRefCount () const
bool isEmitter (IEventEmitter *e) const
 ============================================================

void removeEmitter (IEventEmitter *e)
 ============================================================

virtual void submitEvents (CEventServer &server, bool allWindows)
 ============================================================

 ~CEventEmitterMulti ()
 ============================================================


Data Fields

sint crefs
CPtrInfo * pinfo

Static Public Attributes

CPtrInfo NullPtrInfo

Private Types

typedef std::vector< std::pair<
IEventEmitter *, bool > > 
TEmitterCont

Private Attributes

TEmitterCont _Emitters

Friends

struct CPtrInfo


Member Typedef Documentation

typedef std::vector<std::pair<IEventEmitter *, bool> > NLMISC::CEventEmitterMulti::TEmitterCont [private]
 

Definition at line 60 of file event_emitter_multi.h.


Constructor & Destructor Documentation

NLMISC::CEventEmitterMulti::~CEventEmitterMulti  ) 
 

============================================================

Definition at line 45 of file event_emitter_multi.cpp.

References _Emitters.

00046 {
00047         for (TEmitterCont::iterator it = _Emitters.begin(); it != _Emitters.end(); ++it)
00048         {
00049                 if (it->second) // asked "must Delete' ?
00050                 {
00051                         delete it->first;
00052                 }
00053         }
00054 }


Member Function Documentation

void NLMISC::CEventEmitterMulti::addEmitter IEventEmitter e,
bool  mustDelete
 

============================================================

Definition at line 57 of file event_emitter_multi.cpp.

References _Emitters, isEmitter(), and nlassert.

00058 {
00059         nlassert(e != this); // avoid infinite recursion
00060         nlassert(!isEmitter(e));
00061         _Emitters.push_back(std::make_pair(e, mustDelete));
00062 }

const IEventEmitter * NLMISC::CEventEmitterMulti::getEmitter uint  index  )  const
 

============================================================

Definition at line 99 of file event_emitter_multi.cpp.

References _Emitters, index, nlassert, and uint.

00100 {
00101         nlassert(index < _Emitters.size());
00102         return _Emitters[index].first;
00103 }

IEventEmitter * NLMISC::CEventEmitterMulti::getEmitter uint  index  ) 
 

============================================================

Definition at line 92 of file event_emitter_multi.cpp.

References _Emitters, index, nlassert, and uint.

00093 {
00094         nlassert(index < _Emitters.size());
00095         return _Emitters[index].first;
00096 }

uint NLMISC::CEventEmitterMulti::getNumEmitters  )  const [inline]
 

Definition at line 53 of file event_emitter_multi.h.

References _Emitters, and uint.

00053 { return _Emitters.size(); }

const sint& NLMISC::CRefCount::getRefCount  )  const [inline, inherited]
 

Definition at line 70 of file smart_ptr.h.

References NLMISC::CRefCount::crefs, and sint.

00071         {
00072                 return  crefs;
00073         }

bool NLMISC::CEventEmitterMulti::isEmitter IEventEmitter e  )  const
 

============================================================

Definition at line 77 of file event_emitter_multi.cpp.

References _Emitters.

Referenced by addEmitter().

00078 {
00079         TEmitterCont::const_iterator it = std::find_if(_Emitters.begin(), _Emitters.end(), EmitterEqualPred(e));
00080         return it != _Emitters.end();
00081 }

void NLMISC::CEventEmitterMulti::removeEmitter IEventEmitter e  ) 
 

============================================================

Definition at line 65 of file event_emitter_multi.cpp.

References _Emitters, and nlassert.

00066 {
00067         TEmitterCont::iterator it = std::find_if(_Emitters.begin(), _Emitters.end(), EmitterEqualPred(e));
00068         nlassert(it!= _Emitters.end());
00069         if (it->second)
00070         {
00071                 delete it->first;
00072         }
00073         _Emitters.erase(it);
00074 }

void NLMISC::CEventEmitterMulti::submitEvents CEventServer server,
bool  allWindows
[virtual]
 

============================================================

Implements NLMISC::IEventEmitter.

Definition at line 84 of file event_emitter_multi.cpp.

References _Emitters.

00085 {
00086         for (TEmitterCont::iterator it = _Emitters.begin(); it != _Emitters.end(); ++it)
00087         {
00088                 it->first->submitEvents(server, allWindows);
00089         }
00090 }


Friends And Related Function Documentation

friend struct CPtrInfo [friend, inherited]
 

Definition at line 67 of file smart_ptr.h.


Field Documentation

TEmitterCont NLMISC::CEventEmitterMulti::_Emitters [private]
 

Definition at line 61 of file event_emitter_multi.h.

Referenced by addEmitter(), getEmitter(), getNumEmitters(), isEmitter(), removeEmitter(), submitEvents(), and ~CEventEmitterMulti().

sint NLMISC::CRefCount::crefs [mutable, inherited]
 

Definition at line 79 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount().

CRefCount::CPtrInfo NLMISC::CRefCount::NullPtrInfo [static, inherited]
 

Referenced by NLMISC::CRefCount::CRefCount().

CPtrInfo* NLMISC::CRefCount::pinfo [mutable, inherited]
 

Definition at line 80 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:10:20 2004 for NeL by doxygen 1.3.6