LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_COMPONENTPINSIGNALMAP_H
21 #define LIBREPCB_LIBRARY_COMPONENTPINSIGNALMAP_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "cmpsigpindisplaytype.h"
27 
32 #include <librepcb/common/uuid.h>
33 
34 #include <QtCore>
35 
36 /*******************************************************************************
37  * Namespace / Forward Declarations
38  ******************************************************************************/
39 namespace librepcb {
40 namespace library {
41 
42 /*******************************************************************************
43  * Class ComponentPinSignalMapItem
44  ******************************************************************************/
45 
56  Q_DECLARE_TR_FUNCTIONS(ComponentPinSignalMapItem)
57 
58 public:
59  // Signals
60  enum class Event {
64  };
67 
68  // Constructors / Destructor
69  ComponentPinSignalMapItem() = delete;
71  ComponentPinSignalMapItem(const Uuid& pin, const tl::optional<Uuid>& signal,
72  const CmpSigPinDisplayType& displayType) noexcept;
73  explicit ComponentPinSignalMapItem(const SExpression& node);
74  ~ComponentPinSignalMapItem() noexcept;
75 
76  // Getters
77  const Uuid& getUuid() const noexcept {
78  return mPinUuid;
79  } // used for UuidObjectMap
80  const Uuid& getPinUuid() const noexcept { return mPinUuid; }
81  const tl::optional<Uuid>& getSignalUuid() const noexcept {
82  return mSignalUuid;
83  }
84  const CmpSigPinDisplayType& getDisplayType() const noexcept {
85  return mDisplayType;
86  }
87 
88  // Setters
89  bool setSignalUuid(const tl::optional<Uuid>& uuid) noexcept;
90  bool setDisplayType(const CmpSigPinDisplayType& type) noexcept;
91 
93  void serialize(SExpression& root) const override;
94 
95  // Operator Overloadings
96  bool operator==(const ComponentPinSignalMapItem& rhs) const noexcept;
97  bool operator!=(const ComponentPinSignalMapItem& rhs) const noexcept {
98  return !(*this == rhs);
99  }
101  const ComponentPinSignalMapItem& rhs) noexcept;
102 
103 private: // Data
105  tl::optional<Uuid> mSignalUuid;
107 };
108 
109 /*******************************************************************************
110  * Class PinSignalMap
111  ******************************************************************************/
112 
114  static constexpr const char* tagname = "pin";
115 };
116 using ComponentPinSignalMap =
132 
133 /*******************************************************************************
134  * Class ComponentPinSignalMapHelpers
135  ******************************************************************************/
136 
138 public:
139  ComponentPinSignalMapHelpers() = delete; // disable instantiation
140 
142  const QSet<Uuid> pins,
143  const CmpSigPinDisplayType& display =
146  foreach (const Uuid& pin, pins) {
147  map.append(std::make_shared<ComponentPinSignalMapItem>(pin, tl::nullopt,
148  display));
149  }
150  return map;
151  }
152 };
153 
154 /*******************************************************************************
155  * End of File
156  ******************************************************************************/
157 
158 } // namespace library
159 } // namespace librepcb
160 
161 #endif // LIBREPCB_LIBRARY_COMPONENTPINSIGNALMAP_H
const tl::optional< Uuid > & getSignalUuid() const noexcept
Definition: componentpinsignalmap.h:81
Event
Definition: componentpinsignalmap.h:60
static ComponentPinSignalMap create(const QSet< Uuid > pins, const CmpSigPinDisplayType &display=CmpSigPinDisplayType::componentSignal()) noexcept
Definition: componentpinsignalmap.h:141
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
The CmpSigPinDisplayType clas.
Definition: cmpsigpindisplaytype.h:43
const Uuid & getUuid() const noexcept
Definition: componentpinsignalmap.h:77
static constexpr const char * tagname
Definition: componentpinsignalmap.h:114
ComponentPinSignalMapItem & operator=(const ComponentPinSignalMapItem &rhs) noexcept
Definition: componentpinsignalmap.cpp:112
static const CmpSigPinDisplayType & componentSignal() noexcept
display the name of the component signal
Definition: cmpsigpindisplaytype.h:109
Slot< ComponentPinSignalMapItem, Event > OnEditedSlot
Definition: componentpinsignalmap.h:66
bool setSignalUuid(const tl::optional< Uuid > &uuid) noexcept
Definition: componentpinsignalmap.cpp:69
const CmpSigPinDisplayType & getDisplayType() const noexcept
Definition: componentpinsignalmap.h:84
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
const Uuid & getPinUuid() const noexcept
Definition: componentpinsignalmap.h:80
Definition: componentpinsignalmap.h:113
The ComponentPinSignalMapItem class maps a symbol pin to a component signal.
Definition: componentpinsignalmap.h:55
Uuid mPinUuid
must be valid
Definition: componentpinsignalmap.h:104
~ComponentPinSignalMapItem() noexcept
Definition: componentpinsignalmap.cpp:62
Signal< ComponentPinSignalMapItem, Event > onEdited
Definition: componentpinsignalmap.h:65
Definition: componentpinsignalmap.h:137
int append(const std::shared_ptr< T > &obj) noexcept
Definition: serializableobjectlist.h:321
bool setDisplayType(const CmpSigPinDisplayType &type) noexcept
Definition: componentpinsignalmap.cpp:79
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentpinsignalmap.cpp:94
CmpSigPinDisplayType mDisplayType
Definition: componentpinsignalmap.h:106
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
bool operator!=(const ComponentPinSignalMapItem &rhs) const noexcept
Definition: componentpinsignalmap.h:97
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool operator==(const ComponentPinSignalMapItem &rhs) const noexcept
Definition: componentpinsignalmap.cpp:104
tl::optional< Uuid > mSignalUuid
tl::nullopt if not connected to a signal
Definition: componentpinsignalmap.h:105
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
The SExpression class.
Definition: sexpression.h:57