LibrePCB Developers Documentation
netsignal.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_NETSIGNAL_H
21#define LIBREPCB_CORE_NETSIGNAL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../types/circuitidentifier.h"
27#include "../../types/uuid.h"
28
29#include <QtCore>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36class BI_NetSegment;
37class BI_Plane;
38class Circuit;
39class ComponentSignalInstance;
40class NetClass;
41class SI_NetSegment;
42
43/*******************************************************************************
44 * Class NetSignal
45 ******************************************************************************/
46
50class NetSignal final : public QObject {
51 Q_OBJECT
52
53public:
54 // Constructors / Destructor
55 NetSignal() = delete;
56 NetSignal(const NetSignal& other) = delete;
57 explicit NetSignal(Circuit& circuit, const Uuid& uuid, NetClass& netclass,
58 const CircuitIdentifier& name, bool autoName);
59 ~NetSignal() noexcept;
60
61 // Getters: Attributes
62 const Uuid& getUuid() const noexcept { return mUuid; }
63 const CircuitIdentifier& getName() const noexcept { return mName; }
64 bool hasAutoName() const noexcept { return mHasAutoName; }
65 NetClass& getNetClass() const noexcept { return mNetClass; }
66
67 // Getters: General
68 Circuit& getCircuit() const noexcept { return mCircuit; }
69 const QList<ComponentSignalInstance*>& getComponentSignals() const noexcept {
71 }
72 const QList<SI_NetSegment*>& getSchematicNetSegments() const noexcept {
74 }
75 const QList<BI_NetSegment*>& getBoardNetSegments() const noexcept {
77 }
78 const QList<BI_Plane*>& getBoardPlanes() const noexcept {
80 }
81 int getRegisteredElementsCount() const noexcept;
82 bool isUsed() const noexcept;
83 bool isNameForced() const noexcept;
84 bool isAddedToCircuit() const noexcept { return mIsAddedToCircuit; }
85
86 // Setters
87 void setName(const CircuitIdentifier& name, bool isAutoName) noexcept;
88
89 // General Methods
90 void addToCircuit();
91 void removeFromCircuit();
96 void registerBoardNetSegment(BI_NetSegment& netsegment);
98 void registerBoardPlane(BI_Plane& plane);
99 void unregisterBoardPlane(BI_Plane& plane);
100
106 void serialize(SExpression& root) const;
107
108 // Operator Overloadings
109 NetSignal& operator=(const NetSignal& rhs) = delete;
110 bool operator==(const NetSignal& rhs) noexcept { return (this == &rhs); }
111 bool operator!=(const NetSignal& rhs) noexcept { return (this != &rhs); }
112
113signals:
114
115 void nameChanged(const CircuitIdentifier& newName);
116
117private:
118 // General
121
122 // Attributes
127
128 // Registered Elements of this NetSignal
129 QList<ComponentSignalInstance*> mRegisteredComponentSignals;
130 QList<SI_NetSegment*> mRegisteredSchematicNetSegments;
131 QList<BI_NetSegment*> mRegisteredBoardNetSegments;
132 QList<BI_Plane*> mRegisteredBoardPlanes;
133};
134
135/*******************************************************************************
136 * End of File
137 ******************************************************************************/
138
139} // namespace librepcb
140
141#endif
The BI_NetSegment class.
Definition: bi_netsegment.h:52
The BI_Plane class.
Definition: bi_plane.h:52
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition: circuit.h:70
The ComponentSignalInstance class.
Definition: componentsignalinstance.h:49
The NetClass class.
Definition: netclass.h:46
The NetSignal class.
Definition: netsignal.h:50
bool mHasAutoName
Definition: netsignal.h:125
bool isAddedToCircuit() const noexcept
Definition: netsignal.h:84
NetClass & getNetClass() const noexcept
Definition: netsignal.h:65
Circuit & mCircuit
Definition: netsignal.h:119
void registerComponentSignal(ComponentSignalInstance &signal)
Definition: netsignal.cpp:128
int getRegisteredElementsCount() const noexcept
Definition: netsignal.cpp:66
NetClass & mNetClass
Definition: netsignal.h:126
const QList< BI_Plane * > & getBoardPlanes() const noexcept
Definition: netsignal.h:78
bool operator!=(const NetSignal &rhs) noexcept
Definition: netsignal.h:111
Uuid mUuid
Definition: netsignal.h:123
bool isUsed() const noexcept
Definition: netsignal.cpp:75
void unregisterBoardNetSegment(BI_NetSegment &netsegment)
Definition: netsignal.cpp:174
void nameChanged(const CircuitIdentifier &newName)
const QList< ComponentSignalInstance * > & getComponentSignals() const noexcept
Definition: netsignal.h:69
const CircuitIdentifier & getName() const noexcept
Definition: netsignal.h:63
void setName(const CircuitIdentifier &name, bool isAutoName) noexcept
Definition: netsignal.cpp:92
void registerSchematicNetSegment(SI_NetSegment &netsegment)
Definition: netsignal.cpp:144
QList< BI_Plane * > mRegisteredBoardPlanes
Definition: netsignal.h:132
bool isNameForced() const noexcept
Definition: netsignal.cpp:79
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: netsignal.cpp:197
void unregisterSchematicNetSegment(SI_NetSegment &netsegment)
Definition: netsignal.cpp:157
bool hasAutoName() const noexcept
Definition: netsignal.h:64
~NetSignal() noexcept
Definition: netsignal.cpp:57
QList< BI_NetSegment * > mRegisteredBoardNetSegments
Definition: netsignal.h:131
const Uuid & getUuid() const noexcept
Definition: netsignal.h:62
void removeFromCircuit()
Definition: netsignal.cpp:114
QList< SI_NetSegment * > mRegisteredSchematicNetSegments
Definition: netsignal.h:130
Circuit & getCircuit() const noexcept
Definition: netsignal.h:68
NetSignal(const NetSignal &other)=delete
bool operator==(const NetSignal &rhs) noexcept
Definition: netsignal.h:110
void registerBoardPlane(BI_Plane &plane)
Definition: netsignal.cpp:182
CircuitIdentifier mName
Definition: netsignal.h:124
void unregisterBoardPlane(BI_Plane &plane)
Definition: netsignal.cpp:190
const QList< SI_NetSegment * > & getSchematicNetSegments() const noexcept
Definition: netsignal.h:72
bool mIsAddedToCircuit
Definition: netsignal.h:120
void registerBoardNetSegment(BI_NetSegment &netsegment)
Definition: netsignal.cpp:165
void addToCircuit()
Definition: netsignal.cpp:106
NetSignal & operator=(const NetSignal &rhs)=delete
const QList< BI_NetSegment * > & getBoardNetSegments() const noexcept
Definition: netsignal.h:75
QList< ComponentSignalInstance * > mRegisteredComponentSignals
Definition: netsignal.h:129
void unregisterComponentSignal(ComponentSignalInstance &signal)
Definition: netsignal.cpp:136
The SExpression class.
Definition: sexpression.h:69
The SI_NetSegment class.
Definition: si_netsegment.h:53
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