LibrePCB Developers Documentation
componentpinsignalmap.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_COMPONENTPINSIGNALMAP_H
21#define LIBREPCB_CORE_COMPONENTPINSIGNALMAP_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../serialization/serializableobjectlist.h"
27#include "../../types/uuid.h"
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37/*******************************************************************************
38 * Class ComponentPinSignalMapItem
39 ******************************************************************************/
40
51 Q_DECLARE_TR_FUNCTIONS(ComponentPinSignalMapItem)
52
53public:
54 // Signals
55 enum class Event {
56 PinUuidChanged,
57 SignalUuidChanged,
58 DisplayTypeChanged,
59 };
62
63 // Constructors / Destructor
66 ComponentPinSignalMapItem(const Uuid& pin, const tl::optional<Uuid>& signal,
67 const CmpSigPinDisplayType& displayType) noexcept;
68 explicit ComponentPinSignalMapItem(const SExpression& node);
70
71 // Getters
72 const Uuid& getUuid() const noexcept {
73 return mPinUuid;
74 } // used for UuidObjectMap
75 const Uuid& getPinUuid() const noexcept { return mPinUuid; }
76 const tl::optional<Uuid>& getSignalUuid() const noexcept {
77 return mSignalUuid;
78 }
79 const CmpSigPinDisplayType& getDisplayType() const noexcept {
80 return mDisplayType;
81 }
82
83 // Setters
84 bool setSignalUuid(const tl::optional<Uuid>& uuid) noexcept;
85 bool setDisplayType(const CmpSigPinDisplayType& type) noexcept;
86
87 // General Methods
88
94 void serialize(SExpression& root) const;
95
96 // Operator Overloadings
97 bool operator==(const ComponentPinSignalMapItem& rhs) const noexcept;
98 bool operator!=(const ComponentPinSignalMapItem& rhs) const noexcept {
99 return !(*this == rhs);
100 }
102 const ComponentPinSignalMapItem& rhs) noexcept;
103
104private: // Data
106 tl::optional<Uuid> mSignalUuid;
108};
109
110/*******************************************************************************
111 * Class PinSignalMap
112 ******************************************************************************/
113
115 static constexpr const char* tagname = "pin";
116};
121
122/*******************************************************************************
123 * Class ComponentPinSignalMapHelpers
124 ******************************************************************************/
125
127public:
128 ComponentPinSignalMapHelpers() = delete; // disable instantiation
129
131 const QSet<Uuid> pins,
132 const CmpSigPinDisplayType& display =
135 foreach (const Uuid& pin, pins) {
136 map.append(std::make_shared<ComponentPinSignalMapItem>(pin, tl::nullopt,
137 display));
138 }
139 return map;
140 }
141};
142
143/*******************************************************************************
144 * End of File
145 ******************************************************************************/
146
147} // namespace librepcb
148
149#endif
The CmpSigPinDisplayType clas.
Definition: cmpsigpindisplaytype.h:40
static const CmpSigPinDisplayType & componentSignal() noexcept
display the name of the component signal
Definition: cmpsigpindisplaytype.h:106
Definition: componentpinsignalmap.h:126
static ComponentPinSignalMap create(const QSet< Uuid > pins, const CmpSigPinDisplayType &display=CmpSigPinDisplayType::componentSignal()) noexcept
Definition: componentpinsignalmap.h:130
The ComponentPinSignalMapItem class maps a symbol pin to a component signal.
Definition: componentpinsignalmap.h:50
~ComponentPinSignalMapItem() noexcept
Definition: componentpinsignalmap.cpp:61
CmpSigPinDisplayType mDisplayType
Definition: componentpinsignalmap.h:107
Event
Definition: componentpinsignalmap.h:55
bool operator!=(const ComponentPinSignalMapItem &rhs) const noexcept
Definition: componentpinsignalmap.h:98
Uuid mPinUuid
must be valid
Definition: componentpinsignalmap.h:105
ComponentPinSignalMapItem & operator=(const ComponentPinSignalMapItem &rhs) noexcept
Definition: componentpinsignalmap.cpp:111
const Uuid & getPinUuid() const noexcept
Definition: componentpinsignalmap.h:75
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: componentpinsignalmap.cpp:93
const Uuid & getUuid() const noexcept
Definition: componentpinsignalmap.h:72
const tl::optional< Uuid > & getSignalUuid() const noexcept
Definition: componentpinsignalmap.h:76
Signal< ComponentPinSignalMapItem, Event > onEdited
Definition: componentpinsignalmap.h:60
Slot< ComponentPinSignalMapItem, Event > OnEditedSlot
Definition: componentpinsignalmap.h:61
bool setSignalUuid(const tl::optional< Uuid > &uuid) noexcept
Definition: componentpinsignalmap.cpp:68
bool operator==(const ComponentPinSignalMapItem &rhs) const noexcept
Definition: componentpinsignalmap.cpp:103
const CmpSigPinDisplayType & getDisplayType() const noexcept
Definition: componentpinsignalmap.h:79
bool setDisplayType(const CmpSigPinDisplayType &type) noexcept
Definition: componentpinsignalmap.cpp:78
tl::optional< Uuid > mSignalUuid
tl::nullopt if not connected to a signal
Definition: componentpinsignalmap.h:106
The SExpression class.
Definition: sexpression.h:69
int append(const std::shared_ptr< T > &obj) noexcept
Definition: serializableobjectlist.h:342
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
Definition: componentpinsignalmap.h:114
static constexpr const char * tagname
Definition: componentpinsignalmap.h:115