aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/designercore/projectstorage/filestatuscache.h
blob: 8f4fa6a3cc10e63027f11956e5350382be7faf76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "filestatus.h"
#include "filesysteminterface.h"

#include <QtGlobal>

QT_FORWARD_DECLARE_CLASS(QFileInfo)

namespace QmlDesigner {

class FileStatusCache
{
public:
    using size_type = FileStatuses::size_type;

    FileStatusCache(FileSystemInterface &fileSystem)
        : m_fileSystem(fileSystem)
    {}
    FileStatusCache &operator=(const FileStatusCache &) = delete;
    FileStatusCache(const FileStatusCache &) = delete;

    long long lastModifiedTime(SourceId sourceId) const;
    long long fileSize(SourceId sourceId) const;
    const FileStatus &find(SourceId sourceId) const;

    void update(SourceId sourceId);
    void update(SourceIds sourceIds);
    SourceIds modified(SourceIds sourceIds) const;

    size_type size() const;

private:
    mutable FileStatuses m_cacheEntries;
    FileSystemInterface &m_fileSystem;
};

} // namespace QmlDesigner