2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2008-12-16 21:42:34 +01:00
|
|
|
|
2024-07-12 09:53:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "util/DereferenceIterator.hxx"
|
|
|
|
#include "util/TerminatedArray.hxx"
|
2008-12-16 21:42:34 +01:00
|
|
|
|
2020-11-04 20:29:25 +01:00
|
|
|
#include <string_view>
|
|
|
|
|
2022-02-14 16:30:38 +01:00
|
|
|
struct ConfigData;
|
2014-02-08 13:22:13 +01:00
|
|
|
struct ArchivePlugin;
|
2008-12-16 21:42:34 +01:00
|
|
|
|
2014-02-08 13:22:13 +01:00
|
|
|
extern const ArchivePlugin *const archive_plugins[];
|
2012-06-12 20:50:51 +02:00
|
|
|
|
2024-07-12 09:53:36 +02:00
|
|
|
static inline auto
|
|
|
|
GetAllArchivePlugins() noexcept
|
|
|
|
{
|
|
|
|
return DereferenceContainerAdapter{TerminatedArray<const ArchivePlugin *const, nullptr>{archive_plugins}};
|
|
|
|
}
|
2012-06-12 20:50:51 +02:00
|
|
|
|
2008-12-16 21:42:34 +01:00
|
|
|
/* interface for using plugins */
|
|
|
|
|
2014-02-08 13:22:13 +01:00
|
|
|
const ArchivePlugin *
|
2020-11-04 20:29:25 +01:00
|
|
|
archive_plugin_from_suffix(std::string_view suffix) noexcept;
|
2008-12-16 21:42:34 +01:00
|
|
|
|
2014-02-08 13:22:13 +01:00
|
|
|
const ArchivePlugin *
|
2019-02-05 21:38:46 +01:00
|
|
|
archive_plugin_from_name(const char *name) noexcept;
|
2008-12-16 21:42:34 +01:00
|
|
|
|
|
|
|
/* this is where we "load" all the "plugins" ;-) */
|
2015-03-03 20:05:08 +01:00
|
|
|
void
|
2022-02-14 16:30:38 +01:00
|
|
|
archive_plugin_init_all(const ConfigData &config);
|
2008-12-16 21:42:34 +01:00
|
|
|
|
|
|
|
/* this is where we "unload" all the "plugins" */
|
2015-03-03 20:05:08 +01:00
|
|
|
void
|
2019-02-05 21:38:46 +01:00
|
|
|
archive_plugin_deinit_all() noexcept;
|
2008-12-16 21:42:34 +01:00
|
|
|
|
2019-02-05 21:40:07 +01:00
|
|
|
class ScopeArchivePluginsInit {
|
|
|
|
public:
|
2022-02-14 16:30:38 +01:00
|
|
|
explicit ScopeArchivePluginsInit(const ConfigData &config) {
|
|
|
|
archive_plugin_init_all(config);
|
2019-02-05 21:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~ScopeArchivePluginsInit() noexcept {
|
|
|
|
archive_plugin_deinit_all();
|
|
|
|
}
|
|
|
|
};
|