Fawkes API  Fawkes Development Version
filter.h
1 
2 /***************************************************************************
3  * filter.h - Laser data filter interface
4  *
5  * Created: Fri Oct 10 17:11:04 2008
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef __PLUGINS_LASER_FILTER_FILTER_H_
23 #define __PLUGINS_LASER_FILTER_FILTER_H_
24 
25 #include <vector>
26 #include <string>
27 
28 namespace fawkes {
29  class Time;
30 }
31 
33 {
34  public:
35  class Buffer {
36  public:
37  Buffer(size_t num_values = 0);
38  ~Buffer();
39  std::string name; ///< name of the input buffer
40  std::string frame; ///< reference coordinate frame ID
41  float *values; ///< values
42  fawkes::Time *timestamp; ///< timestamp of data
43  };
44 
45  LaserDataFilter(const std::string filter_name,
46  unsigned int in_data_size,
47  std::vector<Buffer *> &in, unsigned int out_size);
48  virtual ~LaserDataFilter();
49 
50  virtual std::vector<Buffer *> & get_out_vector();
51  virtual void set_out_vector(std::vector<Buffer *> &out);
52  virtual unsigned int get_out_data_size();
53 
54  virtual void filter() = 0;
55 
56  void set_array_ownership(bool own_in, bool own_out);
57  /** Check if input arrays are owned by filter.
58  * @return true if arrays are owned by this filter, false otherwise. */
59  bool owns_in() const { return __own_in; };
60  /** Check if output arrays are owned by filter.
61  * @return true if arrays are owned by this filter, false otherwise. */
62  bool owns_out() const { return __own_out; };
63 
64  protected:
65  virtual void set_out_data_size(unsigned int data_size);
66 
67  void reset_outbuf(Buffer *b);
68  void copy_to_outbuf(Buffer *outbuf, const Buffer *inbuf);
69 
70 
71  protected:
72  const std::string filter_name;
73  unsigned int out_data_size;
74  unsigned int in_data_size;
75  std::vector<Buffer *> in;
76  std::vector<Buffer *> out;
77 
78  private:
79  bool __own_in;
80  bool __own_out;
81 };
82 
83 
84 #endif
std::string name
name of the input buffer
Definition: filter.h:39
float * values
values
Definition: filter.h:41
std::vector< Buffer * > out
Vector of output arrays.
Definition: filter.h:76
Fawkes library namespace.
A class for handling time.
Definition: time.h:91
std::string frame
reference coordinate frame ID
Definition: filter.h:40
Laser data buffer.
Definition: filter.h:35
bool owns_out() const
Check if output arrays are owned by filter.
Definition: filter.h:62
const std::string filter_name
Name of the specific filter instance.
Definition: filter.h:72
bool owns_in() const
Check if input arrays are owned by filter.
Definition: filter.h:59
fawkes::Time * timestamp
timestamp of data
Definition: filter.h:42
unsigned int out_data_size
Number of entries in output arrays.
Definition: filter.h:73
std::vector< Buffer * > in
Vector of input arrays.
Definition: filter.h:75
unsigned int in_data_size
Number of entries in input arrays.
Definition: filter.h:74
Laser data filter.
Definition: filter.h:32