LibrePCB Developers Documentation
signalrole.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_SIGNALROLE_H
21#define LIBREPCB_CORE_SIGNALROLE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../exceptions.h"
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35/*******************************************************************************
36 * Class SignalRole
37 ******************************************************************************/
38
42class SignalRole final {
43 Q_DECLARE_TR_FUNCTIONS(SignalRole)
44
45public:
46 // Constructors / Destructor
47 SignalRole() noexcept;
48 SignalRole(const SignalRole& other) noexcept;
49 ~SignalRole() noexcept;
50
51 // Getters
52
58 QString toStr() const noexcept { return mRole; }
59
65 const QString& getNameTr() const noexcept { return mName; }
66
67 // Operator Overloadings
68 SignalRole& operator=(const SignalRole& rhs) noexcept;
69 bool operator==(const SignalRole& rhs) const noexcept {
70 return mRole == rhs.mRole;
71 }
72 bool operator!=(const SignalRole& rhs) const noexcept {
73 return mRole != rhs.mRole;
74 }
75
76 // Static Methods
77
83 static const QList<SignalRole>& getAllRoles() noexcept;
84
86 static const SignalRole& passive() noexcept {
87 static SignalRole role("passive", tr("Passive"));
88 return role;
89 }
90
92 static const SignalRole& power() noexcept {
93 static SignalRole role("power", tr("Power"));
94 return role;
95 }
96
98 static const SignalRole& input() noexcept {
99 static SignalRole role("input", tr("Input"));
100 return role;
101 }
102
104 static const SignalRole& output() noexcept {
105 static SignalRole role("output", tr("Output"));
106 return role;
107 }
108
110 static const SignalRole& inout() noexcept {
111 static SignalRole role("inout", tr("I/O"));
112 return role;
113 }
114
116 static const SignalRole& opendrain() noexcept {
117 static SignalRole role("opendrain", tr("Open Drain"));
118 return role;
119 }
120
121private: // Methods
122 SignalRole(const QString& role, const QString& name) noexcept;
123
124private: // Data
125 QString mRole;
126 QString mName;
127};
128
129/*******************************************************************************
130 * End of File
131 ******************************************************************************/
132
133} // namespace librepcb
134
135#endif
The SignalRole class provides all supported electrical signal roles.
Definition: signalrole.h:42
const QString & getNameTr() const noexcept
Get the name of the SignalRole (human readable and translated)
Definition: signalrole.h:65
static const QList< SignalRole > & getAllRoles() noexcept
Get a list of all available signal roles.
Definition: signalrole.cpp:66
~SignalRole() noexcept
Definition: signalrole.cpp:49
SignalRole & operator=(const SignalRole &rhs) noexcept
Definition: signalrole.cpp:56
static const SignalRole & input() noexcept
Input Pins.
Definition: signalrole.h:98
QString toStr() const noexcept
Serialize this object into a string.
Definition: signalrole.h:58
QString mName
human readable (translated)
Definition: signalrole.h:126
bool operator==(const SignalRole &rhs) const noexcept
Definition: signalrole.h:69
static const SignalRole & output() noexcept
Output Pins.
Definition: signalrole.h:104
bool operator!=(const SignalRole &rhs) const noexcept
Definition: signalrole.h:72
static const SignalRole & passive() noexcept
Passive Pins (R, C, L)
Definition: signalrole.h:86
static const SignalRole & inout() noexcept
Input/Output Pins.
Definition: signalrole.h:110
QString mRole
used for serialization (DO NOT MODIFY VALUES!)
Definition: signalrole.h:125
static const SignalRole & power() noexcept
Power Pins (GND, VCC, VSS,... of Devices)
Definition: signalrole.h:92
static const SignalRole & opendrain() noexcept
Open Collector / Open Drain Pins.
Definition: signalrole.h:116
SignalRole() noexcept
Definition: signalrole.cpp:38
Definition: occmodel.cpp:77