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  ******************************************************************************/
34 namespace librepcb {
35 
36 class BI_NetSegment;
37 class BI_Plane;
38 class Circuit;
39 class ComponentSignalInstance;
40 class NetClass;
41 class SI_NetSegment;
42 
43 /*******************************************************************************
44  * Class NetSignal
45  ******************************************************************************/
46 
50 class NetSignal final : public QObject {
51  Q_OBJECT
52 
53 public:
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);
97  void unregisterBoardNetSegment(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 
113 signals:
114 
115  void nameChanged(const CircuitIdentifier& newName);
116 
117 private:
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
void nameChanged(const CircuitIdentifier &newName)
bool isUsed() const noexcept
Definition: netsignal.cpp:75
bool isNameForced() const noexcept
Definition: netsignal.cpp:79
void unregisterSchematicNetSegment(SI_NetSegment &netsegment)
Definition: netsignal.cpp:157
const QList< BI_Plane * > & getBoardPlanes() const noexcept
Definition: netsignal.h:78
CircuitIdentifier mName
Definition: netsignal.h:124
Definition: occmodel.cpp:76
Circuit & getCircuit() const noexcept
Definition: netsignal.h:68
const Uuid & getUuid() const noexcept
Definition: netsignal.h:62
QList< BI_Plane * > mRegisteredBoardPlanes
Definition: netsignal.h:132
~NetSignal() noexcept
Definition: netsignal.cpp:57
void registerBoardNetSegment(BI_NetSegment &netsegment)
Definition: netsignal.cpp:165
NetClass & mNetClass
Definition: netsignal.h:126
const QList< SI_NetSegment * > & getSchematicNetSegments() const noexcept
Definition: netsignal.h:72
bool mIsAddedToCircuit
Definition: netsignal.h:120
QList< BI_NetSegment * > mRegisteredBoardNetSegments
Definition: netsignal.h:131
Uuid mUuid
Definition: netsignal.h:123
Circuit & mCircuit
Definition: netsignal.h:119
const CircuitIdentifier & getName() const noexcept
Definition: netsignal.h:63
void registerComponentSignal(ComponentSignalInstance &signal)
Definition: netsignal.cpp:128
bool hasAutoName() const noexcept
Definition: netsignal.h:64
The Circuit class represents all electrical connections in a project (drawn in the schematics) ...
Definition: circuit.h:70
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: netsignal.cpp:197
void removeFromCircuit()
Definition: netsignal.cpp:114
void unregisterBoardNetSegment(BI_NetSegment &netsegment)
Definition: netsignal.cpp:174
The BI_NetSegment class.
Definition: bi_netsegment.h:52
QList< ComponentSignalInstance * > mRegisteredComponentSignals
Definition: netsignal.h:129
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:93
NetSignal & operator=(const NetSignal &rhs)=delete
The BI_Plane class.
Definition: bi_plane.h:52
NetClass & getNetClass() const noexcept
Definition: netsignal.h:65
bool operator!=(const NetSignal &rhs) noexcept
Definition: netsignal.h:111
bool operator==(const NetSignal &rhs) noexcept
Definition: netsignal.h:110
The NetSignal class.
Definition: netsignal.h:50
The NetClass class.
Definition: netclass.h:46
const QList< BI_NetSegment * > & getBoardNetSegments() const noexcept
Definition: netsignal.h:75
void addToCircuit()
Definition: netsignal.cpp:106
The ComponentSignalInstance class.
Definition: componentsignalinstance.h:49
void unregisterBoardPlane(BI_Plane &plane)
Definition: netsignal.cpp:190
void registerBoardPlane(BI_Plane &plane)
Definition: netsignal.cpp:182
const QList< ComponentSignalInstance * > & getComponentSignals() const noexcept
Definition: netsignal.h:69
void unregisterComponentSignal(ComponentSignalInstance &signal)
Definition: netsignal.cpp:136
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
bool isAddedToCircuit() const noexcept
Definition: netsignal.h:84
void setName(const CircuitIdentifier &name, bool isAutoName) noexcept
Definition: netsignal.cpp:92
The SExpression class.
Definition: sexpression.h:66
void registerSchematicNetSegment(SI_NetSegment &netsegment)
Definition: netsignal.cpp:144
int getRegisteredElementsCount() const noexcept
Definition: netsignal.cpp:66
The SI_NetSegment class.
Definition: si_netsegment.h:53
bool mHasAutoName
Definition: netsignal.h:125
QList< SI_NetSegment * > mRegisteredSchematicNetSegments
Definition: netsignal.h:130