Solid

frontend/storagevolume.h
1/*
2 SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef SOLID_STORAGEVOLUME_H
8#define SOLID_STORAGEVOLUME_H
9
10#include <solid/solid_export.h>
11
12#include <solid/deviceinterface.h>
13
14namespace Solid
15{
16class StorageVolumePrivate;
17class Device;
18
19/**
20 * @class Solid::StorageVolume storagevolume.h <Solid/StorageVolume>
21 *
22 * This device interface is available on volume devices.
23 *
24 * A volume is anything that can contain data (partition, optical disc,
25 * memory card). It's a particular kind of block device.
26 */
27class SOLID_EXPORT StorageVolume : public DeviceInterface
28{
29 Q_OBJECT
30 Q_PROPERTY(bool ignored READ isIgnored)
31 Q_PROPERTY(UsageType usage READ usage)
32 Q_PROPERTY(QString fsType READ fsType)
33 Q_PROPERTY(QString label READ label)
34 Q_PROPERTY(QString uuid READ uuid)
35 Q_PROPERTY(qulonglong size READ size)
36 Q_DECLARE_PRIVATE(StorageVolume)
37 friend class Device;
38
39public:
40 /**
41 * This enum type defines the how a volume is used.
42 *
43 * - FileSystem : A mountable filesystem volume
44 * - PartitionTable : A volume containing a partition table
45 * - Raid : A volume member of a raid set (not mountable)
46 * - Other : A not mountable volume (like a swap partition)
47 * - Unused : An unused or free volume
48 */
49 enum UsageType { Other = 0, Unused = 1, FileSystem = 2, PartitionTable = 3, Raid = 4, Encrypted = 5 };
50 Q_ENUM(UsageType)
51
52private:
53 /**
54 * Creates a new StorageVolume object.
55 * You generally won't need this. It's created when necessary using
56 * Device::as().
57 *
58 * @param backendObject the device interface object provided by the backend
59 * @see Solid::Device::as()
60 */
61 SOLID_NO_EXPORT explicit StorageVolume(QObject *backendObject);
62
63public:
64 /**
65 * Destroys a StorageVolume object.
66 */
67 ~StorageVolume() override;
68
69 /**
70 * Get the Solid::DeviceInterface::Type of the StorageVolume device interface.
71 *
72 * @return the StorageVolume device interface type
73 * @see Solid::DeviceInterface::Type
74 */
76 {
77 return DeviceInterface::StorageVolume;
78 }
79
80 /**
81 * Indicates if this volume should be ignored by applications.
82 *
83 * If it should be ignored, it generally means that it should be
84 * invisible to the user. It's useful for firmware partitions or
85 * OS reinstall partitions on some systems.
86 *
87 * @return true if the volume should be ignored
88 */
89 bool isIgnored() const;
90
91 /**
92 * Retrieves the type of use for this volume (for example filesystem).
93 *
94 * @return the usage type
95 * @see Solid::StorageVolume::UsageType
96 */
97 UsageType usage() const;
98
99 /**
100 * Retrieves the filesystem type of this volume.
101 *
102 * FIXME: It's a platform dependent string, maybe we should switch to
103 * an enum?
104 *
105 * @return the filesystem type if applicable, QString() otherwise
106 */
107 QString fsType() const;
108
109 /**
110 * Retrieves this volume label.
111 *
112 * @return the volume label if available, QString() otherwise
113 */
114 QString label() const;
115
116 /**
117 * Retrieves this volume Universal Unique IDentifier (UUID).
118 *
119 * You can generally assume that this identifier is unique with reasonable
120 * confidence. Except if the volume UUID has been forged to intentionally
121 * provoke a collision, the probability to have two volumes having the same
122 * UUID is low.
123 *
124 * @return the Universal Unique IDentifier if available, QString() otherwise
125 */
126 QString uuid() const;
127
128 /**
129 * Retrieves this volume size in bytes.
130 *
131 * @return the size of this volume
132 */
133 qulonglong size() const;
134
135 /**
136 * Retrieves the crypto container of this volume.
137 *
138 * @return the encrypted volume containing the current volume if applicable,
139 * an invalid device otherwise
140 */
141 Device encryptedContainer() const;
142
143protected:
144 /**
145 * @internal
146 */
147 SOLID_NO_EXPORT StorageVolume(StorageVolumePrivate &dd, QObject *backendObject);
148};
149}
150
151#endif // SOLID_STORAGEVOLUME_H
Base class of all the device interfaces.
Type
This enum type defines the type of device interface that a Device can have.
This class allows applications to deal with devices available in the underlying system.
This device interface is available on volume devices.
static Type deviceInterfaceType()
Get the Solid::DeviceInterface::Type of the StorageVolume device interface.
UsageType
This enum type defines the how a volume is used.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:47:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.