File indexing completed on 2024-04-28 05:45:46
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2008 Laurent Montel <montel@kde.org> 0004 SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk> 0005 SPDX-FileCopyrightText: 2016 Teo Mrnjavac <teo@kde.org> 0006 SPDX-FileCopyrightText: 2016-2017 Andrius Štikonas <andrius@stikonas.eu> 0007 0008 SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 0011 #ifndef KPMCORE_PARTITIONROLE_H 0012 #define KPMCORE_PARTITIONROLE_H 0013 0014 #include "util/libpartitionmanagerexport.h" 0015 0016 #include <QtGlobal> 0017 #include <QStringList> 0018 0019 /** A Partition's role. 0020 0021 Each Partition has a PartitionRole: It can be primary, extended, logical or represent unallocated space on the Device. 0022 0023 @author Volker Lanz <vl@fidra.de> 0024 */ 0025 class LIBKPMCORE_EXPORT PartitionRole 0026 { 0027 public: 0028 /** A Partition's role: What kind of Partition is it? */ 0029 enum Role { 0030 None = 0, /**< None at all */ 0031 Primary = 1, /**< Primary */ 0032 Extended = 2, /**< Extended */ 0033 Logical = 4, /**< Logical inside an extended */ 0034 Unallocated = 8, /**< No real Partition, just unallocated space */ 0035 Luks = 16, /**< Encrypted partition with LUKS key management */ 0036 Lvm_Lv = 32, /**< Logical Volume of LVM */ 0037 0038 Any = 255 /**< In case we're looking for a Partition with a PartitionRole, any will do */ 0039 }; 0040 0041 Q_DECLARE_FLAGS(Roles, Role) 0042 0043 public: 0044 explicit PartitionRole(Roles r) : m_Roles(r) {} /**< Creates a new PartitionRole object */ 0045 Roles roles() const { 0046 return m_Roles; /**< @return the roles as bitfield */ 0047 } 0048 bool has(Role r) const { 0049 return roles() & r; /**< @param r the role to check @return true if the role is set */ 0050 } 0051 0052 bool operator==(const PartitionRole& other) const { 0053 return m_Roles == other.m_Roles; /**< @param other object to compare with @return true if the same */ 0054 } 0055 bool operator!=(const PartitionRole& other) const { 0056 return !operator==(other); /**< @param other object to compare with @return true if not the same */ 0057 } 0058 0059 QString toString(const QStringList& languages = {}) const; 0060 0061 private: 0062 Roles m_Roles; 0063 }; 0064 0065 Q_DECLARE_OPERATORS_FOR_FLAGS(PartitionRole::Roles) 0066 0067 #endif