Last change
on this file since 10256 was
9780,
checked in by georgr, 11 years ago
|
WiiCpp library successfully added - won't work without libbluetooth-dev
|
File size:
1.4 KB
|
Line | |
---|
1 | #ifndef TRAINING_H |
---|
2 | #define TRAINING_H |
---|
3 | |
---|
4 | #include <fstream> |
---|
5 | #include <iostream> |
---|
6 | #include <vector> |
---|
7 | #include <sstream> |
---|
8 | #include "sample.h" |
---|
9 | #include "accsample.h" |
---|
10 | #include "gyrosample.h" |
---|
11 | |
---|
12 | using namespace std; |
---|
13 | |
---|
14 | /** |
---|
15 | * Class Training to save the individual training of a gesture |
---|
16 | */ |
---|
17 | class Training |
---|
18 | { |
---|
19 | public: |
---|
20 | /** |
---|
21 | * Default constructor. |
---|
22 | */ |
---|
23 | Training() { } |
---|
24 | ~Training(); |
---|
25 | |
---|
26 | bool loadTraining(ifstream&); |
---|
27 | void save(ofstream&) const; |
---|
28 | void addSample(Sample*); |
---|
29 | void clear(); |
---|
30 | |
---|
31 | /** |
---|
32 | * Returns the i-th sample of the training as a constant pointer. |
---|
33 | * |
---|
34 | * @param i Sample index in the training set |
---|
35 | */ |
---|
36 | inline const Sample* sampleAt(unsigned int i) const { |
---|
37 | if(i < samples.size()) |
---|
38 | return samples[i]; |
---|
39 | else { |
---|
40 | cout << "[Error]: requested out of array bound index in training." << endl; |
---|
41 | return 0; |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | /** |
---|
46 | * Returns the i-th sample of the training as a pointer. |
---|
47 | * |
---|
48 | * @param i Sample index in the training set |
---|
49 | */ |
---|
50 | inline Sample* sampleAt(unsigned int i) { |
---|
51 | if(i < samples.size()) |
---|
52 | return samples[i]; |
---|
53 | else { |
---|
54 | cout << "[Error]: requested out of array bound index in training." << endl; |
---|
55 | return 0; |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * Number of samples in the current training. |
---|
61 | */ |
---|
62 | inline unsigned int size() const { return samples.size(); } |
---|
63 | |
---|
64 | inline void setTimestampFromMidnight(unsigned long ts) { timestamp = ts; } |
---|
65 | |
---|
66 | private: |
---|
67 | vector<Sample*> samples; |
---|
68 | unsigned long timestamp; // Training timestamp (beginning of the gesture) |
---|
69 | }; |
---|
70 | |
---|
71 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.