Files
ptouch-prnt/src/PtouchPrint.hpp
Moritz Martinius ad0b2c91ae
All checks were successful
Build ptprnt / build (push) Successful in 1m1s
Add a printer factory to simplify construction of printer drivers (#11)
Co-authored-by: Moritz Martinius <mm@cloudprinters.de>
Reviewed-on: #11
2024-04-20 11:10:30 +00:00

64 lines
2.0 KiB
C++

/*
ptrnt - print labels on linux
Copyright (C) 2023 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 <CLI/CLI.hpp>
#include <spdlog/common.h>
#include <spdlog/spdlog.h>
#include "constants.hpp"
#include "interface/IPrinterDriver.hpp"
#include "libusbwrap/UsbDeviceFactory.hpp"
namespace ptprnt {
enum class CliCmdType { None = 0, Text = 1, FontSize = 2, Font = 3, VAlign = 4, HAlign = 5 };
using CliCmd = std::pair<CliCmdType, std::string>;
class PtouchPrint {
public:
PtouchPrint(const char* versionString);
~PtouchPrint() = default;
// This is basically a singelton application class, no need to copy or move
PtouchPrint(const PtouchPrint&) = delete;
PtouchPrint& operator=(const PtouchPrint&) = delete;
PtouchPrint(PtouchPrint&&) = delete;
PtouchPrint& operator=(PtouchPrint&&) = delete;
int init(int argc, char** argv);
int run();
private:
// methods
void setupLogger(spdlog::level::level_enum lvl);
void setupCliParser();
std::vector<std::shared_ptr<IPrinterDriver>> getCompatiblePrinters();
// member variables
CLI::App mApp{ptprnt::APP_DESC};
libusbwrap::UsbDeviceFactory mUsbDeviceFactory{};
std::vector<std::shared_ptr<IPrinterDriver>> mDetectedPrinters{};
std::vector<CliCmd> mCommands{};
std::string mVersionString = "";
// CLI flags
bool mVerboseFlag = false;
};
} // namespace ptprnt