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_CORE_NETCLASS_H
21 #define LIBREPCB_CORE_NETCLASS_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../types/elementname.h"
27 #include "../../types/uuid.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class Circuit;
37 class NetSignal;
38 
39 /*******************************************************************************
40  * Class NetClass
41  ******************************************************************************/
42 
46 class NetClass final : public QObject {
47  Q_OBJECT
48 
49 public:
50  // Constructors / Destructor
51  NetClass() = delete;
52  NetClass(const NetClass& other) = delete;
53  explicit NetClass(Circuit& circuit, const Uuid& uuid,
54  const ElementName& name);
55  ~NetClass() noexcept;
56 
57  // Getters
58  Circuit& getCircuit() const noexcept { return mCircuit; }
59  const Uuid& getUuid() const noexcept { return mUuid; }
60  const ElementName& getName() const noexcept { return mName; }
61  int getNetSignalCount() const noexcept {
62  return mRegisteredNetSignals.count();
63  }
64  bool isUsed() const noexcept { return (getNetSignalCount() > 0); }
65 
66  // Setters
67  void setName(const ElementName& name) noexcept;
68 
69  // General Methods
70  void addToCircuit();
71  void removeFromCircuit();
72  void registerNetSignal(NetSignal& signal);
73  void unregisterNetSignal(NetSignal& signal);
74 
80  void serialize(SExpression& root) const;
81 
82  // Operator Overloadings
83  NetClass& operator=(const NetClass& rhs) = delete;
84 
85 private:
86  // General
89 
90  // Attributes
93 
94  // Registered Elements
96  QHash<Uuid, NetSignal*> mRegisteredNetSignals;
97 };
98 
99 /*******************************************************************************
100  * End of File
101  ******************************************************************************/
102 
103 } // namespace librepcb
104 
105 #endif
Uuid mUuid
Definition: netclass.h:91
int getNetSignalCount() const noexcept
Definition: netclass.h:61
QHash< Uuid, NetSignal * > mRegisteredNetSignals
all registered netsignals
Definition: netclass.h:96
Definition: occmodel.cpp:77
void addToCircuit()
Definition: netclass.cpp:68
bool mIsAddedToCircuit
Definition: netclass.h:88
void registerNetSignal(NetSignal &signal)
Definition: netclass.cpp:88
void unregisterNetSignal(NetSignal &signal)
Definition: netclass.cpp:97
Circuit & mCircuit
Definition: netclass.h:87
NetClass & operator=(const NetClass &rhs)=delete
const ElementName & getName() const noexcept
Definition: netclass.h:60
void removeFromCircuit()
Definition: netclass.cpp:75
The Circuit class represents all electrical connections in a project (drawn in the schematics) ...
Definition: circuit.h:70
bool isUsed() const noexcept
Definition: netclass.h:64
ElementName mName
Definition: netclass.h:92
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: netclass.cpp:105
The NetSignal class.
Definition: netsignal.h:50
The NetClass class.
Definition: netclass.h:46
Circuit & getCircuit() const noexcept
Definition: netclass.h:58
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
const Uuid & getUuid() const noexcept
Definition: netclass.h:59
~NetClass() noexcept
Definition: netclass.cpp:48
The SExpression class.
Definition: sexpression.h:69
void setName(const ElementName &name) noexcept
Definition: netclass.cpp:57
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84