-
Notifications
You must be signed in to change notification settings - Fork 8
/
DirectionlessOdometer.hpp
39 lines (31 loc) · 999 Bytes
/
DirectionlessOdometer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef CPP_REFACTORING_FOR_TESTABILITY_DIRECTIONLESSODOMETER_HPP
#define CPP_REFACTORING_FOR_TESTABILITY_DIRECTIONLESSODOMETER_HPP
#include "Encoder.hpp"
#include "InterruptServiceManager.hpp"
#include "MyInterruptServiceManager.hpp" // Remove this after refactoring
#include "Odometer.hpp"
namespace before
{
struct DirectionlessOdometer : public Odometer
{
DirectionlessOdometer(int pulsePin, int pulsesPerMeter);
double getDistance() const override;
protected:
const int mPulsesPerMeter;
int mPulses{0};
MyInterruptServiceManager mInterruptManager;
};
} // namespace before
namespace after
{
struct DirectionlessOdometer : public Odometer
{
DirectionlessOdometer(Encoder& encoder,
InterruptServiceManager& interruptServiceManager,
int pulsePin);
double getDistance() const override;
private:
Encoder& mEncoder;
};
} // namespace after
#endif // CPP_REFACTORING_FOR_TESTABILITY_DIRECTIONLESSODOMETER_HPP