MPD: neighbor/Glue.hxx Source File

MPD 0.20.18

Glue.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_NEIGHBOR_ALL_HXX
21 #define MPD_NEIGHBOR_ALL_HXX
22
23 #include "check.h"
24 #include "Compiler.h"
25 #include "thread/Mutex.hxx"
26
27 #include <forward_list>
28
29 class EventLoop;
30 class NeighborExplorer;
31 class NeighborListener;
32 struct NeighborInfo;
33
37 class NeighborGlue {
38 struct Explorer {
39 NeighborExplorer *const explorer;
40
41 Explorer(NeighborExplorer *_explorer):explorer(_explorer) {}
42 Explorer(const Explorer &) = delete;
43 ~Explorer();
44 };
45
46 Mutex mutex;
47
48 std::forward_list<Explorer> explorers;
49
50 public:
51 typedef std::forward_list<NeighborInfo> List;
52
53 NeighborGlue() = default;
54 NeighborGlue(const NeighborGlue &) = delete;
55 ~NeighborGlue();
56
57 bool IsEmpty() const {
58 return explorers.empty();
59 }
60
64 void Init(EventLoop &loop, NeighborListener &listener);
65
66 void Open();
67 void Close();
68
73 gcc_pure
74 List GetList() const noexcept;
75 };
76
77 #endif
check.h
NeighborExplorer
An object that explores the neighborhood for music servers.
Definition: Explorer.hxx:39
EventLoop
An event loop that polls for events on file/socket descriptors.
Definition: Loop.hxx:52
Mutex
Definition: Mutex.hxx:43
NeighborInfo
Definition: Info.hxx:25
Compiler.h
NeighborListener
An interface that listens on events from neighbor plugins.
Definition: Listener.hxx:30
NeighborGlue::~NeighborGlue
~NeighborGlue()
NeighborGlue::NeighborGlue
NeighborGlue()=default
Mutex.hxx
NeighborGlue::Open
void Open()
NeighborGlue::Init
void Init(EventLoop &loop, NeighborListener &listener)
Throws std::runtime_error on error.
NeighborGlue
A class that initializes and opens all configured neighbor plugins.
Definition: Glue.hxx:37
NeighborGlue::GetList
gcc_pure List GetList() const noexcept
Get the combined list of all neighbors from all active plugins.
NeighborGlue::List
std::forward_list< NeighborInfo > List
Definition: Glue.hxx:51
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
NeighborGlue::Close
void Close()
NeighborGlue::IsEmpty
bool IsEmpty() const
Definition: Glue.hxx:57