LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cmpsigpindisplaytype.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_LIBRARY_CMPSIGPINDISPLAYTYPE_H
21 #define LIBREPCB_LIBRARY_CMPSIGPINDISPLAYTYPE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 namespace library {
35 
36 /*******************************************************************************
37  * Class CmpSigPinDisplayType
38  ******************************************************************************/
39 
46 class CmpSigPinDisplayType final {
47  Q_DECLARE_TR_FUNCTIONS(CmpSigPinDisplayType)
48 
49 public:
50  // Constructors / Destructor
51  CmpSigPinDisplayType() noexcept;
52  CmpSigPinDisplayType(const CmpSigPinDisplayType& other) noexcept;
53  ~CmpSigPinDisplayType() noexcept;
54 
55  // Getters
56 
63  const QString& toString() const noexcept { return mDisplayType; }
64 
70  const QString& getNameTr() const noexcept { return mName; }
71 
72  // Operator Overloadings
73  bool operator==(const CmpSigPinDisplayType& rhs) const noexcept;
74  bool operator!=(const CmpSigPinDisplayType& rhs) const noexcept {
75  return !(*this == rhs);
76  }
78 
79  // Static Methods
80 
90  static const CmpSigPinDisplayType& fromString(const QString& str);
91 
97  static const QList<CmpSigPinDisplayType>& getAllTypes() noexcept;
98 
100  static const CmpSigPinDisplayType& none() noexcept {
101  static CmpSigPinDisplayType type("none", tr("None (no text)"));
102  return type;
103  }
104 
106  static const CmpSigPinDisplayType& pinName() noexcept {
107  static CmpSigPinDisplayType type("pin", tr("Symbol pin name"));
108  return type;
109  }
110 
112  static const CmpSigPinDisplayType& componentSignal() noexcept {
113  static CmpSigPinDisplayType type("signal", tr("Component signal name"));
114  return type;
115  }
116 
118  static const CmpSigPinDisplayType& netSignal() noexcept {
119  static CmpSigPinDisplayType type("net", tr("Schematic net name"));
120  return type;
121  }
122 
123 private: // Methods
124  CmpSigPinDisplayType(const QString& type, const QString& name) noexcept;
125 
126 private: // Data
127  QString mDisplayType;
128  QString mName;
129 };
130 
131 /*******************************************************************************
132  * Non-Member Functions
133  ******************************************************************************/
134 
135 } // namespace library
136 
137 template <>
139  const library::CmpSigPinDisplayType& obj) {
140  return SExpression::createToken(obj.toString());
141 }
142 
143 /*******************************************************************************
144  * End of File
145  ******************************************************************************/
146 
147 } // namespace librepcb
148 
149 #endif // LIBREPCB_LIBRARY_CMPSIGPINDISPLAYTYPE_H
static const QList< CmpSigPinDisplayType > & getAllTypes() noexcept
Get a list of all available display types.
Definition: cmpsigpindisplaytype.cpp:88
QString mName
human readable (translated)
Definition: cmpsigpindisplaytype.h:128
The CmpSigPinDisplayType clas.
Definition: cmpsigpindisplaytype.h:46
static const CmpSigPinDisplayType & netSignal() noexcept
display the name of the connected net signal
Definition: cmpsigpindisplaytype.h:118
bool operator!=(const CmpSigPinDisplayType &rhs) const noexcept
Definition: cmpsigpindisplaytype.h:74
CmpSigPinDisplayType() noexcept
Definition: cmpsigpindisplaytype.cpp:37
CmpSigPinDisplayType & operator=(const CmpSigPinDisplayType &rhs) noexcept
Definition: cmpsigpindisplaytype.cpp:63
static const CmpSigPinDisplayType & componentSignal() noexcept
display the name of the component signal
Definition: cmpsigpindisplaytype.h:112
SExpression serializeToSExpression(const HAlign &obj)
Definition: alignment.h:79
static SExpression createToken(const QString &token)
Definition: sexpression.cpp:280
bool operator==(const CmpSigPinDisplayType &rhs) const noexcept
Definition: cmpsigpindisplaytype.cpp:58
static const CmpSigPinDisplayType & none() noexcept
None (no text)
Definition: cmpsigpindisplaytype.h:100
~CmpSigPinDisplayType() noexcept
Definition: cmpsigpindisplaytype.cpp:51
QString mDisplayType
used for serialization (DO NOT MODIFY VALUES!)
Definition: cmpsigpindisplaytype.h:127
const QString & toString() const noexcept
Serialize the display type to a string (e.g. to write it into a file)
Definition: cmpsigpindisplaytype.h:63
const QString & getNameTr() const noexcept
Get the name of the display type (human readable and translated)
Definition: cmpsigpindisplaytype.h:70
static const CmpSigPinDisplayType & pinName() noexcept
display the name of the symbol pin
Definition: cmpsigpindisplaytype.h:106
static const CmpSigPinDisplayType & fromString(const QString &str)
Deserialize a display type from a string.
Definition: cmpsigpindisplaytype.cpp:74
The SExpression class.
Definition: sexpression.h:60