#ifndef DATABASEMANAGER_H #define DATABASEMANAGER_H #include #include #include #include QT_FORWARD_DECLARE_CLASS(SqliteDb) QT_FORWARD_DECLARE_CLASS(SqliteStmt) class DatabaseManager : public QObject { Q_OBJECT public: explicit DatabaseManager(const QString &filePath, QObject *parent = nullptr); virtual ~DatabaseManager(); bool initialize(); SqliteDb *sqliteDb() const { return m_sqliteDb; } void logProcNew(const QString &appPath, bool &isNew); void logStatTraf(quint16 procCount, const quint8 *procBits, const quint32 *trafBytes); void logClear(); void getAppList(QStringList &list, QVector &appIds); qint64 getAppId(const QString &appPath); qint32 getTrafficTime(const char *sql, qint64 appId = 0); void getTraffic(const char *sql, qint32 trafTime, qint64 &inBytes, qint64 &outBytes, qint64 appId = 0); signals: public slots: private: bool createTables(); qint64 createAppId(const QString &appPath); SqliteStmt *getSqliteStmt(const char *sql); void insertTraffic(SqliteStmt *stmt, qint64 appId = 0); void updateTraffic(SqliteStmt *stmt, quint32 inBytes, quint32 outBytes, qint64 appId = 0); private: qint32 m_lastTrafHour; qint32 m_lastTrafDay; qint32 m_lastTrafMonth; QString m_filePath; SqliteDb *m_sqliteDb; QHash m_sqliteStmts; QStringList m_appPaths; QVector m_appIds; }; #endif // DATABASEMANAGER_H