LibrePCB Developers Documentation
Loading...
Searching...
No Matches
bus.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_BUS_H
21#define LIBREPCB_CORE_BUS_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../types/busname.h"
27#include "../../types/length.h"
28#include "../../types/uuid.h"
29
30#include <QtCore>
31
32#include <optional>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Circuit;
40class NetSignal;
41class SI_BusSegment;
42
43/*******************************************************************************
44 * Class Bus
45 ******************************************************************************/
46
50class Bus final : public QObject {
51 Q_OBJECT
52
53public:
54 // Constructors / Destructor
55 Bus() = delete;
56 Bus(const Bus& other) = delete;
57 explicit Bus(Circuit& circuit, const Uuid& uuid, const BusName& name,
58 bool autoName, bool prefixNetNames,
59 const std::optional<UnsignedLength>& maxTraceLengthDifference);
60 ~Bus() noexcept;
61
62 // Getters: Attributes
63 const Uuid& getUuid() const noexcept { return mUuid; }
64 const BusName& getName() const noexcept { return mName; }
65 bool hasAutoName() const noexcept { return mHasAutoName; }
66 bool getPrefixNetNames() const noexcept { return mPrefixNetNames; }
67 const std::optional<UnsignedLength>& getMaxTraceLengthDifference()
68 const noexcept {
70 }
71
72 // Getters: General
73 Circuit& getCircuit() const noexcept { return mCircuit; }
74 const QList<SI_BusSegment*>& getSchematicBusSegments() const noexcept {
76 }
77 QSet<NetSignal*> getConnectedNetSignals() const noexcept;
78 bool isUsed() const noexcept;
79 bool isAddedToCircuit() const noexcept { return mIsAddedToCircuit; }
80
81 // Setters
82 void setName(const BusName& name, bool isAutoName) noexcept;
83 void setPrefixNetNames(bool prefix) noexcept;
85 const std::optional<UnsignedLength>& diff) noexcept;
86
87 // General Methods
88 void addToCircuit();
89 void removeFromCircuit();
92
98 void serialize(SExpression& root) const;
99
100 // Operator Overloadings
101 Bus& operator=(const Bus& rhs) = delete;
102 bool operator==(const Bus& rhs) const noexcept { return (this == &rhs); }
103 bool operator!=(const Bus& rhs) const noexcept { return (this != &rhs); }
104
105signals:
106 void nameChanged(const BusName& newName);
107
108private:
109 // General
112
113 // Attributes
118 std::optional<UnsignedLength> mMaxTraceLengthDifference;
119
120 // Registered Elements of this bus
121 QList<SI_BusSegment*> mRegisteredSchematicBusSegments;
122};
123
124/*******************************************************************************
125 * End of File
126 ******************************************************************************/
127
128} // namespace librepcb
129
130#endif
The Bus class.
Definition bus.h:50
bool mHasAutoName
Definition bus.h:116
bool isAddedToCircuit() const noexcept
Definition bus.h:79
Circuit & mCircuit
Definition bus.h:110
QSet< NetSignal * > getConnectedNetSignals() const noexcept
Definition bus.cpp:63
bool operator==(const Bus &rhs) const noexcept
Definition bus.h:102
void nameChanged(const BusName &newName)
Uuid mUuid
Definition bus.h:114
void setPrefixNetNames(bool prefix) noexcept
Definition bus.cpp:90
bool isUsed() const noexcept
Definition bus.cpp:73
void unregisterSchematicBusSegment(SI_BusSegment &s)
Definition bus.cpp:136
const QList< SI_BusSegment * > & getSchematicBusSegments() const noexcept
Definition bus.h:74
BusName mName
Definition bus.h:115
const BusName & getName() const noexcept
Definition bus.h:64
bool operator!=(const Bus &rhs) const noexcept
Definition bus.h:103
QList< SI_BusSegment * > mRegisteredSchematicBusSegments
Definition bus.h:121
void registerSchematicBusSegment(SI_BusSegment &s)
Definition bus.cpp:123
Bus & operator=(const Bus &rhs)=delete
bool mPrefixNetNames
Definition bus.h:117
std::optional< UnsignedLength > mMaxTraceLengthDifference
Definition bus.h:118
Bus()=delete
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition bus.cpp:143
bool hasAutoName() const noexcept
Definition bus.h:65
const Uuid & getUuid() const noexcept
Definition bus.h:63
void removeFromCircuit()
Definition bus.cpp:110
Circuit & getCircuit() const noexcept
Definition bus.h:73
bool getPrefixNetNames() const noexcept
Definition bus.h:66
~Bus() noexcept
Definition bus.cpp:54
Bus(const Bus &other)=delete
void setMaxTraceLengthDifference(const std::optional< UnsignedLength > &diff) noexcept
Definition bus.cpp:94
bool mIsAddedToCircuit
Definition bus.h:111
const std::optional< UnsignedLength > & getMaxTraceLengthDifference() const noexcept
Definition bus.h:67
void addToCircuit()
Definition bus.cpp:103
void setName(const BusName &name, bool isAutoName) noexcept
Definition bus.cpp:81
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition circuit.h:72
The SExpression class.
Definition sexpression.h:69
The SI_BusSegment class.
Definition si_bussegment.h:52
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:77
type_safe::constrained_type< QString, BusNameConstraint, BusNameVerifier > BusName
Definition busname.h:82