LibreOffice Module svl (master) 1
broadcast.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SVL_BROADCAST_HXX
20#define INCLUDED_SVL_BROADCAST_HXX
21
22#include <svl/svldllapi.h>
23
24#include <vector>
25
26class SvtListener;
27class SfxHint;
28
30{
31public:
32 friend class SvtListener;
33
34 typedef std::vector<SvtListener*> ListenersType;
35
36private:
37 const SvtBroadcaster& operator=(const SvtBroadcaster &) = delete;
38
44 void Normalize() const;
45
46 void Add( SvtListener* p );
47 void Remove( SvtListener* p );
48
49protected:
50 virtual void ListenersGone();
51
52public:
54 : mnEmptySlots(0), mnListenersFirstUnsorted(0), mbAboutToDie(false)
55 , mbDisposing(false), mbDestNormalized(true) {}
56 SvtBroadcaster( const SvtBroadcaster &rBC );
57 virtual ~SvtBroadcaster();
58
59 void Broadcast( const SfxHint &rHint );
60
61 ListenersType& GetAllListeners();
62 const ListenersType& GetAllListeners() const;
63
64 bool HasListeners() const { return (maListeners.size() - mnEmptySlots) > 0; }
65
76 void PrepareForDestruction();
77
78private:
81
84
90 mutable sal_Int32 mnEmptySlots;
91 // The first item in maListeners that is not sorted. The container can become large, so this optimizes sorting.
92 mutable sal_Int32 mnListenersFirstUnsorted;
96 // Whether maDestructedListeners is sorted or not.
97 mutable bool mbDestNormalized:1;
98};
99
100
101#endif
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool HasListeners() const
Definition: broadcast.hxx:64
sal_Int32 mnEmptySlots
Note that this class is very performance sensitive, so the following fields have been carefully sized...
Definition: broadcast.hxx:90
ListenersType maDestructedListeners
When the broadcaster is about to die, collect listeners that asked for removal.
Definition: broadcast.hxx:83
ListenersType maListeners
contains only one of each listener, which is enforced by SvtListener
Definition: broadcast.hxx:80
sal_Int32 mnListenersFirstUnsorted
Definition: broadcast.hxx:92
bool mbAboutToDie
Indicate that this broadcaster will be destructed (we indicate this on all ScColumn's broadcasters du...
Definition: broadcast.hxx:94
const SvtBroadcaster & operator=(const SvtBroadcaster &)=delete
bool mbDestNormalized
Definition: broadcast.hxx:97
std::vector< SvtListener * > ListenersType
Definition: broadcast.hxx:34
friend class SvtBroadcaster
Definition: listener.hxx:31
#define SVL_DLLPUBLIC
Definition: svldllapi.h:28