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 SerializableObject {
50 public:
51  // Signals
52  enum class Event {
60  };
63 
64  // Constructors / Destructor
65  ComponentSignal() = delete;
66  ComponentSignal(const ComponentSignal& other) noexcept;
67  ComponentSignal(const Uuid& uuid, const CircuitIdentifier& name,
68  const SignalRole& role, const QString& forcedNetName,
69  bool isRequired, bool isNegated, bool isClock) noexcept;
70  explicit ComponentSignal(const SExpression& node);
71  ~ComponentSignal() noexcept;
72 
73  // Getters
74  const Uuid& getUuid() const noexcept { return mUuid; }
75  const CircuitIdentifier& getName() const noexcept { return mName; }
76  const SignalRole& getRole() const noexcept { return mRole; }
77  const QString& getForcedNetName() const noexcept { return mForcedNetName; }
78  bool isRequired() const noexcept { return mIsRequired; }
79  bool isNegated() const noexcept { return mIsNegated; }
80  bool isClock() const noexcept { return mIsClock; }
81  bool isNetSignalNameForced() const noexcept {
82  return !mForcedNetName.isEmpty();
83  }
84 
85  // Setters
86  bool setName(const CircuitIdentifier& name) noexcept;
87  bool setRole(const SignalRole& role) noexcept;
88  bool setForcedNetName(const QString& name) noexcept;
89  bool setIsRequired(bool required) noexcept;
90  bool setIsNegated(bool negated) noexcept;
91  bool setIsClock(bool clock) noexcept;
92 
93  // General Methods
94 
96  void serialize(SExpression& root) const override;
97 
98  // Operator Overloadings
99  bool operator==(const ComponentSignal& rhs) const noexcept;
100  bool operator!=(const ComponentSignal& rhs) const noexcept {
101  return !(*this == rhs);
102  }
103  ComponentSignal& operator=(const ComponentSignal& rhs) noexcept;
104 
105 private: // Data
109  QString mForcedNetName;
112  bool mIsClock;
113 };
114 
115 /*******************************************************************************
116  * Class ComponentSignalList
117  ******************************************************************************/
118 
120  static constexpr const char* tagname = "signal";
121 };
122 using ComponentSignalList =
134 
135 /*******************************************************************************
136  * End of File
137  ******************************************************************************/
138 
139 } // namespace library
140 } // namespace librepcb
141 
142 #endif // LIBREPCB_LIBRARY_COMPONENTSIGNAL_H
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:44
bool isNegated() const noexcept
Definition: componentsignal.h:79
bool setName(const CircuitIdentifier &name) noexcept
Definition: componentsignal.cpp:81
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:49
bool isClock() const noexcept
Definition: componentsignal.h:80
CircuitIdentifier mName
Definition: componentsignal.h:107
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentsignal.cpp:145
Slot< ComponentSignal, Event > OnEditedSlot
Definition: componentsignal.h:62
SignalRole mRole
Definition: componentsignal.h:108
bool isNetSignalNameForced() const noexcept
Definition: componentsignal.h:81
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 SignalRole & getRole() const noexcept
Definition: componentsignal.h:76
QString mForcedNetName
Definition: componentsignal.h:109
The SignalRole class provides all supported electrical signal roles.
Definition: signalrole.h:42
bool mIsRequired
Definition: componentsignal.h:110
bool setIsRequired(bool required) noexcept
Definition: componentsignal.cpp:111
Signal< ComponentSignal, Event > onEdited
Definition: componentsignal.h:61
Event
Definition: componentsignal.h:52
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:89
Uuid mUuid
Definition: componentsignal.h:106
bool setIsClock(bool clock) noexcept
Definition: componentsignal.cpp:131
bool operator!=(const ComponentSignal &rhs) const noexcept
Definition: componentsignal.h:100
const CircuitIdentifier & getName() const noexcept
Definition: componentsignal.h:75
~ComponentSignal() noexcept
Definition: componentsignal.cpp:74
const Uuid & getUuid() const noexcept
Definition: componentsignal.h:74
bool operator==(const ComponentSignal &rhs) const noexcept
Definition: componentsignal.cpp:159
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
const QString & getForcedNetName() const noexcept
Definition: componentsignal.h:77
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:44
bool isRequired() const noexcept
Definition: componentsignal.h:78
bool mIsNegated
Definition: componentsignal.h:111
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool setRole(const SignalRole &role) noexcept
Definition: componentsignal.cpp:91
ComponentSignal & operator=(const ComponentSignal &rhs) noexcept
Definition: componentsignal.cpp:170
static constexpr const char * tagname
Definition: componentsignal.h:120
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
bool setForcedNetName(const QString &name) noexcept
Definition: componentsignal.cpp:101
The SExpression class.
Definition: sexpression.h:57
bool setIsNegated(bool negated) noexcept
Definition: componentsignal.cpp:121
bool mIsClock
Definition: componentsignal.h:112