LibreOffice Module svl (master) 1
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SvtBroadcaster Class Reference

#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)
 
ListenersTypeGetAllListeners ()
 
const ListenersTypeGetAllListeners () const
 
bool HasListeners () const
 
void PrepareForDestruction ()
 Listeners and broadcasters are M:N relationship. More...
 

Protected Member Functions

virtual void ListenersGone ()
 

Private Member Functions

const SvtBroadcasteroperator= (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
 

Detailed Description

Definition at line 29 of file broadcast.hxx.

Member Typedef Documentation

◆ ListenersType

Definition at line 34 of file broadcast.hxx.

Constructor & Destructor Documentation

◆ SvtBroadcaster() [1/2]

SvtBroadcaster::SvtBroadcaster ( )
inline

Definition at line 53 of file broadcast.hxx.

◆ SvtBroadcaster() [2/2]

SvtBroadcaster::SvtBroadcaster ( const SvtBroadcaster rBC)

Definition at line 172 of file broadcast.cxx.

References maListeners, mbAboutToDie, mbDisposing, Normalize(), and p.

◆ ~SvtBroadcaster()

SvtBroadcaster::~SvtBroadcaster ( )
virtual

Definition at line 186 of file broadcast.cxx.

References Broadcast(), Dying, maDestructedListeners, maListeners, mbDisposing, and Normalize().

Member Function Documentation

◆ Add()

void SvtBroadcaster::Add ( SvtListener p)
private

◆ Broadcast()

void SvtBroadcaster::Broadcast ( const SfxHint rHint)

Definition at line 208 of file broadcast.cxx.

References aListeners, maDestructedListeners, maListeners, and Normalize().

Referenced by ~SvtBroadcaster().

◆ GetAllListeners() [1/2]

SvtBroadcaster::ListenersType & SvtBroadcaster::GetAllListeners ( )

Definition at line 227 of file broadcast.cxx.

References maListeners, and Normalize().

◆ GetAllListeners() [2/2]

const SvtBroadcaster::ListenersType & SvtBroadcaster::GetAllListeners ( ) const

Definition at line 233 of file broadcast.cxx.

References maListeners, and Normalize().

◆ HasListeners()

bool SvtBroadcaster::HasListeners ( ) const
inline

Definition at line 64 of file broadcast.hxx.

Referenced by Remove().

◆ ListenersGone()

void SvtBroadcaster::ListenersGone ( )
protectedvirtual

Definition at line 225 of file broadcast.cxx.

Referenced by Remove().

◆ Normalize()

void SvtBroadcaster::Normalize ( ) const
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().

◆ operator=()

const SvtBroadcaster & SvtBroadcaster::operator= ( const SvtBroadcaster )
privatedelete

References Add, and Remove.

◆ PrepareForDestruction()

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.

◆ Remove()

void SvtBroadcaster::Remove ( SvtListener p)
private

Friends And Related Function Documentation

◆ SvtListener

friend class SvtListener
friend

Definition at line 32 of file broadcast.hxx.

Member Data Documentation

◆ maDestructedListeners

ListenersType SvtBroadcaster::maDestructedListeners
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().

◆ maListeners

ListenersType SvtBroadcaster::maListeners
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().

◆ mbAboutToDie

bool SvtBroadcaster::mbAboutToDie
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().

◆ mbDestNormalized

bool SvtBroadcaster::mbDestNormalized
mutableprivate

Definition at line 97 of file broadcast.hxx.

Referenced by Normalize(), and Remove().

◆ mbDisposing

bool SvtBroadcaster::mbDisposing
private

Definition at line 95 of file broadcast.hxx.

Referenced by Add(), Remove(), SvtBroadcaster(), and ~SvtBroadcaster().

◆ mnEmptySlots

sal_Int32 SvtBroadcaster::mnEmptySlots
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().

◆ mnListenersFirstUnsorted

sal_Int32 SvtBroadcaster::mnListenersFirstUnsorted
mutableprivate

Definition at line 92 of file broadcast.hxx.

Referenced by Add(), Normalize(), and Remove().


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