LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
componentsignalinstance.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_COMPONENTSIGNALINSTANCE_H
21 #define LIBREPCB_PROJECT_COMPONENTSIGNALINSTANCE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../erc/if_ercmsgprovider.h"
27 
31 
32 #include <QtCore>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class DomElement;
40 
41 namespace library {
42 class ComponentSignal;
43 }
44 
45 namespace project {
46 
47 class ComponentInstance;
48 class SI_SymbolPin;
49 class BI_FootprintPad;
50 class NetSignal;
51 class Circuit;
52 class ErcMsg;
53 
54 /*******************************************************************************
55  * Class ComponentSignalInstance
56  ******************************************************************************/
57 
61 class ComponentSignalInstance final : public QObject,
62  public IF_ErcMsgProvider,
63  public SerializableObject {
64  Q_OBJECT
66 
67 public:
68  // Constructors / Destructor
69  ComponentSignalInstance() = delete;
70  ComponentSignalInstance(const ComponentSignalInstance& other) = delete;
71  explicit ComponentSignalInstance(Circuit& circuit,
72  ComponentInstance& cmpInstance,
73  const SExpression& node);
74  explicit ComponentSignalInstance(Circuit& circuit,
75  ComponentInstance& cmpInstance,
76  const library::ComponentSignal& cmpSignal,
77  NetSignal* netsignal = nullptr);
78  ~ComponentSignalInstance() noexcept;
79 
80  // Getters
81  Circuit& getCircuit() const noexcept { return mCircuit; }
82  const library::ComponentSignal& getCompSignal() const noexcept {
83  return *mComponentSignal;
84  }
85  NetSignal* getNetSignal() const noexcept { return mNetSignal; }
86  bool isNetSignalNameForced() const noexcept;
87  QString getForcedNetSignalName() const noexcept;
88  const QList<SI_SymbolPin*>& getRegisteredSymbolPins() const noexcept {
89  return mRegisteredSymbolPins;
90  }
91  const QList<BI_FootprintPad*>& getRegisteredFootprintPads() const noexcept {
93  }
94  int getRegisteredElementsCount() const noexcept;
95  bool isUsed() const noexcept { return (getRegisteredElementsCount() > 0); }
96  bool arePinsOrPadsUsed() const noexcept;
97 
98  // Setters
99 
111  void setNetSignal(NetSignal* netsignal);
112 
113  // General Methods
114  void addToCircuit();
115  void removeFromCircuit();
116  void registerSymbolPin(SI_SymbolPin& pin);
120 
122  void serialize(SExpression& root) const override;
123 
124  // Operator Overloadings
125  ComponentSignalInstance& operator=(const ComponentSignalInstance& rhs) =
126  delete;
127 
128 signals:
129  void netSignalChanged(NetSignal* from, NetSignal* to);
130 
131 private slots:
132 
133  void netSignalNameChanged(const CircuitIdentifier& newName) noexcept;
134  void updateErcMessages() noexcept;
135 
136 private:
137  void init();
138  bool checkAttributesValidity() const noexcept;
139 
140  // General
145 
146  // Attributes
148 
149  // Registered Elements
152 
153  // ERC Messages
158 };
159 
160 /*******************************************************************************
161  * End of File
162  ******************************************************************************/
163 
164 } // namespace project
165 } // namespace librepcb
166 
167 #endif // LIBREPCB_PROJECT_COMPONENTSIGNALINSTANCE_H
The Circuit class represents all electrical connections in a project (drawed in the schematics) ...
Definition: circuit.h:75
bool arePinsOrPadsUsed() const noexcept
Definition: componentsignalinstance.cpp:148
#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
void registerSymbolPin(SI_SymbolPin &pin)
Definition: componentsignalinstance.cpp:241
QList< SI_SymbolPin * > mRegisteredSymbolPins
Definition: componentsignalinstance.h:150
~ComponentSignalInstance() noexcept
Definition: componentsignalinstance.cpp:122
void unregisterFootprintPad(BI_FootprintPad &pad)
Definition: componentsignalinstance.cpp:264
Circuit & mCircuit
Definition: componentsignalinstance.h:141
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:49
void unregisterSymbolPin(SI_SymbolPin &pin)
Definition: componentsignalinstance.cpp:249
void removeFromCircuit()
Definition: componentsignalinstance.cpp:224
void addToCircuit()
Definition: componentsignalinstance.cpp:213
bool checkAttributesValidity() const noexcept
Definition: componentsignalinstance.cpp:285
The IF_ErcMsgProvider class.
Definition: if_ercmsgprovider.h:62
void init()
Definition: componentsignalinstance.cpp:91
void registerFootprintPad(BI_FootprintPad &pad)
Definition: componentsignalinstance.cpp:256
void netSignalChanged(NetSignal *from, NetSignal *to)
QScopedPointer< ErcMsg > mErcMsgUnconnectedRequiredSignal
The ERC message for an unconnected required component signal.
Definition: componentsignalinstance.h:155
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
ComponentInstance & mComponentInstance
Definition: componentsignalinstance.h:142
void netSignalNameChanged(const CircuitIdentifier &newName) noexcept
Definition: componentsignalinstance.cpp:294
The SI_SymbolPin class.
Definition: si_symbolpin.h:58
QList< BI_FootprintPad * > mRegisteredFootprintPads
Definition: componentsignalinstance.h:151
void setNetSignal(NetSignal *netsignal)
(Re-)Connect/Disconnect this component signal to/from a circuit's netsignal
Definition: componentsignalinstance.cpp:166
const QList< BI_FootprintPad * > & getRegisteredFootprintPads() const noexcept
Definition: componentsignalinstance.h:91
const library::ComponentSignal * mComponentSignal
Definition: componentsignalinstance.h:143
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: componentsignalinstance.cpp:271
The BI_FootprintPad class.
Definition: bi_footprintpad.h:56
NetSignal * mNetSignal
Definition: componentsignalinstance.h:147
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:89
QScopedPointer< ErcMsg > mErcMsgForcedNetSignalNameConflict
The ERC message for a global net signal name mismatch.
Definition: componentsignalinstance.h:157
QString getForcedNetSignalName() const noexcept
Definition: componentsignalinstance.cpp:136
bool isUsed() const noexcept
Definition: componentsignalinstance.h:95
int getRegisteredElementsCount() const noexcept
Definition: componentsignalinstance.cpp:141
Circuit & getCircuit() const noexcept
Definition: componentsignalinstance.h:81
The NetSignal class.
Definition: netsignal.h:56
const QList< SI_SymbolPin * > & getRegisteredSymbolPins() const noexcept
Definition: componentsignalinstance.h:88
The ComponentSignalInstance class.
Definition: componentsignalinstance.h:61
bool mIsAddedToCircuit
Definition: componentsignalinstance.h:144
bool isNetSignalNameForced() const noexcept
Definition: componentsignalinstance.cpp:132
NetSignal * getNetSignal() const noexcept
Definition: componentsignalinstance.h:85
void updateErcMessages() noexcept
Definition: componentsignalinstance.cpp:300
const library::ComponentSignal & getCompSignal() const noexcept
Definition: componentsignalinstance.h:82
The ComponentInstance class.
Definition: componentinstance.h:64
The SExpression class.
Definition: sexpression.h:60