// SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project #ifndef MPD_NEIGHBOR_ALL_HXX #define MPD_NEIGHBOR_ALL_HXX #include "thread/Mutex.hxx" #include #include #include struct ConfigData; class EventLoop; class NeighborExplorer; class NeighborListener; struct NeighborInfo; /** * A class that initializes and opens all configured neighbor plugins. */ class NeighborGlue { struct Explorer { const std::string name; std::unique_ptr explorer; template Explorer(N &&_name, E &&_explorer) noexcept :name(std::forward(_name)), explorer(std::forward(_explorer)) {} Explorer(const Explorer &) = delete; }; Mutex mutex; std::forward_list explorers; public: typedef std::forward_list List; NeighborGlue() noexcept; NeighborGlue(const NeighborGlue &) = delete; ~NeighborGlue() noexcept; bool IsEmpty() const noexcept { return explorers.empty(); } /** * Throws std::runtime_error on error. */ void Init(const ConfigData &config, EventLoop &loop, NeighborListener &listener); void Open(); void Close() noexcept; /** * Get the combined list of all neighbors from all active * plugins. */ [[gnu::pure]] List GetList() const noexcept; }; #endif