2020-09-20 20:33:16 +01:00
|
|
|
/*
|
2020-10-01 00:33:19 +01:00
|
|
|
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
2020-09-20 20:33:16 +01:00
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2018-01-08 20:59:48 +00:00
|
|
|
|
2018-04-02 13:13:16 +01:00
|
|
|
#ifndef KPMCORE_SMARTPARSER_H
|
2018-01-08 20:59:48 +00:00
|
|
|
#define KPMCORE_SMARTPARSER_H
|
|
|
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
class SmartDiskInformation;
|
|
|
|
|
2018-01-11 20:38:53 +00:00
|
|
|
/** A parser to SMART JSON output.
|
|
|
|
|
2018-01-11 20:59:18 +00:00
|
|
|
Responsible to execute smartctl and parse its output.
|
2018-01-11 20:38:53 +00:00
|
|
|
|
2020-10-01 00:33:19 +01:00
|
|
|
@author Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
2018-01-11 20:38:53 +00:00
|
|
|
*/
|
2018-01-21 04:41:59 +00:00
|
|
|
class SmartParser
|
2018-01-08 20:59:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-12-09 16:09:53 +00:00
|
|
|
explicit SmartParser(const QString &device_path);
|
2018-04-09 16:07:44 +01:00
|
|
|
~SmartParser();
|
2018-01-08 20:59:48 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
bool init();
|
|
|
|
|
|
|
|
public:
|
|
|
|
const QString &devicePath() const
|
|
|
|
{
|
2019-11-22 13:39:14 +00:00
|
|
|
return m_DevicePath; /**< @return the device path that SMART must analyze */
|
2018-01-08 20:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SmartDiskInformation *diskInformation() const
|
|
|
|
{
|
2018-01-11 20:38:53 +00:00
|
|
|
return m_DiskInformation; /**< @return a reference to parsed disk information */
|
2018-01-08 20:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void loadSmartOutput();
|
|
|
|
|
|
|
|
void loadAttributes();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const QString m_DevicePath;
|
|
|
|
QJsonDocument m_SmartOutput;
|
|
|
|
SmartDiskInformation *m_DiskInformation;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SMARTPARSER_H
|