LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  explicit NetClass(Circuit& circuit, const SExpression& node);
63  explicit NetClass(Circuit& circuit, const ElementName& name);
64  ~NetClass() noexcept;
65 
66  // Getters
67  Circuit& getCircuit() const noexcept { return mCircuit; }
68  const Uuid& getUuid() const noexcept { return mUuid; }
69  const ElementName& getName() const noexcept { return mName; }
70  int getNetSignalCount() const noexcept {
71  return mRegisteredNetSignals.count();
72  }
73  bool isUsed() const noexcept { return (getNetSignalCount() > 0); }
74 
75  // Setters
76  void setName(const ElementName& name) noexcept;
77 
78  // General Methods
79  void addToCircuit();
80  void removeFromCircuit();
81  void registerNetSignal(NetSignal& signal);
82  void unregisterNetSignal(NetSignal& signal);
83 
85  void serialize(SExpression& root) const override;
86 
87  // Operator Overloadings
88  NetClass& operator=(const NetClass& rhs) = delete;
89 
90 private:
91  void updateErcMessages() noexcept;
92 
93  // General
96 
97  // Attributes
100 
101  // Registered Elements
104 
105  // ERC Messages
107  QScopedPointer<ErcMsg> mErcMsgUnusedNetClass;
108 };
109 
110 /*******************************************************************************
111  * End of File
112  ******************************************************************************/
113 
114 } // namespace project
115 } // namespace librepcb
116 
117 #endif // LIBREPCB_PROJECT_NETCLASS_H
The Circuit class represents all electrical connections in a project (drawed in the schematics) ...
Definition: circuit.h:75
void unregisterNetSignal(NetSignal &signal)
Definition: netclass.cpp:112
#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 serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: netclass.cpp:121
QHash< Uuid, NetSignal * > mRegisteredNetSignals
all registered netsignals
Definition: netclass.h:103
const Uuid & getUuid() const noexcept
Definition: netclass.h:68
The IF_ErcMsgProvider class.
Definition: if_ercmsgprovider.h:62
void registerNetSignal(NetSignal &signal)
Definition: netclass.cpp:102
bool mIsAddedToCircuit
Definition: netclass.h:95
ElementName mName
Definition: netclass.h:99
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
void setName(const ElementName &name) noexcept
Definition: netclass.cpp:68
QScopedPointer< ErcMsg > mErcMsgUnusedNetClass
the ERC message for unused netclasses
Definition: netclass.h:107
Uuid mUuid
Definition: netclass.h:98
Circuit & mCircuit
Definition: netclass.h:94
bool isUsed() const noexcept
Definition: netclass.h:73
The NetClass class.
Definition: netclass.h:52
~NetClass() noexcept
Definition: netclass.cpp:59
void removeFromCircuit()
Definition: netclass.cpp:88
NetClass & operator=(const NetClass &rhs)=delete
const ElementName & getName() const noexcept
Definition: netclass.h:69
void updateErcMessages() noexcept
Definition: netclass.cpp:130
int getNetSignalCount() const noexcept
Definition: netclass.h:70
void addToCircuit()
Definition: netclass.cpp:80
The NetSignal class.
Definition: netsignal.h:56
Circuit & getCircuit() const noexcept
Definition: netclass.h:67
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The SExpression class.
Definition: sexpression.h:60
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92