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_LIBRARY_PACKAGE_H 21 #define LIBREPCB_LIBRARY_PACKAGE_H 22 23 /******************************************************************************* 24 * Includes 25 ******************************************************************************/ 26 #include "../libraryelement.h" 27 #include "footprint.h" 28 #include "packagepad.h" 29 30 #include <QtCore> 31 32 /******************************************************************************* 33 * Namespace / Forward Declarations 34 ******************************************************************************/ 35 namespace librepcb { 36 namespace library { 37 38 /******************************************************************************* 39 * Class Package 40 ******************************************************************************/ 41 42 /** 43 * @brief The Package class represents a package of a component (including 44 * footprint and 3D model) 45 * 46 * Following information is considered as the "interface" of a package and must 47 * therefore never be changed: 48 * - UUID 49 * - Package pads (neither adding nor removing pads is allowed) 50 * - UUID 51 * - Footprints (adding new footprints is allowed, but removing not) 52 * - UUID 53 * - Footprint pads (neither adding nor removing pads is allowed) 54 * - UUID 55 */ 56 class Package final : public LibraryElement { 57 Q_OBJECT 58 59 public: 60 // Constructors / Destructor 61 Package() = delete; 62 Package(const Package& other) = delete; 63 Package(const Uuid& uuid, const Version& version, const QString& author, 64 const ElementName& name_en_US, const QString& description_en_US, 65 const QString& keywords_en_US); 66 explicit Package(std::unique_ptr<TransactionalDirectory> directory); 67 ~Package() noexcept; 68 69 // Getters getPads()70 PackagePadList& getPads() noexcept { return mPads; } getPads()71 const PackagePadList& getPads() const noexcept { return mPads; } getFootprints()72 FootprintList& getFootprints() noexcept { return mFootprints; } getFootprints()73 const FootprintList& getFootprints() const noexcept { return mFootprints; } 74 75 // General Methods 76 virtual LibraryElementCheckMessageList runChecks() const override; 77 78 // Operator Overloadings 79 Package& operator=(const Package& rhs) = delete; 80 81 // Static Methods getShortElementName()82 static QString getShortElementName() noexcept { 83 return QStringLiteral("pkg"); 84 } getLongElementName()85 static QString getLongElementName() noexcept { 86 return QStringLiteral("package"); 87 } 88 89 private: // Methods 90 /// @copydoc librepcb::SerializableObject::serialize() 91 void serialize(SExpression& root) const override; 92 93 private: // Data 94 PackagePadList mPads; ///< empty list if the package has no pads 95 FootprintList mFootprints; ///< minimum one footprint 96 }; 97 98 /******************************************************************************* 99 * End of File 100 ******************************************************************************/ 101 102 } // namespace library 103 } // namespace librepcb 104 105 #endif // LIBREPCB_LIBRARY_PACKAGE_H 106