]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/speedquantizer.h
Remove the GTK-based remote control program
[r2c2.git] / source / libr2c2 / speedquantizer.h
1 #ifndef LIBR2C2_SPEEDQUANTIZER_H_
2 #define LIBR2C2_SPEEDQUANTIZER_H_
3
4 #include <list>
5 #include <vector>
6 #include <msp/datafile/objectloader.h>
7
8 namespace R2C2 {
9
10 class SpeedQuantizer
11 {
12 public:
13         class Loader: public Msp::DataFile::ObjectLoader<SpeedQuantizer>
14         {
15         public:
16                 Loader(SpeedQuantizer &);
17         private:
18                 void step(unsigned, float, float);
19         };
20
21 private:
22         struct SpeedStep
23         {
24                 float speed;
25                 float weight;
26
27                 SpeedStep();
28                 void add(float, float);
29         };
30
31         std::vector<SpeedStep> steps;
32         float weight_limit;
33
34 public:
35         SpeedQuantizer(unsigned);
36
37         void learn(unsigned, float, float);
38         float get_speed(unsigned) const;
39         float quantize_speed(float) const;
40         unsigned find_speed_step(float) const;
41
42         void save(std::list<Msp::DataFile::Statement> &) const;
43 };
44
45 } // namespace R2C2
46
47 #endif