All checks were successful
Build ptprnt / build (push) Successful in 3m50s
Reviewed-on: moritz/ptouch-prnt#15
75 lines
2.2 KiB
C++
75 lines
2.2 KiB
C++
/*
|
|
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 <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "graphics/interface/ILabel.hpp"
|
|
#include "printers/interface/IPrinterDriver.hpp"
|
|
|
|
namespace ptprnt::core {
|
|
|
|
/**
|
|
* @brief Interface for core printer service operations
|
|
*
|
|
* This interface allows for mocking printer operations in unit tests
|
|
* and provides a clear contract for printer service implementations.
|
|
*/
|
|
class IPrinterService {
|
|
public:
|
|
virtual ~IPrinterService() = default;
|
|
|
|
/**
|
|
* @brief Initialize the printer service
|
|
* @return true on success, false on failure
|
|
*/
|
|
virtual bool initialize() = 0;
|
|
|
|
/**
|
|
* @brief Detect all compatible printers
|
|
* @return Vector of detected printers
|
|
*/
|
|
virtual std::vector<std::shared_ptr<IPrinterDriver>> detectPrinters() = 0;
|
|
|
|
/**
|
|
* @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
|
|
*/
|
|
virtual std::shared_ptr<IPrinterDriver> selectPrinter(const std::string& printerName) = 0;
|
|
|
|
/**
|
|
* @brief Get the currently selected printer
|
|
* @return Current printer, or nullptr if none selected
|
|
*/
|
|
[[nodiscard]] virtual std::shared_ptr<IPrinterDriver> getCurrentPrinter() const = 0;
|
|
|
|
/**
|
|
* @brief Print a label
|
|
* @param label The label to print
|
|
* @return true on success, false on failure
|
|
*/
|
|
virtual bool printLabel(std::unique_ptr<graphics::ILabel> label) = 0;
|
|
};
|
|
|
|
} // namespace ptprnt::core
|