Add a printer factory to simplify construction of printer drivers (#11)
All checks were successful
Build ptprnt / build (push) Successful in 1m1s
All checks were successful
Build ptprnt / build (push) Successful in 1m1s
Co-authored-by: Moritz Martinius <mm@cloudprinters.de> Reviewed-on: #11
This commit is contained in:
23
src/PrinterDriverFactory.cpp
Normal file
23
src/PrinterDriverFactory.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#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
|
Reference in New Issue
Block a user