/*
ptrnt - print labels on linux
Copyright (C) 2023-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
namespace ptprnt::cli {
class ICliParser;
}
namespace ptprnt::core {
class IPrinterService;
}
namespace ptprnt {
/**
* @brief Main application class for ptprnt
*
* Acts as a thin glue layer coordinating CLI parsing and core printer functionality.
* Separates CLI frontend concerns from the core library.
*
* Uses interfaces (ICliParser, IPrinterService) to enable dependency injection
* and facilitate unit testing with mocks.
*/
class PtouchPrint {
public:
/**
* @brief Construct the application with default implementations
* @param versionString Version string to display
*/
PtouchPrint(const char* versionString);
/**
* @brief Construct with custom implementations (for testing)
* @param versionString Version string to display
* @param cliParser Custom CLI parser implementation
* @param printerService Custom printer service implementation
*/
PtouchPrint(const char* versionString, std::unique_ptr cliParser,
std::unique_ptr printerService);
~PtouchPrint(); // Must be defined in .cpp where complete types are visible
// This is basically a singleton application class, no need to copy or move
PtouchPrint(const PtouchPrint&) = delete;
PtouchPrint& operator=(const PtouchPrint&) = delete;
PtouchPrint(PtouchPrint&&) = delete;
PtouchPrint& operator=(PtouchPrint&&) = delete;
/**
* @brief Initialize the application
* @param argc Argument count
* @param argv Argument values
* @return 0 on success, non-zero on error
*/
int init(int argc, char** argv);
/**
* @brief Run the application
* @return 0 on success, non-zero on error
*/
int run();
private:
void setupLogger();
bool handleListDrivers();
bool handlePrinting();
std::string mVersionString;
std::unique_ptr mCliParser;
std::unique_ptr mPrinterService;
};
} // namespace ptprnt