LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
componentsignal.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_COMPONENTSIGNAL_H
21 #define LIBREPCB_LIBRARY_COMPONENTSIGNAL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
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 ComponentSignal
44  ******************************************************************************/
45 
49 class ComponentSignal final : public QObject, public SerializableObject {
50  Q_OBJECT
51 
52 public:
53  // Constructors / Destructor
54  ComponentSignal() = delete;
55  ComponentSignal(const ComponentSignal& other) noexcept;
56  ComponentSignal(const Uuid& uuid, const CircuitIdentifier& name,
57  const SignalRole& role, const QString& forcedNetName,
58  bool isRequired, bool isNegated, bool isClock) noexcept;
59  explicit ComponentSignal(const SExpression& node);
60  ~ComponentSignal() noexcept;
61 
62  // Getters
63  const Uuid& getUuid() const noexcept { return mUuid; }
64  const CircuitIdentifier& getName() const noexcept { return mName; }
65  const SignalRole& getRole() const noexcept { return mRole; }
66  const QString& getForcedNetName() const noexcept { return mForcedNetName; }
67  bool isRequired() const noexcept { return mIsRequired; }
68  bool isNegated() const noexcept { return mIsNegated; }
69  bool isClock() const noexcept { return mIsClock; }
70  bool isNetSignalNameForced() const noexcept {
71  return !mForcedNetName.isEmpty();
72  }
73 
74  // Setters
75  void setName(const CircuitIdentifier& name) noexcept;
76  void setRole(const SignalRole& role) noexcept;
77  void setForcedNetName(const QString& name) noexcept;
78  void setIsRequired(bool required) noexcept;
79  void setIsNegated(bool negated) noexcept;
80  void setIsClock(bool clock) noexcept;
81 
82  // General Methods
83 
85  void serialize(SExpression& root) const override;
86 
87  // Operator Overloadings
88  bool operator==(const ComponentSignal& rhs) const noexcept;
89  bool operator!=(const ComponentSignal& rhs) const noexcept {
90  return !(*this == rhs);
91  }
92  ComponentSignal& operator=(const ComponentSignal& rhs) noexcept;
93 
94 signals:
95  void edited();
96  void nameChanged(const CircuitIdentifier& name);
97  void roleChanged(const SignalRole& role);
98  void forcedNetNameChanged(const QString& name);
99  void isRequiredChanged(bool required);
100  void isNegatedChanged(bool negated);
101  void isClockChanged(bool clock);
102 
103 private: // Data
107  QString mForcedNetName;
110  bool mIsClock;
111 };
112 
113 /*******************************************************************************
114  * Class ComponentSignalList
115  ******************************************************************************/
116 
118  static constexpr const char* tagname = "signal";
119 };
120 using ComponentSignalList =
128 
129 /*******************************************************************************
130  * End of File
131  ******************************************************************************/
132 
133 } // namespace library
134 } // namespace librepcb
135 
136 #endif // LIBREPCB_LIBRARY_COMPONENTSIGNAL_H
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
bool isNegated() const noexcept
Definition: componentsignal.h:68
void isNegatedChanged(bool negated)
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:49
void forcedNetNameChanged(const QString &name)
void nameChanged(const CircuitIdentifier &name)
bool isClock() const noexcept
Definition: componentsignal.h:69
CircuitIdentifier mName
Definition: componentsignal.h:105
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentsignal.cpp:127
SignalRole mRole
Definition: componentsignal.h:106
bool isNetSignalNameForced() const noexcept
Definition: componentsignal.h:70
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 SignalRole & getRole() const noexcept
Definition: componentsignal.h:65
QString mForcedNetName
Definition: componentsignal.h:107
void isRequiredChanged(bool required)
The SignalRole class provides all supported electrical signal roles.
Definition: signalrole.h:45
bool mIsRequired
Definition: componentsignal.h:108
void setIsRequired(bool required) noexcept
Definition: componentsignal.cpp:102
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:89
Uuid mUuid
Definition: componentsignal.h:104
void setName(const CircuitIdentifier &name) noexcept
Definition: componentsignal.cpp:81
bool operator!=(const ComponentSignal &rhs) const noexcept
Definition: componentsignal.h:89
const CircuitIdentifier & getName() const noexcept
Definition: componentsignal.h:64
~ComponentSignal() noexcept
Definition: componentsignal.cpp:74
const Uuid & getUuid() const noexcept
Definition: componentsignal.h:63
void setIsNegated(bool negated) noexcept
Definition: componentsignal.cpp:109
void setRole(const SignalRole &role) noexcept
Definition: componentsignal.cpp:88
bool operator==(const ComponentSignal &rhs) const noexcept
Definition: componentsignal.cpp:141
const QString & getForcedNetName() const noexcept
Definition: componentsignal.h:66
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
bool isRequired() const noexcept
Definition: componentsignal.h:67
bool mIsNegated
Definition: componentsignal.h:109
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void setForcedNetName(const QString &name) noexcept
Definition: componentsignal.cpp:95
ComponentSignal & operator=(const ComponentSignal &rhs) noexcept
Definition: componentsignal.cpp:152
static constexpr const char * tagname
Definition: componentsignal.h:118
void roleChanged(const SignalRole &role)
The SExpression class.
Definition: sexpression.h:60
void setIsClock(bool clock) noexcept
Definition: componentsignal.cpp:116
bool mIsClock
Definition: componentsignal.h:110