LibrePCB Developers Documentation
componentassemblyoption.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_COMPONENTASSEMBLYOPTION_H
21#define LIBREPCB_CORE_COMPONENTASSEMBLYOPTION_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../library/dev/part.h"
27#include "../../serialization/serializableobjectlist.h"
28
29#include <QtCore>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36/*******************************************************************************
37 * Class ComponentAssemblyOption
38 ******************************************************************************/
39
44public:
45 // Signals
46 enum class Event {
47 DeviceChanged,
48 AttributesChanged,
49 AssemblyVariantsChanged,
50 PartsEdited,
51 };
54
55 // Constructors / Destructor
58 explicit ComponentAssemblyOption(const SExpression& node);
59 ComponentAssemblyOption(const Uuid& device, const AttributeList& attributes,
60 const QSet<Uuid>& assemblyVariants,
61 const PartList& parts);
62 ~ComponentAssemblyOption() noexcept;
63
64 // Getters
65 const Uuid& getDevice() const noexcept { return mDevice; }
66 const AttributeList& getAttributes() const noexcept { return mAttributes; }
67 const QSet<Uuid>& getAssemblyVariants() const noexcept {
68 return mAssemblyVariants;
69 }
70 PartList& getParts() noexcept { return mParts; }
71 const PartList& getParts() const noexcept { return mParts; }
72
73 // Setters
74 void setDevice(const Uuid& value) noexcept;
75 void setAttributes(const AttributeList& value) noexcept;
76 void setAssemblyVariants(const QSet<Uuid>& assemblyVariants) noexcept;
77
83 void serialize(SExpression& root) const;
84
85 // Operator Overloadings
87 delete;
88 bool operator==(const ComponentAssemblyOption& rhs) const noexcept;
89 bool operator!=(const ComponentAssemblyOption& rhs) const noexcept {
90 return !(*this == rhs);
91 }
92
93private: // Methods
94 void partListEdited(const PartList& list, int index,
95 const std::shared_ptr<const Part>& obj,
96 PartList::Event event) noexcept;
97
98private: // Data
101
104
107
110
111 // Slots
113};
114
115/*******************************************************************************
116 * Class ComponentAssemblyOptionList
117 ******************************************************************************/
118
120 static constexpr const char* tagname = "device";
121};
126
127/*******************************************************************************
128 * End of File
129 ******************************************************************************/
130
131} // namespace librepcb
132
133#endif
The ComponentAssemblyOption class.
Definition: componentassemblyoption.h:43
bool operator==(const ComponentAssemblyOption &rhs) const noexcept
Definition: componentassemblyoption.cpp:123
const PartList & getParts() const noexcept
Definition: componentassemblyoption.h:71
void setAttributes(const AttributeList &value) noexcept
Definition: componentassemblyoption.cpp:86
void setDevice(const Uuid &value) noexcept
Definition: componentassemblyoption.cpp:79
void partListEdited(const PartList &list, int index, const std::shared_ptr< const Part > &obj, PartList::Event event) noexcept
Definition: componentassemblyoption.cpp:136
~ComponentAssemblyOption() noexcept
Definition: componentassemblyoption.cpp:72
PartList mParts
Parts available for assembly.
Definition: componentassemblyoption.h:109
Event
Definition: componentassemblyoption.h:46
Uuid mDevice
Compatible device.
Definition: componentassemblyoption.h:100
const QSet< Uuid > & getAssemblyVariants() const noexcept
Definition: componentassemblyoption.h:67
const AttributeList & getAttributes() const noexcept
Definition: componentassemblyoption.h:66
bool operator!=(const ComponentAssemblyOption &rhs) const noexcept
Definition: componentassemblyoption.h:89
Slot< ComponentAssemblyOption, Event > OnEditedSlot
Definition: componentassemblyoption.h:53
ComponentAssemblyOption & operator=(const ComponentAssemblyOption &rhs)=delete
QSet< Uuid > mAssemblyVariants
UUIDs of librepcb::AssemblyVariant this option is available for.
Definition: componentassemblyoption.h:106
AttributeList mAttributes
Default attributes to copy when adding new parts.
Definition: componentassemblyoption.h:103
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: componentassemblyoption.cpp:106
PartList & getParts() noexcept
Definition: componentassemblyoption.h:70
PartList::OnEditedSlot mOnPartsEditedSlot
Definition: componentassemblyoption.h:112
void setAssemblyVariants(const QSet< Uuid > &assemblyVariants) noexcept
Definition: componentassemblyoption.cpp:94
Signal< ComponentAssemblyOption, Event > onEdited
Definition: componentassemblyoption.h:52
const Uuid & getDevice() const noexcept
Definition: componentassemblyoption.h:65
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
Definition: componentassemblyoption.h:119
static constexpr const char * tagname
Definition: componentassemblyoption.h:120