LibreOffice Module svl (master) 1
|
#include <broadcast.hxx>
Public Types | |
typedef std::vector< SvtListener * > | ListenersType |
Public Member Functions | |
SvtBroadcaster () | |
SvtBroadcaster (const SvtBroadcaster &rBC) | |
virtual | ~SvtBroadcaster () |
void | Broadcast (const SfxHint &rHint) |
ListenersType & | GetAllListeners () |
const ListenersType & | GetAllListeners () const |
bool | HasListeners () const |
void | PrepareForDestruction () |
Listeners and broadcasters are M:N relationship. More... | |
Protected Member Functions | |
virtual void | ListenersGone () |
Private Member Functions | |
const SvtBroadcaster & | operator= (const SvtBroadcaster &)=delete |
void | Normalize () const |
Ensure that the container doesn't contain any duplicated listener entries. More... | |
void | Add (SvtListener *p) |
void | Remove (SvtListener *p) |
Private Attributes | |
ListenersType | maListeners |
contains only one of each listener, which is enforced by SvtListener More... | |
ListenersType | maDestructedListeners |
When the broadcaster is about to die, collect listeners that asked for removal. More... | |
sal_Int32 | mnEmptySlots |
Note that this class is very performance sensitive, so the following fields have been carefully sized and packed so we can access them quickly, while also taking as little CPU cache space as possible (because e.g. More... | |
sal_Int32 | mnListenersFirstUnsorted |
bool | mbAboutToDie:1 |
Indicate that this broadcaster will be destructed (we indicate this on all ScColumn's broadcasters during the ScTable destruction, eg.) More... | |
bool | mbDisposing:1 |
bool | mbDestNormalized:1 |
Friends | |
class | SvtListener |
Definition at line 29 of file broadcast.hxx.
typedef std::vector<SvtListener*> SvtBroadcaster::ListenersType |
Definition at line 34 of file broadcast.hxx.
|
inline |
Definition at line 53 of file broadcast.hxx.
SvtBroadcaster::SvtBroadcaster | ( | const SvtBroadcaster & | rBC | ) |
Definition at line 172 of file broadcast.cxx.
References maListeners, mbAboutToDie, mbDisposing, Normalize(), and p.
|
virtual |
Definition at line 186 of file broadcast.cxx.
References Broadcast(), Dying, maDestructedListeners, maListeners, mbDisposing, and Normalize().
|
private |
Definition at line 109 of file broadcast.cxx.
References isDeletedPtr(), maListeners, mbAboutToDie, mbDisposing, mnEmptySlots, mnListenersFirstUnsorted, and p.
Referenced by SvtListener::StartListening().
void SvtBroadcaster::Broadcast | ( | const SfxHint & | rHint | ) |
Definition at line 208 of file broadcast.cxx.
References aListeners, maDestructedListeners, maListeners, and Normalize().
Referenced by ~SvtBroadcaster().
SvtBroadcaster::ListenersType & SvtBroadcaster::GetAllListeners | ( | ) |
Definition at line 227 of file broadcast.cxx.
References maListeners, and Normalize().
const SvtBroadcaster::ListenersType & SvtBroadcaster::GetAllListeners | ( | ) | const |
Definition at line 233 of file broadcast.cxx.
References maListeners, and Normalize().
|
inline |
Definition at line 64 of file broadcast.hxx.
Referenced by Remove().
|
protectedvirtual |
Definition at line 225 of file broadcast.cxx.
Referenced by Remove().
|
private |
Ensure that the container doesn't contain any duplicated listener entries.
As a side effect, the listeners get sorted by pointer values after this call.
Definition at line 85 of file broadcast.cxx.
References maDestructedListeners, maListeners, mbDestNormalized, mnEmptySlots, mnListenersFirstUnsorted, p, and sortListeners().
Referenced by Broadcast(), GetAllListeners(), Remove(), SvtBroadcaster(), and ~SvtBroadcaster().
|
privatedelete |
void SvtBroadcaster::PrepareForDestruction | ( | ) |
Listeners and broadcasters are M:N relationship.
If you want to destruct them, you easily end up in O(M*N) situation; where for every listener, you iterate all broadcasters, to remove that one listener.
To avoid that, use this call to announce to the broadcaster it is going to die, and the listeners do not have to bother with removing themselves from the broadcaster - the broadcaster will not broadcast anything after the PrepareForDestruction() call anyway.
Definition at line 239 of file broadcast.cxx.
References maDestructedListeners, maListeners, and mbAboutToDie.
|
private |
Definition at line 140 of file broadcast.cxx.
References HasListeners(), ListenersGone(), maDestructedListeners, maListeners, markDeletedPtr(), mbAboutToDie, mbDestNormalized, mbDisposing, mnEmptySlots, mnListenersFirstUnsorted, Normalize(), and p.
Referenced by SvtListener::EndListening(), and SvtListener::EndListeningAll().
|
friend |
Definition at line 32 of file broadcast.hxx.
|
mutableprivate |
When the broadcaster is about to die, collect listeners that asked for removal.
Definition at line 83 of file broadcast.hxx.
Referenced by Broadcast(), Normalize(), PrepareForDestruction(), Remove(), and ~SvtBroadcaster().
|
mutableprivate |
contains only one of each listener, which is enforced by SvtListener
Definition at line 80 of file broadcast.hxx.
Referenced by Add(), Broadcast(), GetAllListeners(), Normalize(), PrepareForDestruction(), Remove(), SvtBroadcaster(), and ~SvtBroadcaster().
|
private |
Indicate that this broadcaster will be destructed (we indicate this on all ScColumn's broadcasters during the ScTable destruction, eg.)
Definition at line 94 of file broadcast.hxx.
Referenced by Add(), PrepareForDestruction(), Remove(), and SvtBroadcaster().
|
mutableprivate |
Definition at line 97 of file broadcast.hxx.
Referenced by Normalize(), and Remove().
|
private |
Definition at line 95 of file broadcast.hxx.
Referenced by Add(), Remove(), SvtBroadcaster(), and ~SvtBroadcaster().
|
mutableprivate |
Note that this class is very performance sensitive, so the following fields have been carefully sized and packed so we can access them quickly, while also taking as little CPU cache space as possible (because e.g.
calc can have a LOT of them)
Definition at line 90 of file broadcast.hxx.
Referenced by Add(), Normalize(), and Remove().
|
mutableprivate |
Definition at line 92 of file broadcast.hxx.
Referenced by Add(), Normalize(), and Remove().