Files
ptouch-prnt/src/PrinterDriverFactory.cpp
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

23 lines
562 B
C++

#include "PrinterDriverFactory.hpp"
#include <spdlog/spdlog.h>
#include <memory>
#include "P700Printer.hpp"
#include "libusbwrap/LibUsbTypes.hpp"
namespace ptprnt {
std::shared_ptr<IPrinterDriver> PrinterDriverFactory::create(libusbwrap::usbId id) {
if (printer::P700Printer::mInfo.usbId == id) {
spdlog::info("Found printer P700!");
return std::make_shared<printer::P700Printer>();
} else {
spdlog::trace("{:04x}:{:04x} is not a compatible printer", id.first, id.second);
}
return nullptr;
}
} // namespace ptprnt