LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_LIBRARY_H
21 #define LIBREPCB_LIBRARY_LIBRARY_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "librarybaseelement.h"
27 
28 #include <librepcb/common/uuid.h>
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 namespace library {
38 
39 /*******************************************************************************
40  * Class Library
41  ******************************************************************************/
42 
49 class Library final : public LibraryBaseElement {
50  Q_OBJECT
51 
52 public:
53  // Constructors / Destructor
54  Library() = delete;
55  Library(const Library& other) = delete;
56  Library(const Uuid& uuid, const Version& version, const QString& author,
57  const ElementName& name_en_US, const QString& description_en_US,
58  const QString& keywords_en_US);
59  explicit Library(std::unique_ptr<TransactionalDirectory> directory);
60  ~Library() noexcept;
61 
62  // Getters
63  template <typename ElementType>
64  QString getElementsDirectoryName() const noexcept;
65  const QUrl& getUrl() const noexcept { return mUrl; }
66  const QSet<Uuid>& getDependencies() const noexcept { return mDependencies; }
67  const QByteArray& getIcon() const noexcept { return mIcon; }
68  QPixmap getIconAsPixmap() const noexcept;
69 
70  // Setters
71  void setUrl(const QUrl& url) noexcept { mUrl = url; }
72  void setDependencies(const QSet<Uuid>& deps) noexcept {
73  mDependencies = deps;
74  }
75  void setIcon(const QByteArray& png) noexcept { mIcon = png; }
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 QString getShortElementName() noexcept {
88  return QStringLiteral("lib");
89  }
90  static QString getLongElementName() noexcept {
91  return QStringLiteral("library");
92  }
93 
94 private: // Methods
96  virtual void serialize(SExpression& root) const override;
97 
98 private: // Data
99  QUrl mUrl;
100  QSet<Uuid> mDependencies;
101  QByteArray mIcon;
102 };
103 
104 /*******************************************************************************
105  * End of File
106  ******************************************************************************/
107 
108 } // namespace library
109 } // namespace librepcb
110 
111 #endif // LIBREPCB_LIBRARY_LIBRARY_H
QString getElementsDirectoryName() const noexcept
Definition: library.cpp:97
The Version class represents a version number in the format "1.42.7".
Definition: version.h:60
virtual void moveTo(TransactionalDirectory &dest) override
Definition: library.cpp:132
The Library class represents a library directory.
Definition: library.h:49
static QString getShortElementName() noexcept
Definition: library.h:87
virtual void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: library.cpp:175
Helper class to access a subdirectory of TransactionalFileSystem.
Definition: transactionaldirectory.h:52
const QUrl & getUrl() const noexcept
Definition: library.h:65
QSet< Uuid > mDependencies
Definition: library.h:100
void setIcon(const QByteArray &png) noexcept
Definition: library.h:75
const QByteArray & getIcon() const noexcept
Definition: library.h:67
The LibraryBaseElement class.
Definition: librarybaseelement.h:52
void setUrl(const QUrl &url) noexcept
Definition: library.h:71
QByteArray mIcon
Definition: library.h:101
QUrl mUrl
Definition: library.h:99
QStringList searchForElements() const noexcept
Definition: library.cpp:146
virtual void save() override
Definition: library.cpp:121
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void setDependencies(const QSet< Uuid > &deps) noexcept
Definition: library.h:72
const QSet< Uuid > & getDependencies() const noexcept
Definition: library.h:66
static QString getLongElementName() noexcept
Definition: library.h:90
~Library() noexcept
Definition: library.cpp:89
The SExpression class.
Definition: sexpression.h:60
QPixmap getIconAsPixmap() const noexcept
Definition: library.cpp:111
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92