LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_PROJECT_NETSIGNAL_H
21 #define LIBREPCB_PROJECT_NETSIGNAL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../erc/if_ercmsgprovider.h"
27 
31 #include <librepcb/common/uuid.h>
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 namespace project {
40 
41 class Circuit;
42 class NetClass;
43 class ComponentSignalInstance;
44 class SI_NetSegment;
45 class BI_NetSegment;
46 class BI_Plane;
47 class ErcMsg;
48 
49 /*******************************************************************************
50  * Class NetSignal
51  ******************************************************************************/
52 
56 class NetSignal final : public QObject,
57  public IF_ErcMsgProvider,
58  public SerializableObject {
59  Q_OBJECT
61 
62 public:
63  // Constructors / Destructor
64  NetSignal() = delete;
65  NetSignal(const NetSignal& other) = delete;
66  explicit NetSignal(Circuit& circuit, const SExpression& node);
67  explicit NetSignal(Circuit& circuit, NetClass& netclass,
68  const CircuitIdentifier& name, bool autoName);
69  ~NetSignal() noexcept;
70 
71  // Getters: Attributes
72  const Uuid& getUuid() const noexcept { return mUuid; }
73  const CircuitIdentifier& getName() const noexcept { return mName; }
74  bool hasAutoName() const noexcept { return mHasAutoName; }
75  NetClass& getNetClass() const noexcept { return *mNetClass; }
76  bool isHighlighted() const noexcept { return mIsHighlighted; }
77 
78  // Getters: General
79  Circuit& getCircuit() const noexcept { return mCircuit; }
80  const QList<ComponentSignalInstance*>& getComponentSignals() const noexcept {
82  }
83  const QList<SI_NetSegment*>& getSchematicNetSegments() const noexcept {
85  }
86  const QList<BI_NetSegment*>& getBoardNetSegments() const noexcept {
88  }
89  const QList<BI_Plane*>& getBoardPlanes() const noexcept {
91  }
92  int getRegisteredElementsCount() const noexcept;
93  bool isUsed() const noexcept;
94  bool isNameForced() const noexcept;
95  bool isAddedToCircuit() const noexcept { return mIsAddedToCircuit; }
96 
97  // Setters
98  void setName(const CircuitIdentifier& name, bool isAutoName) noexcept;
99  void setHighlighted(bool hl) noexcept;
100 
101  // General Methods
102  void addToCircuit();
103  void removeFromCircuit();
106  void registerSchematicNetSegment(SI_NetSegment& netsegment);
108  void registerBoardNetSegment(BI_NetSegment& netsegment);
109  void unregisterBoardNetSegment(BI_NetSegment& netsegment);
110  void registerBoardPlane(BI_Plane& plane);
111  void unregisterBoardPlane(BI_Plane& plane);
112 
114  void serialize(SExpression& root) const override;
115 
116  // Operator Overloadings
117  NetSignal& operator=(const NetSignal& rhs) = delete;
118  bool operator==(const NetSignal& rhs) noexcept { return (this == &rhs); }
119  bool operator!=(const NetSignal& rhs) noexcept { return (this != &rhs); }
120 
121 signals:
122 
123  void nameChanged(const CircuitIdentifier& newName);
125 
126 private:
127  bool checkAttributesValidity() const noexcept;
128  void updateErcMessages() noexcept;
129 
130  // General
134 
135  // Attributes
140 
141  // Registered Elements of this NetSignal
146 
147  // ERC Messages
153 };
154 
155 /*******************************************************************************
156  * End of File
157  ******************************************************************************/
158 
159 } // namespace project
160 } // namespace librepcb
161 
162 #endif // LIBREPCB_PROJECT_NETSIGNAL_H
The Circuit class represents all electrical connections in a project (drawed in the schematics) ...
Definition: circuit.h:72
bool operator==(const NetSignal &rhs) noexcept
Definition: netsignal.h:118
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: netsignal.cpp:234
#define DECLARE_ERC_MSG_CLASS_NAME(msgOwnerClassName)
Definition: if_ercmsgprovider.h:44
The ErcMsg class represents a message in the ERC (Electrical Rule Check) list.
Definition: ercmsg.h:46
Uuid mUuid
Definition: netsignal.h:136
Circuit & mCircuit
Definition: netsignal.h:131
void nameChanged(const CircuitIdentifier &newName)
The IF_ErcMsgProvider class.
Definition: if_ercmsgprovider.h:59
QList< BI_Plane * > mRegisteredBoardPlanes
Definition: netsignal.h:145
int getRegisteredElementsCount() const noexcept
Definition: netsignal.cpp:89
bool hasAutoName() const noexcept
Definition: netsignal.h:74
const QList< SI_NetSegment * > & getSchematicNetSegments() const noexcept
Definition: netsignal.h:83
void registerSchematicNetSegment(SI_NetSegment &netsegment)
Definition: netsignal.cpp:179
bool isNameForced() const noexcept
Definition: netsignal.cpp:102
void registerComponentSignal(ComponentSignalInstance &signal)
Definition: netsignal.cpp:161
Circuit & getCircuit() const noexcept
Definition: netsignal.h:79
~NetSignal() noexcept
Definition: netsignal.cpp:80
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
void unregisterSchematicNetSegment(SI_NetSegment &netsegment)
Definition: netsignal.cpp:189
The BI_Plane class.
Definition: bi_plane.h:53
const Uuid & getUuid() const noexcept
Definition: netsignal.h:72
The BI_NetSegment class.
Definition: bi_netsegment.h:57
bool mIsHighlighted
Definition: netsignal.h:133
void unregisterBoardNetSegment(BI_NetSegment &netsegment)
Definition: netsignal.cpp:208
void setHighlighted(bool hl) noexcept
Definition: netsignal.cpp:126
bool operator!=(const NetSignal &rhs) noexcept
Definition: netsignal.h:119
const QList< ComponentSignalInstance * > & getComponentSignals() const noexcept
Definition: netsignal.h:80
QList< BI_NetSegment * > mRegisteredBoardNetSegments
Definition: netsignal.h:144
bool isUsed() const noexcept
Definition: netsignal.cpp:98
const QList< BI_Plane * > & getBoardPlanes() const noexcept
Definition: netsignal.h:89
bool mIsAddedToCircuit
Definition: netsignal.h:132
The NetClass class.
Definition: netclass.h:52
const QList< BI_NetSegment * > & getBoardNetSegments() const noexcept
Definition: netsignal.h:86
QScopedPointer< ErcMsg > mErcMsgUnusedNetSignal
the ERC message for unused netsignals
Definition: netsignal.h:149
The SI_NetSegment class.
Definition: si_netsegment.h:55
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:89
NetSignal & operator=(const NetSignal &rhs)=delete
void addToCircuit()
Definition: netsignal.cpp:137
bool isHighlighted() const noexcept
Definition: netsignal.h:76
NetClass * mNetClass
Definition: netsignal.h:139
bool mHasAutoName
Definition: netsignal.h:138
void removeFromCircuit()
Definition: netsignal.cpp:146
NetClass & getNetClass() const noexcept
Definition: netsignal.h:75
The NetSignal class.
Definition: netsignal.h:56
void updateErcMessages() noexcept
Definition: netsignal.cpp:252
QList< SI_NetSegment * > mRegisteredSchematicNetSegments
Definition: netsignal.h:143
void highlightedChanged(bool isHighlighted)
void registerBoardNetSegment(BI_NetSegment &netsegment)
Definition: netsignal.cpp:198
The ComponentSignalInstance class.
Definition: componentsignalinstance.h:61
void unregisterBoardPlane(BI_Plane &plane)
Definition: netsignal.cpp:226
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void registerBoardPlane(BI_Plane &plane)
Definition: netsignal.cpp:217
void setName(const CircuitIdentifier &name, bool isAutoName) noexcept
Definition: netsignal.cpp:115
QList< ComponentSignalInstance * > mRegisteredComponentSignals
Definition: netsignal.h:142
bool isAddedToCircuit() const noexcept
Definition: netsignal.h:95
bool checkAttributesValidity() const noexcept
Definition: netsignal.cpp:247
QScopedPointer< ErcMsg > mErcMsgConnectedToLessThanTwoPins
the ERC messages for netsignals with less than two component signals
Definition: netsignal.h:152
const CircuitIdentifier & getName() const noexcept
Definition: netsignal.h:73
The SExpression class.
Definition: sexpression.h:57
void unregisterComponentSignal(ComponentSignalInstance &signal)
Definition: netsignal.cpp:170
CircuitIdentifier mName
Definition: netsignal.h:137