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 
43 class CmpSigPinDisplayType final {
44  Q_DECLARE_TR_FUNCTIONS(CmpSigPinDisplayType)
45 
46 public:
47  // Constructors / Destructor
48  CmpSigPinDisplayType() noexcept;
49  CmpSigPinDisplayType(const CmpSigPinDisplayType& other) noexcept;
50  ~CmpSigPinDisplayType() noexcept;
51 
52  // Getters
53 
60  const QString& toString() const noexcept { return mDisplayType; }
61 
67  const QString& getNameTr() const noexcept { return mName; }
68 
69  // Operator Overloadings
70  bool operator==(const CmpSigPinDisplayType& rhs) const noexcept;
71  bool operator!=(const CmpSigPinDisplayType& rhs) const noexcept {
72  return !(*this == rhs);
73  }
75 
76  // Static Methods
77 
87  static const CmpSigPinDisplayType& fromString(const QString& str);
88 
94  static const QList<CmpSigPinDisplayType>& getAllTypes() noexcept;
95 
97  static const CmpSigPinDisplayType& none() noexcept {
98  static CmpSigPinDisplayType type("none", tr("None (no text)"));
99  return type;
100  }
101 
103  static const CmpSigPinDisplayType& pinName() noexcept {
104  static CmpSigPinDisplayType type("pin", tr("Symbol pin name"));
105  return type;
106  }
107 
109  static const CmpSigPinDisplayType& componentSignal() noexcept {
110  static CmpSigPinDisplayType type("signal", tr("Component signal name"));
111  return type;
112  }
113 
115  static const CmpSigPinDisplayType& netSignal() noexcept {
116  static CmpSigPinDisplayType type("net", tr("Schematic net name"));
117  return type;
118  }
119 
120 private: // Methods
121  CmpSigPinDisplayType(const QString& type, const QString& name) noexcept;
122 
123 private: // Data
124  QString mDisplayType;
125  QString mName;
126 };
127 
128 /*******************************************************************************
129  * Non-Member Functions
130  ******************************************************************************/
131 
132 } // namespace library
133 
134 template <>
136  const library::CmpSigPinDisplayType& obj) {
137  return SExpression::createToken(obj.toString());
138 }
139 
140 /*******************************************************************************
141  * End of File
142  ******************************************************************************/
143 
144 } // namespace librepcb
145 
146 #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:125
The CmpSigPinDisplayType clas.
Definition: cmpsigpindisplaytype.h:43
static const CmpSigPinDisplayType & netSignal() noexcept
display the name of the connected net signal
Definition: cmpsigpindisplaytype.h:115
bool operator!=(const CmpSigPinDisplayType &rhs) const noexcept
Definition: cmpsigpindisplaytype.h:71
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:109
SExpression serializeToSExpression(const HAlign &obj)
Definition: alignment.h:76
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:97
~CmpSigPinDisplayType() noexcept
Definition: cmpsigpindisplaytype.cpp:51
QString mDisplayType
used for serialization (DO NOT MODIFY VALUES!)
Definition: cmpsigpindisplaytype.h:124
const QString & toString() const noexcept
Serialize the display type to a string (e.g. to write it into a file)
Definition: cmpsigpindisplaytype.h:60
const QString & getNameTr() const noexcept
Get the name of the display type (human readable and translated)
Definition: cmpsigpindisplaytype.h:67
static const CmpSigPinDisplayType & pinName() noexcept
display the name of the symbol pin
Definition: cmpsigpindisplaytype.h:103
static const CmpSigPinDisplayType & fromString(const QString &str)
Deserialize a display type from a string.
Definition: cmpsigpindisplaytype.cpp:74
The SExpression class.
Definition: sexpression.h:57