LibrePCB Developers Documentation
Loading...
Searching...
No Matches
part.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_PART_H
21#define LIBREPCB_CORE_PART_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../attribute/attribute.h"
27#include "../../serialization/serializableobjectlist.h"
28#include "../../types/simplestring.h"
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39/*******************************************************************************
40 * Class Part
41 ******************************************************************************/
42
46class Part final {
47 Q_DECLARE_TR_FUNCTIONS(Part)
48
49public:
50 // Signals
51 enum class Event {
55 };
58
59 // Constructors / Destructor
60 Part() = delete;
61 Part(const Part& other) noexcept;
62 explicit Part(const SExpression& node);
63 Part(const SimpleString& mpn, const SimpleString& manufacturer,
64 const AttributeList& attributes) noexcept;
65 ~Part() noexcept;
66
67 // Getters
68 bool isEmpty() const noexcept;
69 const SimpleString& getMpn() const noexcept { return mMpn; }
70 const SimpleString& getManufacturer() const noexcept { return mManufacturer; }
71 AttributeList& getAttributes() noexcept { return mAttributes; }
72 const AttributeList& getAttributes() const noexcept { return mAttributes; }
73 QStringList getAttributeValuesTr() const noexcept;
74 QStringList getAttributeKeyValuesTr() const noexcept;
75
76 // Setters
77 void setMpn(const SimpleString& value) noexcept;
78 void setManufacturer(const SimpleString& value) noexcept;
79
80 // General Methods
81
87 void serialize(SExpression& root) const;
88
89 // Operator Overloadings
90 bool operator==(const Part& rhs) const noexcept;
91 bool operator!=(const Part& rhs) const noexcept { return !(*this == rhs); }
92 Part& operator=(const Part& rhs) noexcept;
93
94private: // Methods
95 void attributeListEdited(const AttributeList& list, int index,
96 const std::shared_ptr<const Attribute>& attribute,
97 AttributeList::Event event) noexcept;
98
99private: // Data
103
104 // Slots
106};
107
108/*******************************************************************************
109 * Class PartList
110 ******************************************************************************/
111
113 static constexpr const char* tagname = "part";
114};
115using PartList =
117
118/*******************************************************************************
119 * End of File
120 ******************************************************************************/
121
122} // namespace librepcb
123
124Q_DECLARE_METATYPE(std::shared_ptr<librepcb::Part>)
125
126#endif
The Part class.
Definition part.h:46
void setManufacturer(const SimpleString &value) noexcept
Definition part.cpp:114
~Part() noexcept
Definition part.cpp:69
SimpleString mManufacturer
Definition part.h:101
Part & operator=(const Part &rhs) noexcept
Definition part.cpp:146
const SimpleString & getManufacturer() const noexcept
Definition part.h:70
AttributeList::OnEditedSlot mOnAttributesEditedSlot
Definition part.h:105
void attributeListEdited(const AttributeList &list, int index, const std::shared_ptr< const Attribute > &attribute, AttributeList::Event event) noexcept
Definition part.cpp:157
Event
Definition part.h:51
AttributeList & getAttributes() noexcept
Definition part.h:71
const SimpleString & getMpn() const noexcept
Definition part.h:69
const AttributeList & getAttributes() const noexcept
Definition part.h:72
Signal< Part, Event > onEdited
Definition part.h:56
SimpleString mMpn
Definition part.h:100
AttributeList mAttributes
Definition part.h:102
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition part.cpp:127
Slot< Part, Event > OnEditedSlot
Definition part.h:57
bool isEmpty() const noexcept
Definition part.cpp:76
void setMpn(const SimpleString &value) noexcept
Definition part.cpp:105
QStringList getAttributeValuesTr() const noexcept
Definition part.cpp:80
QStringList getAttributeKeyValuesTr() const noexcept
Definition part.cpp:91
The SExpression class.
Definition sexpression.h:69
Slot< SerializableObjectList< Attribute, AttributeListNameProvider, OnEditedArgs... >, int, const std::shared_ptr< const Attribute > &, Event > OnEditedSlot
Definition serializableobjectlist.h:136
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
Definition occmodel.cpp:76
type_safe::constrained_type< QString, SimpleStringConstraint, SimpleStringVerifier > SimpleString
Definition simplestring.h:79
Definition part.h:112
static constexpr const char * tagname
Definition part.h:113