pointfilter.h
Go to the documentation of this file.
1 
8 #ifndef POINT_FILTER_H
9 #define POINT_FILTER_H
10 
11 #include <string>
12 #include <map>
13 
14 class Checker;
15 
16 
24 {
25 public:
26  // Default empty constructor
27  PointFilter();
29  PointFilter(const std::string& params);
30  ~PointFilter();
31 
32  PointFilter& setRange(double maxDist, double minDist);
33  PointFilter& setHeight(double top, double bottom);
34 
36  std::string getParams();
37 
39  inline bool check(double* point);
40 private:
42  std::map<std::string, std::string> m_params;
43 
45  bool m_changed;
46 
49 
51  void createCheckers();
52 
53  // factory magic
54  template<typename T> friend struct CheckerFactory;
55  static std::map<std::string, Checker* (*)(const std::string&)>* factory;
56 };
57 
58 class Checker {
59 public:
60  Checker();
61  ~Checker();
62 
64  virtual bool test(double* point) = 0;
65 
68 };
69 
71 template<typename T>
74  CheckerFactory(const std::string& key) { (*PointFilter::factory)[key] = CheckerFactory<T>::create; }
76  static Checker* create(const std::string& value) { try { return new T(value); } catch(...) { return 0; } }
77 };
78 
79 class CheckerRangeMax : public Checker {
80 public:
81  CheckerRangeMax(const std::string& value);
82  virtual bool test(double* point);
83 private:
84  double m_max;
85 };
86 
87 class CheckerRangeMin : public Checker {
88 public:
89  CheckerRangeMin(const std::string& value);
90  virtual bool test(double* point);
91 private:
92  double m_min;
93 };
94 
95 class CheckerHeightTop : public Checker {
96 public:
97  CheckerHeightTop(const std::string& value);
98  virtual bool test(double* point);
99 private:
100  double m_top;
101 };
102 
103 class CheckerHeightBottom : public Checker {
104 public:
105  CheckerHeightBottom(const std::string& value);
106  virtual bool test(double* point);
107 private:
108  double m_bottom;
109 };
110 
111 #include "pointfilter.icc"
112 
113 #endif //POINT_FILTER_H
PointFilter::setRange
PointFilter & setRange(double maxDist, double minDist)
CheckerHeightBottom::test
virtual bool test(double *point)
Testing function.
PointFilter::createCheckers
void createCheckers()
Allocation of the checkers.
CheckerRangeMin::test
virtual bool test(double *point)
Testing function.
CheckerRangeMin
Definition: pointfilter.h:87
PointFilter::PointFilter
PointFilter()
CheckerHeightTop::CheckerHeightTop
CheckerHeightTop(const std::string &value)
Checker
Definition: pointfilter.h:58
CheckerRangeMax
Definition: pointfilter.h:79
PointFilter::m_changed
bool m_changed
If either not created yet or parameters get changed, this flag will cause check to create a new Check...
Definition: pointfilter.h:45
CheckerHeightBottom::CheckerHeightBottom
CheckerHeightBottom(const std::string &value)
CheckerRangeMax::m_max
double m_max
Definition: pointfilter.h:84
PointFilter::~PointFilter
~PointFilter()
CheckerFactory
Factory integrating the create-function and adding it to the lookup map in an easy template.
Definition: pointfilter.h:72
Checker::Checker
Checker()
Checker::m_next
Checker * m_next
Next test in chain.
Definition: pointfilter.h:67
lvr2::map
OutMapT< typename InMapT::HandleType, std::result_of_t< MapF(typename InMapT::ValueType)> > map(const InMapT &mapIn, MapF func)
Calls func for each value of the given map and save the result in the output map.
Checker::test
virtual bool test(double *point)=0
Testing function.
CheckerHeightTop
Definition: pointfilter.h:95
CheckerHeightTop::test
virtual bool test(double *point)
Testing function.
CheckerRangeMin::m_min
double m_min
Definition: pointfilter.h:92
CheckerHeightTop::m_top
double m_top
Definition: pointfilter.h:100
PointFilter::getParams
std::string getParams()
Serialization function to convert it into a string, usable in the constructor.
CheckerRangeMax::test
virtual bool test(double *point)
Testing function.
PointFilter
Definition: pointfilter.h:23
PointFilter::check
bool check(double *point)
Check a point, returning success if all contained Checker functions accept that point (implemented in...
CheckerHeightBottom::m_bottom
double m_bottom
Definition: pointfilter.h:108
Checker::~Checker
~Checker()
CheckerRangeMin::CheckerRangeMin
CheckerRangeMin(const std::string &value)
PointFilter::factory
static std::map< std::string, Checker *(*)(const std::string &)> * factory
Definition: pointfilter.h:55
CheckerHeightBottom
Definition: pointfilter.h:103
PointFilter::m_checker
Checker * m_checker
created in the first check call with the changed flag set
Definition: pointfilter.h:48
CheckerFactory::CheckerFactory
CheckerFactory(const std::string &key)
Instanciate in the source code with the to be created class as template argument and associated key s...
Definition: pointfilter.h:74
CheckerFactory::create
static Checker * create(const std::string &value)
Automated create function, safely returning a nullpointer if the constructor throws for unwanted valu...
Definition: pointfilter.h:76
PointFilter::setHeight
PointFilter & setHeight(double top, double bottom)
CheckerRangeMax::CheckerRangeMax
CheckerRangeMax(const std::string &value)
PointFilter::m_params
std::map< std::string, std::string > m_params
Storage for parameter keys and values.
Definition: pointfilter.h:42


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:24