/* ptrnt - print labels on linux Copyright (C) 2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include #include #include #include "interface/IPrinterService.hpp" #include "libusbwrap/UsbDeviceFactory.hpp" #include "printers/interface/IPrinterDriver.hpp" namespace ptprnt::core { /** * @brief Core service for printer operations * * Concrete implementation of IPrinterService. * Provides the core library functionality for: * - Detecting printers * - Selecting printers * - Building and printing labels */ class PrinterService : public IPrinterService { public: PrinterService(); ~PrinterService() override = default; PrinterService(const PrinterService&) = delete; PrinterService& operator=(const PrinterService&) = delete; PrinterService(PrinterService&&) = delete; PrinterService& operator=(PrinterService&&) = delete; /** * @brief Initialize USB device factory * @return true on success, false on failure */ bool initialize() override; /** * @brief Detect all compatible printers * @return Vector of detected printers */ std::vector> detectPrinters() override; /** * @brief Select a printer by name or auto-detect * @param printerName Printer driver name, or "auto" for first detected * @return Printer driver, or nullptr if not found */ std::shared_ptr selectPrinter(const std::string& printerName) override; /** * @brief Get the currently selected printer * @return Current printer, or nullptr if none selected */ [[nodiscard]] std::shared_ptr getCurrentPrinter() const override { return mCurrentPrinter; } /** * @brief Print a label * @param label The label to print * @return true on success, false on failure */ bool printLabel(std::unique_ptr label) override; private: libusbwrap::UsbDeviceFactory mUsbDeviceFactory; std::vector> mDetectedPrinters; std::shared_ptr mCurrentPrinter; }; } // namespace ptprnt::core