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 ******************************************************************************/
34namespace librepcb {
35
36class Circuit;
37class NetSignal;
38
39/*******************************************************************************
40 * Class NetClass
41 ******************************************************************************/
42
46class NetClass final : public QObject {
47 Q_OBJECT
48
49public:
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
85private:
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
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition: circuit.h:70
The NetClass class.
Definition: netclass.h:46
int getNetSignalCount() const noexcept
Definition: netclass.h:61
void setName(const ElementName &name) noexcept
Definition: netclass.cpp:57
Circuit & mCircuit
Definition: netclass.h:87
const ElementName & getName() const noexcept
Definition: netclass.h:60
Uuid mUuid
Definition: netclass.h:91
bool isUsed() const noexcept
Definition: netclass.h:64
ElementName mName
Definition: netclass.h:92
void unregisterNetSignal(NetSignal &signal)
Definition: netclass.cpp:97
void registerNetSignal(NetSignal &signal)
Definition: netclass.cpp:88
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: netclass.cpp:105
NetClass & operator=(const NetClass &rhs)=delete
const Uuid & getUuid() const noexcept
Definition: netclass.h:59
void removeFromCircuit()
Definition: netclass.cpp:75
Circuit & getCircuit() const noexcept
Definition: netclass.h:58
QHash< Uuid, NetSignal * > mRegisteredNetSignals
all registered netsignals
Definition: netclass.h:96
NetClass(const NetClass &other)=delete
bool mIsAddedToCircuit
Definition: netclass.h:88
void addToCircuit()
Definition: netclass.cpp:68
~NetClass() noexcept
Definition: netclass.cpp:48
The NetSignal class.
Definition: netsignal.h:50
The SExpression class.
Definition: sexpression.h:69
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84