Warning, file /system/kpmcore/src/core/device.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2008 Laurent Montel <montel@kde.org> 0004 SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org> 0005 SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk> 0006 SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com> 0007 SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu> 0008 0009 SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 0012 #ifndef KPMCORE_DEVICE_H 0013 #define KPMCORE_DEVICE_H 0014 0015 #include "util/libpartitionmanagerexport.h" 0016 0017 #include <QString> 0018 #include <QObject> 0019 0020 #include <memory> 0021 0022 class PartitionTable; 0023 class CreatePartitionTableOperation; 0024 class CoreBackend; 0025 class SmartStatus; 0026 class DevicePrivate; 0027 0028 /** A device description. 0029 0030 Represents a device like /dev/sda. Contains information about 0031 the device (name, status, size...) but does not operate on 0032 the device itself. @see CoreBackendDevice 0033 0034 Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions. 0035 0036 @see PartitionTable, Partition 0037 @author Volker Lanz <vl@fidra.de> 0038 */ 0039 class LIBKPMCORE_EXPORT Device : public QObject 0040 { 0041 Device &operator=(const Device &) = delete; 0042 0043 friend class CreatePartitionTableOperation; 0044 friend class CoreBackend; 0045 0046 public: 0047 enum class Type { 0048 Unknown_Device, 0049 Disk_Device, 0050 LVM_Device, /* VG */ 0051 SoftwareRAID_Device, /* software RAID device, i.e. mdraid */ 0052 FakeRAID_Device, /* fake RAID device, i.e. dmraid */ 0053 }; 0054 0055 explicit Device(std::shared_ptr<DevicePrivate> d_ptr, const QString& name, const QString& deviceNode, const qint64 logicalSectorSize, const qint64 totalLogicalSectors, const QString& iconName = QString(), Device::Type type = Device::Type::Disk_Device); 0056 0057 public: 0058 explicit Device(const Device& other); 0059 ~Device() override; 0060 0061 virtual bool operator==(const Device& other) const; 0062 virtual bool operator!=(const Device& other) const; 0063 0064 /**< @return the Device's name, usually some manufacturer string */ 0065 virtual QString& name(); 0066 virtual const QString& name() const; 0067 0068 /**< @return the Device's node, for example "/dev/sda" */ 0069 virtual const QString& deviceNode() const; 0070 0071 /**< @return the logical sector size the Device uses (would be extent size for e.g. LVM devices) */ 0072 virtual qint64 logicalSize() const; 0073 0074 /**< @return the total number of logical sectors on the device */ 0075 virtual qint64 totalLogical() const; 0076 0077 /**< @return the Device's PartitionTable */ 0078 virtual PartitionTable* partitionTable(); 0079 virtual const PartitionTable* partitionTable() const; 0080 0081 /** 0082 * Change the description of the partition table for different one. 0083 * The device itself is not changed; use CreatePartitionTableOperation 0084 * for that. The Device instance becomes the owner of @p ptable . 0085 */ 0086 virtual void setPartitionTable(PartitionTable* ptable); 0087 0088 virtual qint64 capacity() const { /**< @return the Device's capacity in bytes */ 0089 return logicalSize() * totalLogical(); 0090 } 0091 0092 /**< @return suggested icon name for this Device */ 0093 virtual const QString& iconName() const; 0094 0095 /**< @param name set the new Icon for this Device */ 0096 virtual void setIconName(const QString& name); 0097 0098 virtual SmartStatus& smartStatus(); 0099 virtual const SmartStatus& smartStatus() const; 0100 0101 virtual Device::Type type() const; 0102 0103 virtual QString prettyName() const; 0104 0105 protected: 0106 std::shared_ptr<DevicePrivate> d; 0107 }; 0108 0109 #endif