Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / src / Blackboard / LiveBlackboard.cpp
bloba4174d2940f2177f9f0e893b7f51fe8a69484072
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "LiveBlackboard.hpp"
25 #include "BlackboardListener.hpp"
27 #include <assert.h>
29 void
30 LiveBlackboard::AddListener(BlackboardListener &listener)
32 assert(!calling_listeners);
33 /* must not be registered already */
34 assert(std::find(listeners.begin(), listeners.end(),
35 &listener) == listeners.end());
37 listeners.push_back(&listener);
40 void
41 LiveBlackboard::RemoveListener(BlackboardListener &listener)
43 assert(!calling_listeners);
45 auto i = std::find(listeners.begin(), listeners.end(), &listener);
46 assert(i != listeners.end());
48 listeners.erase(i);
51 void
52 LiveBlackboard::BroadcastGPSUpdate()
54 calling_listeners = true;
56 for (BlackboardListener *listener : listeners)
57 listener->OnGPSUpdate(Basic());
59 calling_listeners = false;
62 void
63 LiveBlackboard::BroadcastCalculatedUpdate()
65 calling_listeners = true;
67 for (BlackboardListener *listener : listeners)
68 listener->OnCalculatedUpdate(Basic(), Calculated());
70 calling_listeners = false;
73 void
74 LiveBlackboard::BroadcastComputerSettingsUpdate()
76 calling_listeners = true;
78 for (BlackboardListener *listener : listeners)
79 listener->OnComputerSettingsUpdate(GetComputerSettings());
81 calling_listeners = false;
84 void
85 LiveBlackboard::BroadcastUISettingsUpdate()
87 calling_listeners = true;
89 for (BlackboardListener *listener : listeners)
90 listener->OnUISettingsUpdate(GetUISettings());
92 calling_listeners = false;