LibrePCB Developers Documentation
device.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_DEVICE_H
21#define LIBREPCB_CORE_DEVICE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../attribute/attribute.h"
27#include "../libraryelement.h"
28#include "devicepadsignalmap.h"
29#include "part.h"
30
31#include <QtCore>
32
33#include <memory>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40/*******************************************************************************
41 * Class Device
42 ******************************************************************************/
43
55class Device final : public LibraryElement {
56 Q_OBJECT
57
58public:
59 // Constructors / Destructor
60 Device() = delete;
61 Device(const Device& other) = delete;
62 Device(const Uuid& uuid, const Version& version, const QString& author,
63 const ElementName& name_en_US, const QString& description_en_US,
64 const QString& keywords_en_US, const Uuid& component,
65 const Uuid& package);
66 ~Device() noexcept;
67
68 // Getters
69 const Uuid& getComponentUuid() const noexcept { return mComponentUuid; }
70 const Uuid& getPackageUuid() const noexcept { return mPackageUuid; }
72 const DevicePadSignalMap& getPadSignalMap() const noexcept {
73 return mPadSignalMap;
74 }
75 AttributeList& getAttributes() noexcept { return mAttributes; }
76 const AttributeList& getAttributes() const noexcept { return mAttributes; }
77 PartList& getParts() noexcept { return mParts; }
78 const PartList& getParts() const noexcept { return mParts; }
79
80 // Setters
81 void setComponentUuid(const Uuid& uuid) noexcept;
82 void setPackageUuid(const Uuid& uuid) noexcept;
83
84 // General Methods
85 virtual RuleCheckMessageList runChecks() const override;
86
87 // Operator Overloadings
88 Device& operator=(const Device& rhs) = delete;
89
90 // Static Methods
91 static std::unique_ptr<Device> open(
92 std::unique_ptr<TransactionalDirectory> directory,
93 bool abortBeforeMigration = false);
94 static QString getShortElementName() noexcept {
95 return QStringLiteral("dev");
96 }
97 static QString getLongElementName() noexcept {
98 return QStringLiteral("device");
99 }
100
101signals:
102 void componentUuidChanged(const Uuid& uuid);
103 void packageUuidChanged(const Uuid& uuid);
104
105protected: // Methods
106 virtual void serialize(SExpression& root) const override;
107
108private: // Methods
109 Device(std::unique_ptr<TransactionalDirectory> directory,
110 const SExpression& root);
111
112private: // Data
118};
119
120/*******************************************************************************
121 * End of File
122 ******************************************************************************/
123
124} // namespace librepcb
125
126#endif
The Device class represents an instance of a component (a "real" component)
Definition: device.h:55
Uuid mPackageUuid
Definition: device.h:114
const PartList & getParts() const noexcept
Definition: device.h:78
DevicePadSignalMap & getPadSignalMap() noexcept
Definition: device.h:71
void packageUuidChanged(const Uuid &uuid)
virtual RuleCheckMessageList runChecks() const override
Definition: device.cpp:86
~Device() noexcept
Definition: device.cpp:63
PartList mParts
Definition: device.h:117
Uuid mComponentUuid
Definition: device.h:113
Device(const Device &other)=delete
Device & operator=(const Device &rhs)=delete
AttributeList & getAttributes() noexcept
Definition: device.h:75
const AttributeList & getAttributes() const noexcept
Definition: device.h:76
DevicePadSignalMap mPadSignalMap
Definition: device.h:115
const Uuid & getComponentUuid() const noexcept
Definition: device.h:69
const DevicePadSignalMap & getPadSignalMap() const noexcept
Definition: device.h:72
void setComponentUuid(const Uuid &uuid) noexcept
Definition: device.cpp:70
void setPackageUuid(const Uuid &uuid) noexcept
Definition: device.cpp:76
AttributeList mAttributes
Definition: device.h:116
PartList & getParts() noexcept
Definition: device.h:77
static QString getLongElementName() noexcept
Definition: device.h:97
static std::unique_ptr< Device > open(std::unique_ptr< TransactionalDirectory > directory, bool abortBeforeMigration=false)
Definition: device.cpp:91
void componentUuidChanged(const Uuid &uuid)
const Uuid & getPackageUuid() const noexcept
Definition: device.h:70
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition: device.cpp:123
static QString getShortElementName() noexcept
Definition: device.h:94
The LibraryElement class extends the LibraryBaseElement class with some attributes and methods which ...
Definition: libraryelement.h:45
The SExpression class.
Definition: sexpression.h:69
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The Version class represents a version number in the format "1.42.7".
Definition: version.h:58
Definition: occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84