Skip to content

Commit

Permalink
libdnf5 IPlugin: Use pImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
jrohel authored and jan-kolarik committed Apr 17, 2024
1 parent a7ab253 commit d94d641
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/libdnf5/plugin/iplugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#ifndef LIBDNF5_PLUGIN_IPLUGIN_HPP
#define LIBDNF5_PLUGIN_IPLUGIN_HPP

#include "libdnf5/common/impl_ptr.hpp"
#include "libdnf5/version.hpp"

#include <cstdint>
Expand Down Expand Up @@ -123,7 +124,8 @@ class IPlugin {
Base & get_base() noexcept;

private:
Base * base;
class Impl;
ImplPtr<Impl> p_impl;
};

} // namespace libdnf5::plugin
Expand Down
16 changes: 14 additions & 2 deletions libdnf5/plugin/iplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.

namespace libdnf5::plugin {

IPlugin::IPlugin(Base & base) : base(&base) {}

class IPlugin::Impl {
public:
explicit Impl(Base & base) : base(&base) {}

Base & get_base() const noexcept { return *base; }

private:
Base * base;
};


IPlugin::IPlugin(Base & base) : p_impl(new Impl(base)) {}

IPlugin::~IPlugin() = default;

Expand All @@ -48,7 +60,7 @@ void IPlugin::post_transaction([[maybe_unused]] const libdnf5::base::Transaction
void IPlugin::finish() noexcept {}

Base & IPlugin::get_base() noexcept {
return *base;
return p_impl->get_base();
}

} // namespace libdnf5::plugin

0 comments on commit d94d641

Please sign in to comment.