LibrePCB Developers Documentation
Loading...
Searching...
No Matches
projectloader.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_PROJECTLOADER_H
21#define LIBREPCB_CORE_PROJECTLOADER_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../serialization/fileformatmigration.h"
27
28#include <QtCore>
29
30#include <memory>
31#include <optional>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Board;
39class Project;
40class ProjectLibrary;
41class SExpression;
42class Schematic;
43class TransactionalDirectory;
44
45/*******************************************************************************
46 * Class ProjectLoader
47 ******************************************************************************/
48
52class ProjectLoader final : public QObject {
53 Q_OBJECT
54
55public:
56 // Constructors / Destructor
57 explicit ProjectLoader(QObject* parent = nullptr) noexcept;
58 ProjectLoader(const ProjectLoader& other) = delete;
59 ~ProjectLoader() noexcept;
60
61 // Setters
62 void setAutoAssignDeviceModels(bool v) noexcept {
64 }
65
66 // General Methods
67 std::unique_ptr<Project> open(
68 std::unique_ptr<TransactionalDirectory> directory,
69 const QString& filename);
70 const std::optional<QList<FileFormatMigration::Message>>& getUpgradeMessages()
71 const noexcept {
72 return mUpgradeMessages;
73 }
74
75 // Operator Overloadings
76 ProjectLoader& operator=(const ProjectLoader& rhs) = delete;
77
78private: // Methods
79 void loadMetadata(Project& p);
80 void loadSettings(Project& p);
81 void loadOutputJobs(Project& p);
82 void loadLibrary(Project& p);
83 template <typename ElementType>
84 void loadLibraryElements(Project& p, const QString& dirname,
85 const QString& type,
86 void (ProjectLibrary::*addFunction)(ElementType&));
87 void loadCircuit(Project& p);
88 void loadErc(Project& p);
89 void loadSchematics(Project& p);
90 void loadSchematic(Project& p, const QString& relativeFilePath);
91 void loadSchematicSymbol(Schematic& s, const SExpression& node);
92 void loadSchematicNetSegment(Schematic& s, const SExpression& node);
93 void loadBoards(Project& p);
94 void loadBoard(Project& p, const QString& relativeFilePath);
95 void loadBoardDeviceInstance(Board& b, const SExpression& node);
96 void loadBoardNetSegment(Board& b, const SExpression& node);
97 void loadBoardPlane(Board& b, const SExpression& node);
99
100private: // Data
102 std::optional<QList<FileFormatMigration::Message>> mUpgradeMessages;
103};
104
105/*******************************************************************************
106 * End of File
107 ******************************************************************************/
108
109} // namespace librepcb
110
111#endif
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:73
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The ProjectLibrary class.
Definition projectlibrary.h:52
Helper to load a librepcb::Project from the file system.
Definition projectloader.h:52
void loadBoardDeviceInstance(Board &b, const SExpression &node)
Definition projectloader.cpp:641
const std::optional< QList< FileFormatMigration::Message > > & getUpgradeMessages() const noexcept
Definition projectloader.h:70
std::optional< QList< FileFormatMigration::Message > > mUpgradeMessages
Definition projectloader.h:102
std::unique_ptr< Project > open(std::unique_ptr< TransactionalDirectory > directory, const QString &filename)
Definition projectloader.cpp:90
void loadBoardUserSettings(Board &b)
Definition projectloader.cpp:804
~ProjectLoader() noexcept
Definition projectloader.cpp:83
void loadMetadata(Project &p)
Definition projectloader.cpp:175
void loadBoard(Project &p, const QString &relativeFilePath)
Definition projectloader.cpp:555
void loadSchematics(Project &p)
Definition projectloader.cpp:397
ProjectLoader & operator=(const ProjectLoader &rhs)=delete
void loadCircuit(Project &p)
Definition projectloader.cpp:280
bool mAutoAssignDeviceModels
Definition projectloader.h:101
void loadErc(Project &p)
Definition projectloader.cpp:381
void loadLibraryElements(Project &p, const QString &dirname, const QString &type, void(ProjectLibrary::*addFunction)(ElementType &))
Definition projectloader.cpp:253
void loadOutputJobs(Project &p)
Definition projectloader.cpp:230
void loadBoardPlane(Board &b, const SExpression &node)
Definition projectloader.cpp:774
void loadLibrary(Project &p)
Definition projectloader.cpp:239
void loadSchematicSymbol(Schematic &s, const SExpression &node)
Definition projectloader.cpp:442
ProjectLoader(const ProjectLoader &other)=delete
void loadBoardNetSegment(Board &b, const SExpression &node)
Definition projectloader.cpp:677
void loadSettings(Project &p)
Definition projectloader.cpp:191
void setAutoAssignDeviceModels(bool v) noexcept
Definition projectloader.h:62
void loadBoards(Project &p)
Definition projectloader.cpp:544
void loadSchematic(Project &p, const QString &relativeFilePath)
Definition projectloader.cpp:409
void loadSchematicNetSegment(Schematic &s, const SExpression &node)
Definition projectloader.cpp:464
The SExpression class.
Definition sexpression.h:69
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:74
Definition occmodel.cpp:76