Skip to content

Commit

Permalink
modules: Add ModuleItem::get_status method
Browse files Browse the repository at this point in the history
  • Loading branch information
pkratoch committed Sep 25, 2023
1 parent fab191b commit 5f203b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/libdnf5/module/module_item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class ModuleTest;
namespace libdnf5::module {


enum class ModuleStatus;


struct ModuleItemId {
public:
ModuleItemId() = default;
Expand Down Expand Up @@ -167,6 +170,10 @@ class ModuleItem {
// TODO(jmracek) Read a real decision from the modular solver
bool is_active() const;

/// @return The status of this ModuleItem.
/// @since 5.1.5
ModuleStatus get_status() const;

ModuleItem(const ModuleItem & mpkg);
ModuleItem & operator=(const ModuleItem & mpkg);
ModuleItem(ModuleItem && mpkg);
Expand Down
10 changes: 10 additions & 0 deletions libdnf5/module/module_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,14 @@ bool ModuleItem::is_active() const {
}


ModuleStatus ModuleItem::get_status() const {
const ModuleStatus & module_status = module_sack->p_impl->module_db->get_status(get_name());
if (module_status == ModuleStatus::ENABLED &&
get_stream() != module_sack->p_impl->module_db->get_enabled_stream(get_name())) {
return ModuleStatus::AVAILABLE;
}
return module_status;
}


} // namespace libdnf5::module

0 comments on commit 5f203b2

Please sign in to comment.