Baloo

documenttimedb.h
1/*
2 This file is part of the KDE Baloo project.
3 SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-or-later
6*/
7
8#ifndef BALOO_DOCUMENTTIMEDB_H
9#define BALOO_DOCUMENTTIMEDB_H
10
11#include "engine_export.h"
12
13#include <QMap>
14#include <QDebug>
15#include <lmdb.h>
16
17namespace Baloo {
18
19class BALOO_ENGINE_EXPORT DocumentTimeDB
20{
21public:
22 DocumentTimeDB(MDB_dbi dbi, MDB_txn* txn);
23 ~DocumentTimeDB();
24
25 static MDB_dbi create(MDB_txn* txn);
26 static MDB_dbi open(MDB_txn* txn);
27
28 struct TimeInfo
29 {
30 /** Tracking of file time stamps
31 *
32 * @sa QDateTime::toSecsSinceEpoch()
33 * @sa QFileInfo::lastModified()
34 * @sa QFileInfo::metadataChangeTime()
35 */
36 quint32 mTime; /**< file (data) modification time */
37 quint32 cTime; /**< metadata (e.g. XAttr) change time */
38 /* No birthtime yet */
39
40 explicit TimeInfo(quint32 mt = 0, quint32 ct = 0) : mTime(mt), cTime(ct) {}
41
42 bool operator == (const TimeInfo& rhs) const {
43 return mTime == rhs.mTime && cTime == rhs.cTime;
44 }
45 };
46 void put(quint64 docId, const TimeInfo& info);
47 TimeInfo get(quint64 docId);
48
49 void del(quint64 docId);
50 bool contains(quint64 docId);
51
52 QMap<quint64, TimeInfo> toTestMap() const;
53private:
54 MDB_txn* m_txn;
55 MDB_dbi m_dbi;
56};
57
58inline QDebug operator<<(QDebug dbg, const DocumentTimeDB::TimeInfo &time) {
59 dbg << "(" << time.mTime << "," << time.cTime << ")";
60 return dbg;
61}
62
63}
64
65#endif // BALOO_DOCUMENTTIMEDB_H
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
QAction * create(GameStandardAction id, const QObject *recvr, const char *slot, QObject *parent)
KIOCORE_EXPORT DeleteJob * del(const QList< QUrl > &src, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT TransferJob * get(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
KIOCORE_EXPORT TransferJob * put(const QUrl &url, int permissions, JobFlags flags=DefaultFlags)
const QList< QKeySequence > & open()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.