2018-01-08 20:59:48 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2018 by Caio Carvalho <caiojcarvalho@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
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
|
|
|
|
|
|
|
@author Caio Carvalho <caiojcarvalho@gmail.com>
|
|
|
|
*/
|
2018-01-21 04:41:59 +00:00
|
|
|
class SmartParser
|
2018-01-08 20:59:48 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
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
|