LibrePCB Developers Documentation
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_CORE_COMPONENTSIGNAL_H
21#define LIBREPCB_CORE_COMPONENTSIGNAL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../serialization/serializableobjectlist.h"
27#include "../../types/circuitidentifier.h"
28#include "../../types/signalrole.h"
29#include "../../types/uuid.h"
30
31#include <QtCore>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38/*******************************************************************************
39 * Class ComponentSignal
40 ******************************************************************************/
41
45class ComponentSignal final {
46public:
47 // Signals
48 enum class Event {
49 UuidChanged,
50 NameChanged,
51 RoleChanged,
52 ForcedNetNameChanged,
53 IsRequiredChanged,
54 IsNegatedChanged,
55 IsClockChanged,
56 };
59
60 // Constructors / Destructor
61 ComponentSignal() = delete;
62 ComponentSignal(const ComponentSignal& other) noexcept;
63 ComponentSignal(const Uuid& uuid, const CircuitIdentifier& name,
64 const SignalRole& role, const QString& forcedNetName,
65 bool isRequired, bool isNegated, bool isClock) noexcept;
66 explicit ComponentSignal(const SExpression& node);
67 ~ComponentSignal() noexcept;
68
69 // Getters
70 const Uuid& getUuid() const noexcept { return mUuid; }
71 const CircuitIdentifier& getName() const noexcept { return mName; }
72 const SignalRole& getRole() const noexcept { return mRole; }
73 const QString& getForcedNetName() const noexcept { return mForcedNetName; }
74 bool isRequired() const noexcept { return mIsRequired; }
75 bool isNegated() const noexcept { return mIsNegated; }
76 bool isClock() const noexcept { return mIsClock; }
77 bool isNetSignalNameForced() const noexcept {
78 return !mForcedNetName.isEmpty();
79 }
80
81 // Setters
82 bool setName(const CircuitIdentifier& name) noexcept;
83 bool setRole(const SignalRole& role) noexcept;
84 bool setForcedNetName(const QString& name) noexcept;
85 bool setIsRequired(bool required) noexcept;
86 bool setIsNegated(bool negated) noexcept;
87 bool setIsClock(bool clock) noexcept;
88
89 // General Methods
90
96 void serialize(SExpression& root) const;
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
105private: // Data
113};
114
115/*******************************************************************************
116 * Class ComponentSignalList
117 ******************************************************************************/
118
120 static constexpr const char* tagname = "signal";
121};
125
126/*******************************************************************************
127 * End of File
128 ******************************************************************************/
129
130} // namespace librepcb
131
132#endif
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:45
bool setIsNegated(bool negated) noexcept
Definition: componentsignal.cpp:120
bool setForcedNetName(const QString &name) noexcept
Definition: componentsignal.cpp:100
bool isNegated() const noexcept
Definition: componentsignal.h:75
ComponentSignal & operator=(const ComponentSignal &rhs) noexcept
Definition: componentsignal.cpp:171
bool setIsRequired(bool required) noexcept
Definition: componentsignal.cpp:110
bool setName(const CircuitIdentifier &name) noexcept
Definition: componentsignal.cpp:80
bool isClock() const noexcept
Definition: componentsignal.h:76
Signal< ComponentSignal, Event > onEdited
Definition: componentsignal.h:57
bool setIsClock(bool clock) noexcept
Definition: componentsignal.cpp:130
Uuid mUuid
Definition: componentsignal.h:106
Event
Definition: componentsignal.h:48
bool operator!=(const ComponentSignal &rhs) const noexcept
Definition: componentsignal.h:100
bool isNetSignalNameForced() const noexcept
Definition: componentsignal.h:77
const QString & getForcedNetName() const noexcept
Definition: componentsignal.h:73
bool mIsRequired
Definition: componentsignal.h:110
const SignalRole & getRole() const noexcept
Definition: componentsignal.h:72
const CircuitIdentifier & getName() const noexcept
Definition: componentsignal.h:71
bool isRequired() const noexcept
Definition: componentsignal.h:74
SignalRole mRole
Definition: componentsignal.h:108
bool operator==(const ComponentSignal &rhs) const noexcept
Definition: componentsignal.cpp:160
QString mForcedNetName
Definition: componentsignal.h:109
bool mIsNegated
Definition: componentsignal.h:111
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: componentsignal.cpp:144
const Uuid & getUuid() const noexcept
Definition: componentsignal.h:70
bool mIsClock
Definition: componentsignal.h:112
~ComponentSignal() noexcept
Definition: componentsignal.cpp:73
CircuitIdentifier mName
Definition: componentsignal.h:107
Slot< ComponentSignal, Event > OnEditedSlot
Definition: componentsignal.h:58
bool setRole(const SignalRole &role) noexcept
Definition: componentsignal.cpp:90
The SExpression class.
Definition: sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The SignalRole class provides all supported electrical signal roles.
Definition: signalrole.h:42
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:96
Definition: componentsignal.h:119
static constexpr const char * tagname
Definition: componentsignal.h:120