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