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 
46 class Library final : public LibraryBaseElement {
47  Q_OBJECT
48 
49 public:
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  explicit Library(std::unique_ptr<TransactionalDirectory> directory);
57  ~Library() noexcept;
58 
59  // Getters
60  template <typename ElementType>
61  QString getElementsDirectoryName() const noexcept;
62  const QUrl& getUrl() const noexcept { return mUrl; }
63  const QSet<Uuid>& getDependencies() const noexcept { return mDependencies; }
64  const QByteArray& getIcon() const noexcept { return mIcon; }
65  QPixmap getIconAsPixmap() const noexcept;
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 
74  // General Methods
75  virtual void save() override;
76  virtual void moveTo(TransactionalDirectory& dest) override;
77  template <typename ElementType>
78  QStringList searchForElements() const noexcept;
79 
80  // Operator Overloadings
81  Library& operator=(const Library& rhs) = delete;
82 
83  // Static Methods
84  static QString getShortElementName() noexcept {
85  return QStringLiteral("lib");
86  }
87  static QString getLongElementName() noexcept {
88  return QStringLiteral("library");
89  }
90 
91 private: // Methods
93  virtual void serialize(SExpression& root) const override;
94 
95 private: // Data
96  QUrl mUrl;
97  QSet<Uuid> mDependencies;
98  QByteArray mIcon;
99 };
100 
101 /*******************************************************************************
102  * End of File
103  ******************************************************************************/
104 
105 } // namespace library
106 } // namespace librepcb
107 
108 #endif // LIBREPCB_LIBRARY_LIBRARY_H
QString getElementsDirectoryName() const noexcept
Definition: library.cpp:96
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:131
The Library class represents a library directory.
Definition: library.h:46
static QString getShortElementName() noexcept
Definition: library.h:84
virtual void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: library.cpp:174
Helper class to access a subdirectory of TransactionalFileSystem.
Definition: transactionaldirectory.h:52
const QUrl & getUrl() const noexcept
Definition: library.h:62
QSet< Uuid > mDependencies
Definition: library.h:97
void setIcon(const QByteArray &png) noexcept
Definition: library.h:72
const QByteArray & getIcon() const noexcept
Definition: library.h:64
The LibraryBaseElement class.
Definition: librarybaseelement.h:52
void setUrl(const QUrl &url) noexcept
Definition: library.h:68
QByteArray mIcon
Definition: library.h:98
QUrl mUrl
Definition: library.h:96
QStringList searchForElements() const noexcept
Definition: library.cpp:145
virtual void save() override
Definition: library.cpp:120
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:69
const QSet< Uuid > & getDependencies() const noexcept
Definition: library.h:63
static QString getLongElementName() noexcept
Definition: library.h:87
~Library() noexcept
Definition: library.cpp:88
The SExpression class.
Definition: sexpression.h:57
QPixmap getIconAsPixmap() const noexcept
Definition: library.cpp:110
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92