LibrePCB Developers Documentation
assemblyvariant.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_ASSEMBLYVARIANT_H
21#define LIBREPCB_CORE_ASSEMBLYVARIANT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../qtcompat.h"
27#include "../../serialization/serializableobjectlist.h"
28#include "../../types/fileproofname.h"
29#include "../../types/uuid.h"
30
31#include <QtCore>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38/*******************************************************************************
39 * Class AssemblyVariant
40 ******************************************************************************/
41
45class AssemblyVariant final {
46public:
47 // Signals
48 enum class Event {
49 NameChanged,
50 DescriptionChanged,
51 };
54
55 // Constructors / Destructor
56 AssemblyVariant() = delete;
57 AssemblyVariant(const AssemblyVariant& other) noexcept;
58 explicit AssemblyVariant(const SExpression& node);
59 AssemblyVariant(const Uuid& uuid, const FileProofName& name,
60 const QString& description);
61 ~AssemblyVariant() noexcept;
62
63 // Getters
64 const Uuid& getUuid() const noexcept { return mUuid; }
65 const FileProofName& getName() const noexcept { return mName; }
66 const QString& getDescription() const noexcept { return mDescription; }
67 QString getDisplayText() const noexcept;
68
69 // Setters
70 void setName(const FileProofName& name) noexcept;
71 void setDescription(const QString& description) noexcept;
72
73 // General Methods
74
80 void serialize(SExpression& root) const;
81
82 // Operator Overloadings
83 AssemblyVariant& operator=(const AssemblyVariant& rhs) = delete;
84 bool operator==(const AssemblyVariant& rhs) = delete;
85
86private:
89 QString mDescription;
90};
91
92/*******************************************************************************
93 * Non-Member Functions
94 ******************************************************************************/
95
96inline QtCompat::Hash qHash(const std::shared_ptr<AssemblyVariant>& key,
97 QtCompat::Hash seed = 0) noexcept {
98 return ::qHash(key.get(), seed);
99}
100
101/*******************************************************************************
102 * Class AssemblyVariantList
103 ******************************************************************************/
104
106 static constexpr const char* tagname = "variant";
107};
111
112} // namespace librepcb
113
114/*******************************************************************************
115 * End of File
116 ******************************************************************************/
117
118#endif
The AssemblyVariant class.
Definition: assemblyvariant.h:45
QString mDescription
Definition: assemblyvariant.h:89
Slot< AssemblyVariant, Event > OnEditedSlot
Definition: assemblyvariant.h:53
Uuid mUuid
Definition: assemblyvariant.h:87
const QString & getDescription() const noexcept
Definition: assemblyvariant.h:66
Event
Definition: assemblyvariant.h:48
FileProofName mName
Definition: assemblyvariant.h:88
QString getDisplayText() const noexcept
Definition: assemblyvariant.cpp:62
void setName(const FileProofName &name) noexcept
Definition: assemblyvariant.cpp:74
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: assemblyvariant.cpp:92
const FileProofName & getName() const noexcept
Definition: assemblyvariant.h:65
const Uuid & getUuid() const noexcept
Definition: assemblyvariant.h:64
void setDescription(const QString &description) noexcept
Definition: assemblyvariant.cpp:81
Signal< AssemblyVariant, Event > onEdited
Definition: assemblyvariant.h:52
~AssemblyVariant() noexcept
Definition: assemblyvariant.cpp:55
Qt compatibility helper class.
Definition: qtcompat.h:43
The SExpression class.
Definition: sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:170
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Definition: occmodel.cpp:77
QtCompat::Hash qHash(const std::shared_ptr< AssemblyVariant > &key, QtCompat::Hash seed=0) noexcept
Definition: assemblyvariant.h:96
QtCompat::Hash qHash(const AttributeKey &key, QtCompat::Hash seed=0) noexcept
Definition: attributekey.h:119
type_safe::constrained_type< QString, FileProofNameConstraint, FileProofNameVerifier > FileProofName
Definition: fileproofname.h:89
Definition: assemblyvariant.h:105