1 /* 2 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 3 SPDX-FileCopyrightText: 2008 Laurent Montel <montel@kde.org> 4 SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk> 5 SPDX-FileCopyrightText: 2016 Teo Mrnjavac <teo@kde.org> 6 SPDX-FileCopyrightText: 2016-2017 Andrius Štikonas <andrius@stikonas.eu> 7 8 SPDX-License-Identifier: GPL-3.0-or-later 9 */ 10 11 #ifndef KPMCORE_PARTITIONROLE_H 12 #define KPMCORE_PARTITIONROLE_H 13 14 #include "util/libpartitionmanagerexport.h" 15 16 #include <QtGlobal> 17 #include <QStringList> 18 19 /** A Partition's role. 20 21 Each Partition has a PartitionRole: It can be primary, extended, logical or represent unallocated space on the Device. 22 23 @author Volker Lanz <vl@fidra.de> 24 */ 25 class LIBKPMCORE_EXPORT PartitionRole 26 { 27 public: 28 /** A Partition's role: What kind of Partition is it? */ 29 enum Role { 30 None = 0, /**< None at all */ 31 Primary = 1, /**< Primary */ 32 Extended = 2, /**< Extended */ 33 Logical = 4, /**< Logical inside an extended */ 34 Unallocated = 8, /**< No real Partition, just unallocated space */ 35 Luks = 16, /**< Encrypted partition with LUKS key management */ 36 Lvm_Lv = 32, /**< Logical Volume of LVM */ 37 38 Any = 255 /**< In case we're looking for a Partition with a PartitionRole, any will do */ 39 }; 40 Q_DECLARE_FLAGS(Roles,Role)41 Q_DECLARE_FLAGS(Roles, Role) 42 43 public: 44 explicit PartitionRole(Roles r) : m_Roles(r) {} /**< Creates a new PartitionRole object */ roles()45 Roles roles() const { 46 return m_Roles; /**< @return the roles as bitfield */ 47 } has(Role r)48 bool has(Role r) const { 49 return roles() & r; /**< @param r the role to check @return true if the role is set */ 50 } 51 52 bool operator==(const PartitionRole& other) const { 53 return m_Roles == other.m_Roles; /**< @param other object to compare with @return true if the same */ 54 } 55 bool operator!=(const PartitionRole& other) const { 56 return !operator==(other); /**< @param other object to compare with @return true if not the same */ 57 } 58 59 QString toString(const QStringList& languages = {}) const; 60 61 private: 62 Roles m_Roles; 63 }; 64 65 Q_DECLARE_OPERATORS_FOR_FLAGS(PartitionRole::Roles) 66 67 #endif 68