LibrePCB Developers Documentation
bom.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_BOM_H
21#define LIBREPCB_CORE_BOM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28/*******************************************************************************
29 * Namespace / Forward Declarations
30 ******************************************************************************/
31namespace librepcb {
32
33/*******************************************************************************
34 * Class BomItem
35 ******************************************************************************/
36
40class BomItem final {
41 Q_DECLARE_TR_FUNCTIONS(BomItem)
42
43public:
44 // Constructors / Destructor
45 BomItem() = delete;
46 BomItem(const QString& designator, const QStringList& attributes,
47 bool mount) noexcept
48 : mDesignators({designator}), mAttributes(attributes), mMount(mount) {}
49 BomItem(const BomItem& other) noexcept
50 : mDesignators(other.mDesignators),
51 mAttributes(other.mAttributes),
52 mMount(other.mMount) {}
53 ~BomItem() noexcept {}
54
55 // Getters
56 const QStringList& getDesignators() const noexcept { return mDesignators; }
57 const QStringList& getAttributes() const noexcept { return mAttributes; }
58 bool isMount() const noexcept { return mMount; }
59
60 // General Methods
61 void addDesignator(const QString& designator) noexcept;
62
63 // Operator Overloadings
64 BomItem& operator=(const BomItem& rhs) noexcept {
65 mDesignators = rhs.mDesignators;
66 mAttributes = rhs.mAttributes;
67 mMount = rhs.mMount;
68 return *this;
69 }
70
71private:
72 QStringList mDesignators;
73 QStringList mAttributes;
74 bool mMount;
75};
76
77/*******************************************************************************
78 * Class Bom
79 ******************************************************************************/
80
84class Bom final {
85 Q_DECLARE_TR_FUNCTIONS(Bom)
86
87public:
88 // Types
89 typedef std::pair<int, int> IndexPair;
90
91 // Constructors / Destructor
92 Bom() = delete;
93 Bom(const Bom& other) noexcept = delete;
94 Bom(const QStringList& columns,
95 const QVector<IndexPair>& mpnManufacturerColumns) noexcept;
96 ~Bom() noexcept;
97
98 // Getters
99 const QStringList& getColumns() const noexcept { return mColumns; }
100 const QVector<IndexPair>& getMpnManufacturerColumns() const noexcept {
102 }
103 const QList<BomItem>& getItems() const noexcept { return mItems; }
104 int getAssembledRowsCount() const noexcept;
105 int getTotalAssembledPartsCount() const noexcept;
106
107 // General Methods
108 void addItem(const QString& designator, const QStringList& attributes,
109 bool mount) noexcept;
110
111 // Operator Overloadings
112 Bom& operator=(const Bom& rhs) noexcept = delete;
113
114private:
115 QStringList mColumns;
118};
119
120/*******************************************************************************
121 * End of File
122 ******************************************************************************/
123
124} // namespace librepcb
125
126#endif
The Bom class represents a bill of materials list.
Definition: bom.h:84
std::pair< int, int > IndexPair
Definition: bom.h:89
~Bom() noexcept
Definition: bom.cpp:56
const QVector< IndexPair > & getMpnManufacturerColumns() const noexcept
Definition: bom.h:100
QStringList mColumns
Definition: bom.h:115
void addItem(const QString &designator, const QStringList &attributes, bool mount) noexcept
Definition: bom.cpp:83
QVector< IndexPair > mMpnManufacturerColumns
Definition: bom.h:116
Bom(const Bom &other) noexcept=delete
const QList< BomItem > & getItems() const noexcept
Definition: bom.h:103
Bom()=delete
const QStringList & getColumns() const noexcept
Definition: bom.h:99
QList< BomItem > mItems
Definition: bom.h:117
int getAssembledRowsCount() const noexcept
Definition: bom.cpp:63
int getTotalAssembledPartsCount() const noexcept
Definition: bom.cpp:73
The BomItem class represents an item of a bill of materials list.
Definition: bom.h:40
void addDesignator(const QString &designator) noexcept
Definition: bom.cpp:38
QStringList mDesignators
Definition: bom.h:72
BomItem(const BomItem &other) noexcept
Definition: bom.h:49
QStringList mAttributes
Definition: bom.h:73
bool mMount
False means "do not mount".
Definition: bom.h:74
const QStringList & getAttributes() const noexcept
Definition: bom.h:57
BomItem & operator=(const BomItem &rhs) noexcept
Definition: bom.h:64
BomItem(const QString &designator, const QStringList &attributes, bool mount) noexcept
Definition: bom.h:46
const QStringList & getDesignators() const noexcept
Definition: bom.h:56
bool isMount() const noexcept
Definition: bom.h:58
~BomItem() noexcept
Definition: bom.h:53
Definition: occmodel.cpp:77