Fawkes API Fawkes Development Version
copy.cpp
1/***************************************************************************
2 * copy.cpp - Laser data filter to copy data without modification
3 *
4 * Created: Mon 16 Apr 2018 13:50:26 CEST 13:50
5 * Copyright 2018 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#include "copy.h"
22
23#include <utils/time/time.h>
24
25/** @class LaserCopyDataFilter "copy.h"
26 * Copy laser data without modification to a new name.
27 * @author Till Hofmann
28 */
29
30/** Constructor.
31 * @param filter_name name of this filter instance
32 * @param in_data_size number of entries in the input value arrays
33 * @param in vector of input arrays
34 */
35
36LaserCopyDataFilter::LaserCopyDataFilter(const std::string & filter_name,
37 unsigned int in_data_size,
38 std::vector<Buffer *> &in)
39: LaserDataFilter(filter_name, in_data_size, in, in.size())
40{
41}
42
43void
45{
46 const unsigned int num_buffers = std::min(in.size(), out.size());
47 const unsigned int data_size = std::min(in_data_size, out_data_size);
48 for (unsigned int buffer_i = 0; buffer_i < num_buffers; buffer_i++) {
49 out[buffer_i]->frame = in[buffer_i]->frame;
50 out[buffer_i]->timestamp->set_time(in[buffer_i]->timestamp);
51 float *inbuf = in[buffer_i]->values;
52 float *outbuf = out[buffer_i]->values;
53 for (unsigned int i = 0; i < data_size; i++) {
54 outbuf[i] = inbuf[i];
55 }
56 }
57}
LaserCopyDataFilter(const std::string &filter_name, unsigned int in_data_size, std::vector< Buffer * > &in)
Constructor.
Definition: copy.cpp:36
void filter()
Filter the incoming data.
Definition: copy.cpp:44
Laser data filter.
Definition: filter.h:33
unsigned int out_data_size
Number of entries in output arrays.
Definition: filter.h:87
unsigned int in_data_size
Number of entries in input arrays.
Definition: filter.h:88
std::vector< Buffer * > out
Vector of output arrays.
Definition: filter.h:90
std::vector< Buffer * > in
Vector of input arrays.
Definition: filter.h:89