LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
componentsymbolvariantitem.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_COMPONENTSYMBOLVARIANTITEM_H
21 #define LIBREPCB_LIBRARY_COMPONENTSYMBOLVARIANTITEM_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "componentpinsignalmap.h"
28 
34 #include <librepcb/common/uuid.h>
35 
36 #include <QtCore>
37 
38 /*******************************************************************************
39  * Namespace / Forward Declarations
40  ******************************************************************************/
41 namespace librepcb {
42 namespace library {
43 
44 /*******************************************************************************
45  * Class ComponentSymbolVariantItem
46  ******************************************************************************/
47 
62  Q_DECLARE_TR_FUNCTIONS(ComponentSymbolVariantItem)
63 
64 public:
65  // Constructors / Destructor
66  ComponentSymbolVariantItem() = delete;
69  const Uuid& uuid, const Uuid& symbolUuid, const Point& symbolPos,
70  const Angle& symbolRotation, bool isRequired,
71  const ComponentSymbolVariantItemSuffix& suffix) noexcept;
72  explicit ComponentSymbolVariantItem(const SExpression& node);
73  ~ComponentSymbolVariantItem() noexcept;
74 
75  // Getters: Attributes
76  const Uuid& getUuid() const noexcept { return mUuid; }
77  const Uuid& getSymbolUuid() const noexcept { return mSymbolUuid; }
78  const Point& getSymbolPosition() const noexcept { return mSymbolPos; }
79  const Angle& getSymbolRotation() const noexcept { return mSymbolRot; }
80  bool isRequired() const noexcept { return mIsRequired; }
81  const ComponentSymbolVariantItemSuffix& getSuffix() const noexcept {
82  return mSuffix;
83  }
84 
85  // Setters: Attributes
86  void setSymbolUuid(const Uuid& uuid) noexcept { mSymbolUuid = uuid; }
87  void setSymbolPosition(const Point& pos) noexcept { mSymbolPos = pos; }
88  void setSymbolRotation(const Angle& rot) noexcept { mSymbolRot = rot; }
89  void setIsRequired(bool required) noexcept { mIsRequired = required; }
90  void setSuffix(const ComponentSymbolVariantItemSuffix& suffix) noexcept {
91  mSuffix = suffix;
92  }
93 
94  // Pin-Signal-Map Methods
96  const ComponentPinSignalMap& getPinSignalMap() const noexcept {
97  return mPinSignalMap;
98  }
99 
101  void serialize(SExpression& root) const override;
102 
103  // Operator Overloadings
104  bool operator==(const ComponentSymbolVariantItem& rhs) const noexcept;
105  bool operator!=(const ComponentSymbolVariantItem& rhs) const noexcept {
106  return !(*this == rhs);
107  }
109  const ComponentSymbolVariantItem& rhs) noexcept;
110 
111 private: // Data
119 };
120 
121 /*******************************************************************************
122  * Class ComponentSymbolVariantItemList
123  ******************************************************************************/
124 
126  static constexpr const char* tagname = "gate";
127 };
140 
141 /*******************************************************************************
142  * Class ComponentSymbolVariantItemListHelpers
143  ******************************************************************************/
144 
146 public:
147  ComponentSymbolVariantItemListHelpers() = delete; // disable instantiation
148 
149  static QSet<Uuid> getAllSymbolUuids(
150  const ComponentSymbolVariantItemList& list) noexcept {
151  QSet<Uuid> set;
152  for (const auto& item : list) {
153  set.insert(item.getSymbolUuid());
154  }
155  return set;
156  }
157 };
158 
159 /*******************************************************************************
160  * End of File
161  ******************************************************************************/
162 
163 } // namespace library
164 } // namespace librepcb
165 
166 #endif // LIBREPCB_LIBRARY_COMPONENTSYMBOLVARIANTITEM_H
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentsymbolvariantitem.cpp:93
const Uuid & getSymbolUuid() const noexcept
Definition: componentsymbolvariantitem.h:77
Uuid mSymbolUuid
Definition: componentsymbolvariantitem.h:113
ComponentPinSignalMap mPinSignalMap
Definition: componentsymbolvariantitem.h:118
type_safe::constrained_type< QString, ComponentSymbolVariantItemSuffixConstraint, ComponentSymbolVariantItemSuffixVerifier > ComponentSymbolVariantItemSuffix
Definition: componentsymbolvariantitemsuffix.h:79
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
const Angle & getSymbolRotation() const noexcept
Definition: componentsymbolvariantitem.h:79
void setSymbolPosition(const Point &pos) noexcept
Definition: componentsymbolvariantitem.h:87
ComponentSymbolVariantItem & operator=(const ComponentSymbolVariantItem &rhs) noexcept
Definition: componentsymbolvariantitem.cpp:119
void setSuffix(const ComponentSymbolVariantItemSuffix &suffix) noexcept
Definition: componentsymbolvariantitem.h:90
void setIsRequired(bool required) noexcept
Definition: componentsymbolvariantitem.h:89
const Point & getSymbolPosition() const noexcept
Definition: componentsymbolvariantitem.h:78
Uuid mUuid
Definition: componentsymbolvariantitem.h:112
Point mSymbolPos
Definition: componentsymbolvariantitem.h:114
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
~ComponentSymbolVariantItem() noexcept
Definition: componentsymbolvariantitem.cpp:86
Definition: componentsymbolvariantitem.h:125
Angle mSymbolRot
Definition: componentsymbolvariantitem.h:115
const ComponentPinSignalMap & getPinSignalMap() const noexcept
Definition: componentsymbolvariantitem.h:96
static QSet< Uuid > getAllSymbolUuids(const ComponentSymbolVariantItemList &list) noexcept
Definition: componentsymbolvariantitem.h:149
const Uuid & getUuid() const noexcept
Definition: componentsymbolvariantitem.h:76
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
ComponentPinSignalMap & getPinSignalMap() noexcept
Definition: componentsymbolvariantitem.h:95
bool operator==(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.cpp:107
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
bool isRequired() const noexcept
Definition: componentsymbolvariantitem.h:80
const ComponentSymbolVariantItemSuffix & getSuffix() const noexcept
Definition: componentsymbolvariantitem.h:81
static constexpr const char * tagname
Definition: componentsymbolvariantitem.h:126
void setSymbolUuid(const Uuid &uuid) noexcept
Definition: componentsymbolvariantitem.h:86
bool mIsRequired
Definition: componentsymbolvariantitem.h:116
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
Definition: componentsymbolvariantitem.h:145
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition: componentsymbolvariantitem.h:61
ComponentSymbolVariantItemSuffix mSuffix
Definition: componentsymbolvariantitem.h:117
The SExpression class.
Definition: sexpression.h:60
void setSymbolRotation(const Angle &rot) noexcept
Definition: componentsymbolvariantitem.h:88
bool operator!=(const ComponentSymbolVariantItem &rhs) const noexcept
Definition: componentsymbolvariantitem.h:105