LibrePCB Developers Documentation
outputdirectorywriter.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_OUTPUTDIRECTORYWRITER_H
21#define LIBREPCB_CORE_OUTPUTDIRECTORYWRITER_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../fileio/filepath.h"
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class Uuid;
36
37/*******************************************************************************
38 * Class OutputDirectoryWriter
39 ******************************************************************************/
40
44class OutputDirectoryWriter final : public QObject {
45 Q_OBJECT
46
47public:
48 // Constructors / Destructor
51 explicit OutputDirectoryWriter(const FilePath& dirPath) noexcept;
52 ~OutputDirectoryWriter() noexcept;
53
54 // Getters
55 const FilePath& getDirectoryPath() const noexcept { return mDirPath; }
56 const QMultiHash<Uuid, FilePath>& getWrittenFiles() const noexcept {
57 return mWrittenFiles;
58 }
59
60 // General Methods
61 bool loadIndex();
62 void storeIndex();
63 FilePath beginWritingFile(const Uuid& job, const QString& relPath);
64 void removeObsoleteFiles(const Uuid& job);
65 QList<FilePath> findUnknownFiles(const QSet<Uuid>& knownJobs) const;
66 void removeUnknownFiles(const QList<FilePath>& files);
67
68 // Operator Overloadings
70
71signals:
72 void aboutToWriteFile(const FilePath& fp);
73 void aboutToRemoveFile(const FilePath& fp);
74
75private: // Data
78 QMap<FilePath, Uuid> mIndex;
81 QMultiHash<Uuid, FilePath> mWrittenFiles;
82};
83
84/*******************************************************************************
85 * End of File
86 ******************************************************************************/
87
88} // namespace librepcb
89
90#endif
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The OutputDirectoryWriter class.
Definition: outputdirectorywriter.h:44
bool mIndexLoaded
Definition: outputdirectorywriter.h:79
QList< FilePath > findUnknownFiles(const QSet< Uuid > &knownJobs) const
Definition: outputdirectorywriter.cpp:152
const FilePath mDirPath
Definition: outputdirectorywriter.h:76
bool mIndexModified
Definition: outputdirectorywriter.h:80
void removeUnknownFiles(const QList< FilePath > &files)
Definition: outputdirectorywriter.cpp:171
void storeIndex()
Definition: outputdirectorywriter.cpp:91
void removeObsoleteFiles(const Uuid &job)
Definition: outputdirectorywriter.cpp:138
void aboutToWriteFile(const FilePath &fp)
const FilePath & getDirectoryPath() const noexcept
Definition: outputdirectorywriter.h:55
const QMultiHash< Uuid, FilePath > & getWrittenFiles() const noexcept
Definition: outputdirectorywriter.h:56
QMap< FilePath, Uuid > mIndex
Definition: outputdirectorywriter.h:78
bool loadIndex()
Definition: outputdirectorywriter.cpp:65
void aboutToRemoveFile(const FilePath &fp)
const FilePath mIndexFilePath
Definition: outputdirectorywriter.h:77
FilePath beginWritingFile(const Uuid &job, const QString &relPath)
Definition: outputdirectorywriter.cpp:106
OutputDirectoryWriter & operator=(const OutputDirectoryWriter &rhs)=delete
OutputDirectoryWriter(const OutputDirectoryWriter &other)=delete
QMultiHash< Uuid, FilePath > mWrittenFiles
Definition: outputdirectorywriter.h:81
~OutputDirectoryWriter() noexcept
Definition: outputdirectorywriter.cpp:50
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77