1 /* 2 SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com> 3 4 SPDX-License-Identifier: GPL-3.0-or-later 5 */ 6 7 #ifndef KPMCORE_SMARTPARSER_H 8 #define KPMCORE_SMARTPARSER_H 9 10 #include <QJsonDocument> 11 #include <QString> 12 13 class SmartDiskInformation; 14 15 /** A parser to SMART JSON output. 16 17 Responsible to execute smartctl and parse its output. 18 19 @author Caio Jordão Carvalho <caiojcarvalho@gmail.com> 20 */ 21 class SmartParser 22 { 23 public: 24 explicit SmartParser(const QString &device_path); 25 ~SmartParser(); 26 27 public: 28 bool init(); 29 30 public: devicePath()31 const QString &devicePath() const 32 { 33 return m_DevicePath; /**< @return the device path that SMART must analyze */ 34 } 35 diskInformation()36 SmartDiskInformation *diskInformation() const 37 { 38 return m_DiskInformation; /**< @return a reference to parsed disk information */ 39 } 40 41 protected: 42 void loadSmartOutput(); 43 44 void loadAttributes(); 45 46 private: 47 const QString m_DevicePath; 48 QJsonDocument m_SmartOutput; 49 SmartDiskInformation *m_DiskInformation; 50 51 }; 52 53 #endif // SMARTPARSER_H 54