LibrePCB Developers Documentation
fileformatmigration.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_FILEFORMATMIGRATION_H
21#define LIBREPCB_CORE_FILEFORMATMIGRATION_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../types/version.h"
27
28#include <QtCore>
29
30#include <memory>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class TransactionalDirectory;
38
39/*******************************************************************************
40 * Class FileFormatMigration
41 ******************************************************************************/
42
46class FileFormatMigration : public QObject {
47 Q_OBJECT
48
49public:
50 // Types
51 struct Message {
52 enum class Severity : int { Note = 0, Warning = 1, Critical = 2 };
57 QString message;
58
59 QString getSeverityStrTr() const noexcept;
60 };
61
62 // Constructors / Destructor
65 const Version& toVersion,
66 QObject* parent = nullptr) noexcept;
68 virtual ~FileFormatMigration() noexcept;
69
70 // Getters
71 const Version& getFromVersion() const noexcept { return mFromVersion; }
72 const Version& getToVersion() const noexcept { return mToVersion; }
73
74 // General Methods
77 virtual void upgradeSymbol(TransactionalDirectory& dir) = 0;
78 virtual void upgradePackage(TransactionalDirectory& dir) = 0;
80 virtual void upgradeDevice(TransactionalDirectory& dir) = 0;
81 virtual void upgradeLibrary(TransactionalDirectory& dir) = 0;
83 QList<Message>& messages) = 0;
85
86 // Static Methods
87 static QList<std::shared_ptr<FileFormatMigration>> getMigrations(
88 const Version& fileFormat);
89
90 // Operator Overloadings
92
93protected: // Methods
95 int affectedItems = -1) const noexcept;
96 void upgradeVersionFile(TransactionalDirectory& dir, const QString& fileName);
97
98protected: // Data
101};
102
103/*******************************************************************************
104 * End of File
105 ******************************************************************************/
106
107} // namespace librepcb
108
109#endif
Base class for any file format migration.
Definition: fileformatmigration.h:46
void upgradeVersionFile(TransactionalDirectory &dir, const QString &fileName)
Definition: fileformatmigration.cpp:107
virtual void upgradeWorkspaceData(TransactionalDirectory &dir)=0
virtual void upgradeLibrary(TransactionalDirectory &dir)=0
virtual void upgradeSymbol(TransactionalDirectory &dir)=0
virtual void upgradeDevice(TransactionalDirectory &dir)=0
virtual void upgradeComponent(TransactionalDirectory &dir)=0
Version mToVersion
Definition: fileformatmigration.h:100
Version mFromVersion
Definition: fileformatmigration.h:99
Message buildMessage(Message::Severity severity, const QString &message, int affectedItems=-1) const noexcept
Definition: fileformatmigration.cpp:96
virtual void upgradePackageCategory(TransactionalDirectory &dir)=0
static QList< std::shared_ptr< FileFormatMigration > > getMigrations(const Version &fileFormat)
Definition: fileformatmigration.cpp:74
virtual void upgradeProject(TransactionalDirectory &dir, QList< Message > &messages)=0
const Version & getFromVersion() const noexcept
Definition: fileformatmigration.h:71
FileFormatMigration & operator=(const FileFormatMigration &rhs)=delete
const Version & getToVersion() const noexcept
Definition: fileformatmigration.h:72
virtual void upgradeComponentCategory(TransactionalDirectory &dir)=0
virtual void upgradePackage(TransactionalDirectory &dir)=0
Helper class to access a subdirectory of TransactionalFileSystem.
Definition: transactionaldirectory.h:51
The Version class represents a version number in the format "1.42.7".
Definition: version.h:58
Definition: occmodel.cpp:77
Definition: fileformatmigration.h:51
Version toVersion
Definition: fileformatmigration.h:54
Severity severity
Definition: fileformatmigration.h:55
Severity
Definition: fileformatmigration.h:52
Version fromVersion
Definition: fileformatmigration.h:53
int affectedItems
Definition: fileformatmigration.h:56
QString message
Definition: fileformatmigration.h:57
QString getSeverityStrTr() const noexcept
Definition: fileformatmigration.cpp:44