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