LibrePCB Developers Documentation
netclass.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_NETCLASS_H
21 #define LIBREPCB_PROJECT_NETCLASS_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 NetSignal;
43 class ErcMsg;
44 
45 /*******************************************************************************
46  * Class NetClass
47  ******************************************************************************/
48 
52 class NetClass final : public QObject,
53  public IF_ErcMsgProvider,
54  public SerializableObject {
55  Q_OBJECT
57 
58 public:
59  // Constructors / Destructor
60  NetClass() = delete;
61  NetClass(const NetClass& other) = delete;
62  NetClass(Circuit& circuit, const SExpression& node,
63  const Version& fileFormat);
64  explicit NetClass(Circuit& circuit, const ElementName& name);
65  ~NetClass() noexcept;
66 
67  // Getters
68  Circuit& getCircuit() const noexcept { return mCircuit; }
69  const Uuid& getUuid() const noexcept { return mUuid; }
70  const ElementName& getName() const noexcept { return mName; }
71  int getNetSignalCount() const noexcept {
72  return mRegisteredNetSignals.count();
73  }
74  bool isUsed() const noexcept { return (getNetSignalCount() > 0); }
75 
76  // Setters
77  void setName(const ElementName& name) noexcept;
78 
79  // General Methods
80  void addToCircuit();
81  void removeFromCircuit();
82  void registerNetSignal(NetSignal& signal);
83  void unregisterNetSignal(NetSignal& signal);
84 
86  void serialize(SExpression& root) const override;
87 
88  // Operator Overloadings
89  NetClass& operator=(const NetClass& rhs) = delete;
90 
91 private:
92  void updateErcMessages() noexcept;
93 
94  // General
97 
98  // Attributes
101 
102  // Registered Elements
104  QHash<Uuid, NetSignal*> mRegisteredNetSignals;
105 
106  // ERC Messages
108  QScopedPointer<ErcMsg> mErcMsgUnusedNetClass;
109 };
110 
111 /*******************************************************************************
112  * End of File
113  ******************************************************************************/
114 
115 } // namespace project
116 } // namespace librepcb
117 
118 #endif // LIBREPCB_PROJECT_NETCLASS_H
The Circuit class represents all electrical connections in a project (drawed in the schematics) ...
Definition: circuit.h:73
void unregisterNetSignal(NetSignal &signal)
Definition: netclass.cpp:113
The Version class represents a version number in the format "1.42.7".
Definition: version.h:60
#define DECLARE_ERC_MSG_CLASS_NAME(msgOwnerClassName)
Definition: if_ercmsgprovider.h:44
Definition: airwiresbuilder.cpp:32
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: netclass.cpp:122
QHash< Uuid, NetSignal * > mRegisteredNetSignals
all registered netsignals
Definition: netclass.h:104
const Uuid & getUuid() const noexcept
Definition: netclass.h:69
The IF_ErcMsgProvider class.
Definition: if_ercmsgprovider.h:59
void registerNetSignal(NetSignal &signal)
Definition: netclass.cpp:103
bool mIsAddedToCircuit
Definition: netclass.h:96
ElementName mName
Definition: netclass.h:100
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
void setName(const ElementName &name) noexcept
Definition: netclass.cpp:69
QScopedPointer< ErcMsg > mErcMsgUnusedNetClass
the ERC message for unused netclasses
Definition: netclass.h:108
Uuid mUuid
Definition: netclass.h:99
Circuit & mCircuit
Definition: netclass.h:95
bool isUsed() const noexcept
Definition: netclass.h:74
The NetClass class.
Definition: netclass.h:52
~NetClass() noexcept
Definition: netclass.cpp:60
void removeFromCircuit()
Definition: netclass.cpp:89
NetClass & operator=(const NetClass &rhs)=delete
const ElementName & getName() const noexcept
Definition: netclass.h:70
void updateErcMessages() noexcept
Definition: netclass.cpp:131
int getNetSignalCount() const noexcept
Definition: netclass.h:71
void addToCircuit()
Definition: netclass.cpp:81
The NetSignal class.
Definition: netsignal.h:56
Circuit & getCircuit() const noexcept
Definition: netclass.h:68
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The SExpression class.
Definition: sexpression.h:72
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92