LibrePCB Developers Documentation
package.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_PACKAGE_H
21 #define LIBREPCB_CORE_PACKAGE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../libraryelement.h"
27 #include "footprint.h"
28 #include "packagemodel.h"
29 #include "packagepad.h"
30 
31 #include <QtCore>
32 
33 #include <memory>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 /*******************************************************************************
41  * Class Package
42  ******************************************************************************/
43 
58 class Package final : public LibraryElement {
59  Q_OBJECT
60 
61 public:
62  // Types
63  enum class AssemblyType {
64  None,
65  Tht,
66  Smt,
67  Mixed,
68  Other,
69  Auto,
70  };
71 
72  // Constructors / Destructor
73  Package() = delete;
74  Package(const Package& other) = delete;
75  Package(const Uuid& uuid, const Version& version, const QString& author,
76  const ElementName& name_en_US, const QString& description_en_US,
77  const QString& keywords_en_US, AssemblyType assemblyType);
78  ~Package() noexcept;
79 
80  // Getters
81  AssemblyType getAssemblyType(bool resolveAuto) const noexcept;
82  AssemblyType guessAssemblyType() const noexcept;
83  PackagePadList& getPads() noexcept { return mPads; }
84  const PackagePadList& getPads() const noexcept { return mPads; }
85  PackageModelList& getModels() noexcept { return mModels; }
86  const PackageModelList& getModels() const noexcept { return mModels; }
87  QVector<std::shared_ptr<const PackageModel>> getModelsForFootprint(
88  const Uuid& fpt) const noexcept;
89  FootprintList& getFootprints() noexcept { return mFootprints; }
90  const FootprintList& getFootprints() const noexcept { return mFootprints; }
91 
92  // Setters
93  void setAssemblyType(AssemblyType type) noexcept { mAssemblyType = type; }
94 
95  // General Methods
96  virtual RuleCheckMessageList runChecks() const override;
97 
98  // Operator Overloadings
99  Package& operator=(const Package& rhs) = delete;
100 
101  // Static Methods
102  static std::unique_ptr<Package> open(
103  std::unique_ptr<TransactionalDirectory> directory);
104  static QString getShortElementName() noexcept {
105  return QStringLiteral("pkg");
106  }
107  static QString getLongElementName() noexcept {
108  return QStringLiteral("package");
109  }
110 
111 protected: // Methods
112  virtual void serialize(SExpression& root) const override;
113 
114 private: // Methods
115  Package(std::unique_ptr<TransactionalDirectory> directory,
116  const SExpression& root);
117 
118 private: // Data
123 };
124 
125 /*******************************************************************************
126  * End of File
127  ******************************************************************************/
128 
129 } // namespace librepcb
130 
131 Q_DECLARE_METATYPE(librepcb::Package::AssemblyType)
132 
133 #endif
QVector< std::shared_ptr< const PackageModel > > getModelsForFootprint(const Uuid &fpt) const noexcept
Definition: package.cpp:153
The Version class represents a version number in the format "1.42.7".
Definition: version.h:58
static std::unique_ptr< Package > open(std::unique_ptr< TransactionalDirectory > directory)
Definition: package.cpp:175
const PackagePadList & getPads() const noexcept
Definition: package.h:84
Definition: occmodel.cpp:76
PackagePadList mPads
empty list if the package has no pads
Definition: package.h:120
~Package() noexcept
Definition: package.cpp:106
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
static QString getLongElementName() noexcept
Definition: package.h:107
The Package class represents a package of a component (including footprint and 3D model) ...
Definition: package.h:58
AssemblyType mAssemblyType
Package assembly type (metadata)
Definition: package.h:119
virtual void serialize(SExpression &root) const override
Serialize into librepcb::SExpression node.
Definition: package.cpp:202
Anything special, e.g. mechanical parts.
PackageModelList mModels
3D models (optional)
Definition: package.h:121
AssemblyType guessAssemblyType() const noexcept
Definition: package.cpp:122
PackageModelList & getModels() noexcept
Definition: package.h:85
static QString getShortElementName() noexcept
Definition: package.h:104
AssemblyType
Definition: package.h:63
Nothing to mount (i.e. not a package, just a footprint)
Auto detection (deprecated, only for file format migration!)
Package & operator=(const Package &rhs)=delete
FootprintList mFootprints
minimum one footprint
Definition: package.h:122
The LibraryElement class extends the LibraryBaseElement class with some attributes and methods which ...
Definition: libraryelement.h:44
void setAssemblyType(AssemblyType type) noexcept
Definition: package.h:93
AssemblyType getAssemblyType(bool resolveAuto) const noexcept
Definition: package.cpp:113
PackagePadList & getPads() noexcept
Definition: package.h:83
FootprintList & getFootprints() noexcept
Definition: package.h:89
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
const PackageModelList & getModels() const noexcept
Definition: package.h:86
virtual RuleCheckMessageList runChecks() const override
Definition: package.cpp:170
The SExpression class.
Definition: sexpression.h:66
const FootprintList & getFootprints() const noexcept
Definition: package.h:90
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:93