1 /* 2 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 3 SPDX-FileCopyrightText: 2014-2016 Andrius Štikonas <andrius@stikonas.eu> 4 SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk> 5 6 SPDX-License-Identifier: GPL-3.0-or-later 7 */ 8 9 #ifndef KPMCORE_PARTITIONNODE_H 10 #define KPMCORE_PARTITIONNODE_H 11 12 #include "util/libpartitionmanagerexport.h" 13 14 #include <QObject> 15 #include <QList> 16 #include <QtGlobal> 17 18 class Partition; 19 class PartitionRole; 20 21 /** A node in the tree of partitions. 22 23 The root in this tree is the PartitionTable. The primaries are the child nodes; extended partitions again 24 have child nodes. 25 26 @see Device, PartitionTable, Partition 27 @author Volker Lanz <vl@fidra.de> 28 */ 29 class LIBKPMCORE_EXPORT PartitionNode : public QObject 30 { 31 public: 32 typedef QList<Partition*> Partitions; 33 34 protected: PartitionNode()35 PartitionNode() {} ~PartitionNode()36 ~PartitionNode() override {} 37 38 public: 39 virtual bool insert(Partition* partNew); 40 41 virtual Partition* predecessor(Partition& p); 42 virtual const Partition* predecessor(const Partition& p) const; 43 44 virtual Partition* successor(Partition& p); 45 virtual const Partition* successor(const Partition& p) const; 46 47 virtual bool remove(Partition* p); 48 virtual Partition* findPartitionBySector(qint64 s, const PartitionRole& role); 49 virtual const Partition* findPartitionBySector(qint64 s, const PartitionRole& role) const; 50 virtual void reparent(Partition& p); 51 52 virtual Partitions& children() = 0; 53 virtual PartitionNode* parent() = 0; 54 virtual bool isRoot() const = 0; 55 virtual const PartitionNode* parent() const = 0; 56 virtual const Partitions& children() const = 0; 57 virtual void append(Partition* p) = 0; 58 virtual qint32 highestMountedChild() const; 59 virtual bool isChildMounted() const; 60 61 protected: 62 virtual void clearChildren(); 63 }; 64 65 #endif 66