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_PICKPLACECSVWRITER_H 21 #define LIBREPCB_PICKPLACECSVWRITER_H 22 23 /******************************************************************************* 24 * Includes 25 ******************************************************************************/ 26 #include <QtCore> 27 28 #include <memory> 29 30 /******************************************************************************* 31 * Namespace / Forward Declarations 32 ******************************************************************************/ 33 namespace librepcb { 34 35 class CsvFile; 36 class PickPlaceData; 37 class PickPlaceDataItem; 38 39 /******************************************************************************* 40 * Class PickPlaceCsvWriter 41 ******************************************************************************/ 42 43 /** 44 * @brief The PickPlaceCsvWriter class 45 */ 46 class PickPlaceCsvWriter final { 47 Q_DECLARE_TR_FUNCTIONS(PickPlaceCsvWriter) 48 49 public: 50 enum class BoardSide { TOP, BOTTOM, BOTH }; 51 52 // Constructors / Destructor 53 PickPlaceCsvWriter() = delete; 54 PickPlaceCsvWriter(const PickPlaceCsvWriter& other) = delete; 55 explicit PickPlaceCsvWriter(const PickPlaceData& data) noexcept; 56 ~PickPlaceCsvWriter() noexcept; 57 58 // Setters setBoardSide(BoardSide side)59 void setBoardSide(BoardSide side) noexcept { mBoardSide = side; } setIncludeMetadataComment(bool include)60 void setIncludeMetadataComment(bool include) noexcept { 61 mIncludeMetadataComment = include; 62 } 63 64 // General Methods 65 std::shared_ptr<CsvFile> generateCsv() const; 66 67 // Operator Overloadings 68 PickPlaceCsvWriter& operator=(const PickPlaceCsvWriter& rhs) = delete; 69 70 private: // Methods 71 static bool isOnBoardSide(const PickPlaceDataItem& item, 72 BoardSide side) noexcept; 73 static QString boardSideToString(BoardSide side) noexcept; 74 75 private: // Data 76 const PickPlaceData& mData; 77 BoardSide mBoardSide; 78 bool mIncludeMetadataComment; 79 }; 80 81 /******************************************************************************* 82 * End of File 83 ******************************************************************************/ 84 85 } // namespace librepcb 86 87 #endif // LIBREPCB_PICKPLACECSVWRITER_H 88