Skip to content

Commit

Permalink
Change class member naming convention to member_
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Aug 7, 2023
1 parent 6376e5a commit 853a82f
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 178 deletions.
16 changes: 8 additions & 8 deletions extras/tests/TestFixtures/Clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ class ClockWatcher {
class Clock {
public:
void set(unsigned long time) {
_time = time;
std::vector<ClockWatcher *> watchers(_watchers.begin(), _watchers.end());
time_ = time;
std::vector<ClockWatcher *> watchers(watchers_.begin(), watchers_.end());
for (auto watcher : watchers)
watcher->timeChanged(_time);
watcher->timeChanged(time_);
}

unsigned long get() const {
return _time;
return time_;
}

void addWatcher(ClockWatcher *watcher) {
_watchers.insert(watcher);
watchers_.insert(watcher);
}

void removeWatcher(ClockWatcher *watcher) {
_watchers.erase(watcher);
watchers_.erase(watcher);
}

private:
unsigned long _time = 0;
std::set<ClockWatcher *> _watchers;
unsigned long time_ = 0;
std::set<ClockWatcher *> watchers_;
};

extern Clock theClock;
2 changes: 1 addition & 1 deletion extras/tests/TestFixtures/EventLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ std::ostream &operator<<(std::ostream &os, const EventLog::event_t &value) {
}

std::string EventLog::diff(const EventLog &expected) const {
dtl::Diff<event_t> diff(expected._events, _events);
dtl::Diff<event_t> diff(expected.events_, events_);
diff.compose();
std::ostringstream message;
diff.printSES(message);
Expand Down
10 changes: 5 additions & 5 deletions extras/tests/TestFixtures/EventLog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ class EventLog {
using event_t = std::pair<timestamp_t, std::string>;

EventLog() {}
EventLog(std::initializer_list<event_t> events) : _events(events) {}
EventLog(std::initializer_list<event_t> events) : events_(events) {}

void add(timestamp_t t, std::string event) {
_events.emplace_back(t, std::move(event));
events_.emplace_back(t, std::move(event));
}

void clear() {
_events.clear();
events_.clear();
}

std::string diff(const EventLog &) const;

bool operator!=(const EventLog &other) const {
return _events != other._events;
return events_ != other.events_;
}

private:
std::vector<event_t> _events;
std::vector<event_t> events_;
};

extern EventLog theEventLog;
Expand Down
22 changes: 11 additions & 11 deletions extras/tests/TestFixtures/TeensyTimerTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ class PeriodicTimer : ClockWatcher {

void begin(callback_t callback, unsigned long period, bool start = true) {
logEvent("PeriodicTimer::begin(%lu, %s)", period, start ? "true" : "false");
_callback = callback;
_period = period;
callback_ = callback;
period_ = period;
if (start)
theClock.addWatcher(this);
}

void attachInterrupt(callback_t cb) {
logEvent("PeriodicTimer::attachInterrupt()");
_callback = cb;
callback_ = cb;
}

void setPeriod(unsigned long period) {
logEvent("PeriodicTimer::setPeriod(%lu)", period);
_period = period;
period_ = period;
}

void start() {
Expand All @@ -41,16 +41,16 @@ class PeriodicTimer : ClockWatcher {

private:
void timeChanged(unsigned long time) override {
if (time - _lastTime >= _period) {
_lastTime = time;
if (_callback)
_callback();
if (time - lastTime_ >= period_) {
lastTime_ = time;
if (callback_)
callback_();
}
}

unsigned long _period = 0;
unsigned long _lastTime = 0;
callback_t _callback = nullptr;
unsigned long period_ = 0;
unsigned long lastTime_ = 0;
callback_t callback_ = nullptr;
};

} // namespace TeensyTimerTool
18 changes: 9 additions & 9 deletions extras/tests/TestFixtures/TimerOne.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class TimerOne : ClockWatcher {

void attachInterrupt(callback_t cb) {
logEvent("TimerOne::attachInterrupt()");
_callback = cb;
callback_ = cb;
}

void setPeriod(unsigned long period) {
logEvent("TimerOne::setPeriod(%lu)", period);
_period = period;
period_ = period;
}

void start() {
Expand All @@ -33,14 +33,14 @@ class TimerOne : ClockWatcher {

private:
void timeChanged(unsigned long time) override {
if (time - _lastTime >= _period) {
_lastTime = time;
if (_callback)
_callback();
if (time - lastTime_ >= period_) {
lastTime_ = time;
if (callback_)
callback_();
}
}

unsigned long _period = 0;
unsigned long _lastTime = 0;
callback_t _callback = nullptr;
unsigned long period_ = 0;
unsigned long lastTime_ = 0;
callback_t callback_ = nullptr;
};
18 changes: 9 additions & 9 deletions extras/tests/TestFixtures/TimerThree.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class TimerThree : ClockWatcher {

void attachInterrupt(callback_t cb) {
logEvent("TimerThree::attachInterrupt()");
_callback = cb;
callback_ = cb;
}

void setPeriod(unsigned long period) {
logEvent("TimerThree::setPeriod(%lu)", period);
_period = period;
period_ = period;
}

void start() {
Expand All @@ -33,14 +33,14 @@ class TimerThree : ClockWatcher {

private:
void timeChanged(unsigned long time) override {
if (time - _lastTime >= _period) {
_lastTime = time;
if (_callback)
_callback();
if (time - lastTime_ >= period_) {
lastTime_ = time;
if (callback_)
callback_();
}
}

unsigned long _period = 0;
unsigned long _lastTime = 0;
callback_t _callback = nullptr;
unsigned long period_ = 0;
unsigned long lastTime_ = 0;
callback_t callback_ = nullptr;
};
18 changes: 9 additions & 9 deletions src/ContinuousStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ namespace ArduinoContinuousStepper {

class StepperTicker {
protected:
StepperTicker(TickListener *listener) : _listener(listener) {}
StepperTicker(TickListener *listener) : listener_(listener) {}

void tick() {
_listener->tick();
listener_->tick();
}

private:
TickListener *_listener;
TickListener *listener_;
};

class LoopTicker : StepperTicker {
public:
void loop() {
if (!_tickPeriod)
if (!tickPeriod_)
return;

time_t now = micros();
time_t elapsed = now - _lastTick;
time_t elapsed = now - lastTick_;

if (elapsed >= _tickPeriod) {
if (elapsed >= tickPeriod_) {
tick();
_lastTick = now;
lastTick_ = now;
}
}

Expand All @@ -40,15 +40,15 @@ class LoopTicker : StepperTicker {
void init() {}

void setPeriod(unsigned long period) {
_tickPeriod = period;
tickPeriod_ = period;
}

private:
static time_t now() {
return micros();
}

time_t _tickPeriod, _lastTick = 0;
time_t tickPeriod_, lastTick_ = 0;
};

template <class TStepper, class TTicker = LoopTicker>
Expand Down
Loading

0 comments on commit 853a82f

Please sign in to comment.