LibrePCB Developers Documentation
libraryelement.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_LIBRARYELEMENT_H
21 #define LIBREPCB_CORE_LIBRARYELEMENT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "librarybaseelement.h"
27 #include "resource.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class LibraryElement
38  ******************************************************************************/
39 
46  Q_OBJECT
47 
48 public:
49  // Constructors / Destructor
50  LibraryElement() = delete;
51  LibraryElement(const LibraryElement& other) = delete;
52  LibraryElement(const QString& shortElementName,
53  const QString& longElementName, const Uuid& uuid,
54  const Version& version, const QString& author,
55  const ElementName& name_en_US,
56  const QString& description_en_US,
57  const QString& keywords_en_US);
58  LibraryElement(const QString& shortElementName,
59  const QString& longElementName, bool dirnameMustBeUuid,
60  std::unique_ptr<TransactionalDirectory> directory,
61  const SExpression& root);
62  virtual ~LibraryElement() noexcept;
63 
64  // Getters
65  const QString& getGeneratedBy() const noexcept { return mGeneratedBy; }
66  const QSet<Uuid>& getCategories() const noexcept { return mCategories; }
67  const ResourceList& getResources() const noexcept { return mResources; }
68 
69  // Setters
70  void setGeneratedBy(const QString& gen) noexcept { mGeneratedBy = gen; }
71  void setCategories(const QSet<Uuid>& uuids) noexcept { mCategories = uuids; }
72  void setResources(const ResourceList& resources) noexcept {
73  mResources = resources;
74  }
75 
76  // General Methods
77  virtual RuleCheckMessageList runChecks() const override;
78 
79  // Operator Overloadings
80  LibraryElement& operator=(const LibraryElement& rhs) = delete;
81 
82 protected:
83  virtual void serialize(SExpression& root) const override;
84 
85  QString mGeneratedBy;
86  QSet<Uuid> mCategories;
88 };
89 
90 /*******************************************************************************
91  * End of File
92  ******************************************************************************/
93 
94 } // namespace librepcb
95 
96 #endif
The Version class represents a version number in the format "1.42.7".
Definition: version.h:58
The LibraryBaseElement class.
Definition: librarybaseelement.h:48
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition: libraryelement.cpp:81
LibraryElement & operator=(const LibraryElement &rhs)=delete
Definition: occmodel.cpp:77
const QString & getGeneratedBy() const noexcept
Definition: libraryelement.h:65
void setCategories(const QSet< Uuid > &uuids) noexcept
Definition: libraryelement.h:71
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
QSet< Uuid > mCategories
Definition: libraryelement.h:86
QString mGeneratedBy
If not empty, the element is generated.
Definition: libraryelement.h:85
void setResources(const ResourceList &resources) noexcept
Definition: libraryelement.h:72
The LibraryElement class extends the LibraryBaseElement class with some attributes and methods which ...
Definition: libraryelement.h:45
const QSet< Uuid > & getCategories() const noexcept
Definition: libraryelement.h:66
virtual RuleCheckMessageList runChecks() const override
Definition: libraryelement.cpp:72
virtual ~LibraryElement() noexcept
Definition: libraryelement.cpp:65
void setGeneratedBy(const QString &gen) noexcept
Definition: libraryelement.h:70
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
ResourceList mResources
Definition: libraryelement.h:87
The SExpression class.
Definition: sexpression.h:69
const ResourceList & getResources() const noexcept
Definition: libraryelement.h:67
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84