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  // Constructors / Destructor
60  ComponentPinSignalMapItem() = delete;
62  ComponentPinSignalMapItem(const Uuid& pin, const tl::optional<Uuid>& signal,
63  const CmpSigPinDisplayType& displayType) noexcept;
64  explicit ComponentPinSignalMapItem(const SExpression& node);
65  ~ComponentPinSignalMapItem() noexcept;
66 
67  // Getters
68  const Uuid& getUuid() const noexcept {
69  return mPinUuid;
70  } // used for UuidObjectMap
71  const Uuid& getPinUuid() const noexcept { return mPinUuid; }
72  const tl::optional<Uuid>& getSignalUuid() const noexcept {
73  return mSignalUuid;
74  }
75  const CmpSigPinDisplayType& getDisplayType() const noexcept {
76  return mDisplayType;
77  }
78 
79  // Setters
80  void setSignalUuid(const tl::optional<Uuid>& uuid) noexcept {
81  mSignalUuid = uuid;
82  }
83  void setDisplayType(const CmpSigPinDisplayType& type) noexcept {
84  mDisplayType = type;
85  }
86 
88  void serialize(SExpression& root) const override;
89 
90  // Operator Overloadings
91  bool operator==(const ComponentPinSignalMapItem& rhs) const noexcept;
92  bool operator!=(const ComponentPinSignalMapItem& rhs) const noexcept {
93  return !(*this == rhs);
94  }
96  const ComponentPinSignalMapItem& rhs) noexcept;
97 
98 private: // Data
100  tl::optional<Uuid> mSignalUuid;
102 };
103 
104 /*******************************************************************************
105  * Class PinSignalMap
106  ******************************************************************************/
107 
109  static constexpr const char* tagname = "pin";
110 };
111 using ComponentPinSignalMap =
123 
124 /*******************************************************************************
125  * Class ComponentPinSignalMapHelpers
126  ******************************************************************************/
127 
129 public:
130  ComponentPinSignalMapHelpers() = delete; // disable instantiation
131 
133  const QSet<Uuid> pins,
134  const CmpSigPinDisplayType& display =
137  foreach (const Uuid& pin, pins) {
138  map.append(std::make_shared<ComponentPinSignalMapItem>(pin, tl::nullopt,
139  display));
140  }
141  return map;
142  }
143 };
144 
145 /*******************************************************************************
146  * End of File
147  ******************************************************************************/
148 
149 } // namespace library
150 } // namespace librepcb
151 
152 #endif // LIBREPCB_LIBRARY_COMPONENTPINSIGNALMAP_H
const tl::optional< Uuid > & getSignalUuid() const noexcept
Definition: componentpinsignalmap.h:72
static ComponentPinSignalMap create(const QSet< Uuid > pins, const CmpSigPinDisplayType &display=CmpSigPinDisplayType::componentSignal()) noexcept
Definition: componentpinsignalmap.h:132
void setSignalUuid(const tl::optional< Uuid > &uuid) noexcept
Definition: componentpinsignalmap.h:80
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
The CmpSigPinDisplayType clas.
Definition: cmpsigpindisplaytype.h:46
void setDisplayType(const CmpSigPinDisplayType &type) noexcept
Definition: componentpinsignalmap.h:83
const Uuid & getUuid() const noexcept
Definition: componentpinsignalmap.h:68
static constexpr const char * tagname
Definition: componentpinsignalmap.h:109
ComponentPinSignalMapItem & operator=(const ComponentPinSignalMapItem &rhs) noexcept
Definition: componentpinsignalmap.cpp:82
static const CmpSigPinDisplayType & componentSignal() noexcept
display the name of the component signal
Definition: cmpsigpindisplaytype.h:112
const CmpSigPinDisplayType & getDisplayType() const noexcept
Definition: componentpinsignalmap.h:75
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:44
const Uuid & getPinUuid() const noexcept
Definition: componentpinsignalmap.h:71
Definition: componentpinsignalmap.h:108
The ComponentPinSignalMapItem class maps a symbol pin to a component signal.
Definition: componentpinsignalmap.h:55
Uuid mPinUuid
must be valid
Definition: componentpinsignalmap.h:99
~ComponentPinSignalMapItem() noexcept
Definition: componentpinsignalmap.cpp:57
Definition: componentpinsignalmap.h:128
int append(const std::shared_ptr< T > &obj) noexcept
Definition: serializableobjectlist.h:307
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentpinsignalmap.cpp:64
CmpSigPinDisplayType mDisplayType
Definition: componentpinsignalmap.h:101
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
bool operator!=(const ComponentPinSignalMapItem &rhs) const noexcept
Definition: componentpinsignalmap.h:92
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:74
tl::optional< Uuid > mSignalUuid
tl::nullopt if not connected to a signal
Definition: componentpinsignalmap.h:100
The SExpression class.
Definition: sexpression.h:60