OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ | |
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ | |
7 | |
8 namespace device_orientation { | |
9 class Motion { | |
10 public: | |
11 // acceleration_x, acceleration_y, and acceleration_z are the accelerations | |
12 // excluding gravity along the axes specified in | |
13 // http://dev.w3.org/geo/api/spec-source-orientation.html | |
14 | |
15 // acceleration_including_gravity_x, acceleration_including_gravity_y, and | |
16 // acceleration_including_gravity_z are the accelerations including gravity | |
17 // along the same axes as above | |
18 | |
19 // rotation_rate_alpha, rotation_rate_beta, and rotataion_rate_gamma are the | |
20 // rotations around the same axes as above | |
21 | |
22 // interval is the time interval at which data is obtained from the hardware, | |
23 // as specified in the document referenced above | |
24 | |
25 // can_provide_{acceleration_x, acceleration_y, acceleration_z, | |
26 // acceleration_including_gravity_x, acceleration_including_gravity_y, | |
27 // acceleration_including_gravity_z, rotation_rate_alpha, rotation_rate_beta, | |
28 // rotation_rate_gamma, interval} is true if data can be provided for that | |
29 // variable | |
30 | |
31 Motion(); | |
32 Motion(const Motion&); | |
bulach
2012/07/02 12:47:56
is this copy constructor necessary? if possible, i
aousterh
2012/07/04 13:31:55
The copy constructor is used in device_orientation
| |
33 | |
34 static Motion Empty() { return Motion(); } | |
35 | |
36 bool IsEmpty() const { | |
37 return !can_provide_acceleration_x_ && !can_provide_acceleration_y_ && | |
38 !can_provide_acceleration_z_ && | |
39 !can_provide_acceleration_including_gravity_x_ && | |
40 !can_provide_acceleration_including_gravity_y_ && | |
41 !can_provide_acceleration_including_gravity_z_ && | |
42 !can_provide_rotation_rate_alpha_ && | |
43 !can_provide_rotation_rate_beta_ && | |
44 !can_provide_rotation_rate_gamma_ && | |
45 !can_provide_interval_; | |
46 } | |
47 | |
48 void setAccelerationX(double accelerationX) { | |
bulach
2012/07/02 12:47:56
nit: wrong case, needs to s/set/Set/ and s/can/Can
aousterh
2012/07/04 13:31:55
Done.
| |
49 can_provide_acceleration_x_ = true; | |
50 acceleration_x_ = accelerationX; | |
51 } | |
52 bool canProvideAccelerationX() const { return can_provide_acceleration_x_; } | |
53 double accelerationX() const { return acceleration_x_; } | |
54 | |
55 void setAccelerationY(double accelerationY) { | |
56 can_provide_acceleration_y_ = true; | |
57 acceleration_y_ = accelerationY; | |
58 } | |
59 bool canProvideAccelerationY() const { return can_provide_acceleration_y_; } | |
60 double accelerationY() const { return acceleration_y_; } | |
61 | |
62 void setAccelerationZ(double accelerationZ) { | |
63 can_provide_acceleration_z_ = true; | |
64 acceleration_z_ = accelerationZ; | |
65 } | |
66 bool canProvideAccelerationZ() const { return can_provide_acceleration_z_; } | |
67 double accelerationZ() const { return acceleration_z_; } | |
68 | |
69 void setAccelerationIncludingGravityX(double accelerationIncludingGravityX) { | |
70 can_provide_acceleration_including_gravity_x_ = true; | |
71 acceleration_including_gravity_x_ = accelerationIncludingGravityX; | |
72 } | |
73 bool canProvideAccelerationIncludingGravityX() const { | |
74 return can_provide_acceleration_x_; | |
75 } | |
76 double accelerationIncludingGravityX() const { | |
77 return acceleration_including_gravity_x_; | |
78 } | |
79 | |
80 void setAccelerationIncludingGravityY(double accelerationIncludingGravityY) { | |
81 can_provide_acceleration_including_gravity_y_ = true; | |
82 acceleration_including_gravity_y_ = accelerationIncludingGravityY; | |
83 } | |
84 bool canProvideAccelerationIncludingGravityY() const { | |
85 return can_provide_acceleration_y_; | |
86 } | |
87 double accelerationIncludingGravityY() const { | |
88 return acceleration_including_gravity_y_; | |
89 } | |
90 | |
91 void setAccelerationIncludingGravityZ(double accelerationIncludingGravityZ) { | |
92 can_provide_acceleration_including_gravity_z_ = true; | |
93 acceleration_including_gravity_z_ = accelerationIncludingGravityZ; | |
94 } | |
95 bool canProvideAccelerationIncludingGravityZ() const { | |
96 return can_provide_acceleration_z_; | |
97 } | |
98 double accelerationIncludingGravityZ() const { | |
99 return acceleration_including_gravity_z_; | |
100 } | |
101 | |
102 void setRotationRateAlpha(double rotationRateAlpha) { | |
103 can_provide_rotation_rate_alpha_ = true; | |
104 rotation_rate_alpha_ = rotationRateAlpha; | |
105 } | |
106 bool canProvideRotationRateAlpha() const { | |
107 return can_provide_rotation_rate_alpha_; | |
108 } | |
109 double rotationRateAlpha() const { return rotation_rate_alpha_; } | |
110 | |
111 void setRotationRateBeta(double rotationRateBeta) { | |
112 can_provide_rotation_rate_beta_ = true; | |
113 rotation_rate_beta_ = rotationRateBeta; | |
114 } | |
115 bool canProvideRotationRateBeta() const { | |
116 return can_provide_rotation_rate_beta_; | |
117 } | |
118 double rotationRateBeta() const { return rotation_rate_beta_; } | |
119 | |
120 void setRotationRateGamma(double rotationRateGamma) { | |
121 can_provide_rotation_rate_gamma_ = true; | |
122 rotation_rate_gamma_ = rotationRateGamma; | |
123 } | |
124 bool canProvideRotationRateGamma() const { | |
125 return can_provide_rotation_rate_gamma_; | |
126 } | |
127 double rotationRateGamma() const { return rotation_rate_gamma_; } | |
128 | |
129 void setInterval(double interval) { | |
130 can_provide_interval_ = true; | |
131 interval_ = interval; | |
132 } | |
133 bool canProvideInterval() const { return can_provide_interval_; } | |
134 double interval() const { return interval_; } | |
135 | |
136 private: | |
137 double acceleration_x_; | |
138 double acceleration_y_; | |
139 double acceleration_z_; | |
140 double acceleration_including_gravity_x_; | |
141 double acceleration_including_gravity_y_; | |
142 double acceleration_including_gravity_z_; | |
143 double rotation_rate_alpha_; | |
144 double rotation_rate_beta_; | |
145 double rotation_rate_gamma_; | |
146 double interval_; | |
147 bool can_provide_acceleration_x_; | |
148 bool can_provide_acceleration_y_; | |
149 bool can_provide_acceleration_z_; | |
150 bool can_provide_acceleration_including_gravity_x_; | |
151 bool can_provide_acceleration_including_gravity_y_; | |
152 bool can_provide_acceleration_including_gravity_z_; | |
153 bool can_provide_rotation_rate_alpha_; | |
154 bool can_provide_rotation_rate_beta_; | |
155 bool can_provide_rotation_rate_gamma_; | |
156 bool can_provide_interval_; | |
157 }; | |
158 | |
159 } // namespace device_orientation | |
160 | |
161 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ | |
OLD | NEW |