LibrePCB Developers Documentation
Loading...
Searching...
No Matches
library.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_LIBRARY_H
21#define LIBREPCB_CORE_LIBRARY_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../types/simplestring.h"
27#include "../types/uuid.h"
28#include "librarybaseelement.h"
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39/*******************************************************************************
40 * Class Library
41 ******************************************************************************/
42
46class Library final : public LibraryBaseElement {
47 Q_OBJECT
48
49public:
50 // Constructors / Destructor
51 Library() = delete;
52 Library(const Library& other) = delete;
53 Library(const Uuid& uuid, const Version& version, const QString& author,
54 const ElementName& name_en_US, const QString& description_en_US,
55 const QString& keywords_en_US);
56 ~Library() noexcept;
57
58 // Getters
59 template <typename ElementType>
60 QString getElementsDirectoryName() const noexcept;
61 const QUrl& getUrl() const noexcept { return mUrl; }
62 const QSet<Uuid>& getDependencies() const noexcept { return mDependencies; }
63 const QByteArray& getIcon() const noexcept { return mIcon; }
64 QPixmap getIconAsPixmap() const noexcept;
65 const SimpleString& getManufacturer() const noexcept { return mManufacturer; }
66
67 // Setters
68 void setUrl(const QUrl& url) noexcept { mUrl = url; }
69 void setDependencies(const QSet<Uuid>& deps) noexcept {
70 mDependencies = deps;
71 }
72 void setIcon(const QByteArray& png) noexcept { mIcon = png; }
73 void setManufacturer(const SimpleString& value) noexcept {
74 mManufacturer = value;
75 }
76
77 // General Methods
78 virtual void save() override;
79 virtual void moveTo(TransactionalDirectory& dest) override;
80 template <typename ElementType>
81 QStringList searchForElements() const noexcept;
82
83 // Operator Overloadings
84 Library& operator=(const Library& rhs) = delete;
85
86 // Static Methods
87 static std::unique_ptr<Library> open(
88 std::unique_ptr<TransactionalDirectory> directory,
89 bool abortBeforeMigration = false);
90 static QString getShortElementName() noexcept {
91 return QStringLiteral("lib");
92 }
93 static QString getLongElementName() noexcept {
94 return QStringLiteral("library");
95 }
96
97protected:
98 virtual void serialize(SExpression& root) const override;
99
100private: // Methods
101 Library(std::unique_ptr<TransactionalDirectory> directory,
102 const SExpression& root);
103
104private: // Data
105 QUrl mUrl;
106 QSet<Uuid> mDependencies;
107 QByteArray mIcon;
109};
110
111/*******************************************************************************
112 * End of File
113 ******************************************************************************/
114
115} // namespace librepcb
116
117#endif
The LibraryBaseElement class.
Definition librarybaseelement.h:48
The Library class represents a library directory.
Definition library.h:46
void setIcon(const QByteArray &png) noexcept
Definition library.h:72
void setManufacturer(const SimpleString &value) noexcept
Definition library.h:73
void setUrl(const QUrl &url) noexcept
Definition library.h:68
QUrl mUrl
Definition library.h:105
SimpleString mManufacturer
Definition library.h:108
void setDependencies(const QSet< Uuid > &deps) noexcept
Definition library.h:69
const SimpleString & getManufacturer() const noexcept
Definition library.h:65
static std::unique_ptr< Library > open(std::unique_ptr< TransactionalDirectory > directory, bool abortBeforeMigration=false)
Definition library.cpp:169
QByteArray mIcon
Definition library.h:107
const QSet< Uuid > & getDependencies() const noexcept
Definition library.h:62
virtual void save() override
Definition library.cpp:117
QStringList searchForElements() const noexcept
Definition library.cpp:142
QSet< Uuid > mDependencies
Definition library.h:106
static QString getLongElementName() noexcept
Definition library.h:93
Library(const Library &other)=delete
QPixmap getIconAsPixmap() const noexcept
Definition library.cpp:107
~Library() noexcept
Definition library.cpp:85
const QUrl & getUrl() const noexcept
Definition library.h:61
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition library.cpp:201
QString getElementsDirectoryName() const noexcept
Definition library.cpp:93
const QByteArray & getIcon() const noexcept
Definition library.h:63
virtual void moveTo(TransactionalDirectory &dest) override
Definition library.cpp:128
static QString getShortElementName() noexcept
Definition library.h:90
The SExpression class.
Definition sexpression.h:69
Helper class to access a subdirectory of TransactionalFileSystem.
Definition transactionaldirectory.h:51
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Version class represents a version number in the format "1.42.7".
Definition version.h:58
Definition occmodel.cpp:76
type_safe::constrained_type< QString, SimpleStringConstraint, SimpleStringVerifier > SimpleString
Definition simplestring.h:79
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84
Definition uuid.h:186