/* SPDX-FileCopyrightText: 2010 Volker Lanz SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas SPDX-FileCopyrightText: 2015 Teo Mrnjavac SPDX-FileCopyrightText: 2015 Chris Campbell SPDX-FileCopyrightText: 2017 Adriaan de Groot SPDX-FileCopyrightText: 2019 Yuri Chornoivan #include class CoreBackendPartition; class CoreBackendPartitionTable; class Partition; class PartitionTable; class Report; /** * Interface class for devices in the backend plugin. * For a device description, see Device. This * CoreBackendDevice can be used for (read- and) write * operations on the raw device. * * @author Volker Lanz */ class CoreBackendDevice { public: explicit CoreBackendDevice(const QString& deviceNode); virtual ~CoreBackendDevice() {} public: /** * Get the device path for this device (e.g. "/dev/sda") * @return the device path */ virtual const QString& deviceNode() const { return m_DeviceNode; } /** * Determine if this device is opened in exclusive mode. * @return true if it is opened in exclusive mode, otherwise false */ virtual bool isExclusive() const { return m_Exclusive; } /** * Open the backend device * @return true if successful */ virtual bool open() = 0; /** * Open the backend device in exclusive mode * @return true if successful */ virtual bool openExclusive() = 0; /** * Close the backend device * @return true if successful */ virtual bool close() = 0; /** * Open this backend device's partition table * @return a pointer to the CoreBackendPartitionTable for this device or nullptr in case * of errors */ virtual std::unique_ptr openPartitionTable() = 0; /** * Create a new partition table on this device. * @param report the Report to write information to * @param ptable the PartitionTable to create on this backend device * @return true if successful */ virtual bool createPartitionTable(Report& report, const PartitionTable& ptable) = 0; protected: void setExclusive(bool b) { m_Exclusive = b; } private: const QString m_DeviceNode; bool m_Exclusive; }; #endif