-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libdnf5 IPlugin: Pass IPluginData instead of Base to constructor
IPluginData was introduced to allow future changes to the passed dataset without changing the API and ABI. IPluginData now represents Base. But in the future it may be a struct/class. And increases the libdnf5 plugin API version to 2.0.
- Loading branch information
1 parent
d94d641
commit 60338b9
Showing
8 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ constexpr const char * attrs_value[]{"Jaroslav Rohel", "[email protected]", "Plu | |
|
||
class PythonPluginLoader : public plugin::IPlugin { | ||
public: | ||
PythonPluginLoader(libdnf5::Base & base, libdnf5::ConfigParser &) : IPlugin(base) {} | ||
PythonPluginLoader(libdnf5::plugin::IPluginData & data, libdnf5::ConfigParser &) : IPlugin(data) {} | ||
virtual ~PythonPluginLoader(); | ||
|
||
PluginAPIVersion get_api_version() const noexcept override { return PLUGIN_API_VERSION; } | ||
|
@@ -327,8 +327,10 @@ plugin::Version libdnf_plugin_get_version(void) { | |
} | ||
|
||
plugin::IPlugin * libdnf_plugin_new_instance( | ||
[[maybe_unused]] LibraryVersion library_version, libdnf5::Base & base, libdnf5::ConfigParser & parser) try { | ||
return new PythonPluginLoader(base, parser); | ||
[[maybe_unused]] LibraryVersion library_version, | ||
libdnf5::plugin::IPluginData & data, | ||
libdnf5::ConfigParser & parser) try { | ||
return new PythonPluginLoader(data, parser); | ||
} catch (...) { | ||
return nullptr; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright Contributors to the libdnf project. | ||
This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ | ||
Libdnf is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 2.1 of the License, or | ||
(at your option) any later version. | ||
Libdnf is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with libdnf. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef LIBDNF5_PLUGIN_IPLUGIN_PRIVATE_HPP | ||
#define LIBDNF5_PLUGIN_IPLUGIN_PRIVATE_HPP | ||
|
||
#include "libdnf5/plugin/iplugin.hpp" | ||
|
||
namespace libdnf5::plugin { | ||
|
||
// IPluginData exists to allow the set of passed data to be changed in the future without changing the API and ABI. | ||
// IPluginData now represents Base. But in the future it may be a struct/class. | ||
|
||
inline IPluginData & get_iplugin_data(Base & base) noexcept { | ||
return *reinterpret_cast<IPluginData *>(&base); | ||
} | ||
|
||
inline Base & get_base(IPluginData & data) noexcept { | ||
return *reinterpret_cast<Base *>(&data); | ||
} | ||
|
||
} // namespace libdnf5::plugin | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters