genesys: Simplify access to nodes that are newly added to image pipeline

merge-requests/244/head
Povilas Kanapickas 2020-05-26 01:13:20 +03:00
rodzic c9182dc606
commit 8a66829057
2 zmienionych plików z 10 dodań i 22 usunięć

Wyświetl plik

@ -556,32 +556,22 @@ public:
void clear();
template<class Node, class... Args>
void push_first_node(Args&&... args)
{
push_first_node(std::unique_ptr<Node>(new Node(std::forward<Args>(args)...)));
}
template<class Node>
void push_first_node(std::unique_ptr<Node>&& node)
Node& push_first_node(Args&&... args)
{
if (!nodes_.empty()) {
throw SaneException("Trying to append first node when there are existing nodes");
}
nodes_.emplace_back(std::move(node));
nodes_.emplace_back(std::unique_ptr<Node>(new Node(std::forward<Args>(args)...)));
return static_cast<Node&>(*nodes_.back());
}
template<class Node, class... Args>
void push_node(Args&&... args)
Node& push_node(Args&&... args)
{
ensure_node_exists();
push_node(std::unique_ptr<Node>(new Node(*nodes_.back(), std::forward<Args>(args)...)));
}
template<class Node, class... Args>
void push_node(std::unique_ptr<Node>&& node)
{
ensure_node_exists();
nodes_.emplace_back(std::move(node));
nodes_.emplace_back(std::unique_ptr<Node>(new Node(*nodes_.back(),
std::forward<Args>(args)...)));
return static_cast<Node&>(*nodes_.back());
}
bool get_next_row_data(std::uint8_t* out_data)

Wyświetl plik

@ -915,11 +915,9 @@ ImagePipelineStack build_image_pipeline(const Genesys_Device& dev, const ScanSes
// certain circumstances.
buffer_size = align_multiple_ceil(buffer_size, 2);
auto node = std::unique_ptr<ImagePipelineNodeBufferedCallableSource>(
new ImagePipelineNodeBufferedCallableSource(
width, lines, format, buffer_size, read_data_from_usb));
node->set_last_read_multiple(2);
pipeline.push_first_node(std::move(node));
auto& src_node = pipeline.push_first_node<ImagePipelineNodeBufferedCallableSource>(
width, lines, format, buffer_size, read_data_from_usb);
src_node.set_last_read_multiple(2);
if (log_image_data) {
pipeline.push_node<ImagePipelineNodeDebug>(debug_prefix + "_0_from_usb.tiff");