mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
aggregateWith takes a const reference
This commit is contained in:
@@ -82,8 +82,6 @@ class AerobicDecoupling : public RideMetric {
|
||||
}
|
||||
}
|
||||
|
||||
bool canAggregate() const { return false; }
|
||||
void aggregateWith(RideMetric *) { assert(false); }
|
||||
RideMetric *clone() const { return new AerobicDecoupling(*this); }
|
||||
};
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class WorkoutTime : public RideMetric {
|
||||
seconds = ride->dataPoints().back()->secs;
|
||||
}
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) { seconds += other->value(true); }
|
||||
void aggregateWith(const RideMetric &other) { seconds += other.value(true); }
|
||||
RideMetric *clone() const { return new WorkoutTime(*this); }
|
||||
};
|
||||
|
||||
@@ -65,8 +65,8 @@ class TimeRiding : public RideMetric {
|
||||
}
|
||||
}
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) {
|
||||
secsMovingOrPedaling += other->value(true);
|
||||
void aggregateWith(const RideMetric &other) {
|
||||
secsMovingOrPedaling += other.value(true);
|
||||
}
|
||||
RideMetric *clone() const { return new TimeRiding(*this); }
|
||||
};
|
||||
@@ -94,7 +94,7 @@ class TotalDistance : public RideMetric {
|
||||
km = ride->dataPoints().back()->km;
|
||||
}
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) { km += other->value(true); }
|
||||
void aggregateWith(const RideMetric &other) { km += other.value(true); }
|
||||
RideMetric *clone() const { return new TotalDistance(*this); }
|
||||
};
|
||||
|
||||
@@ -132,8 +132,8 @@ class ElevationGain : public RideMetric {
|
||||
}
|
||||
}
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) {
|
||||
elegain += other->value(true);
|
||||
void aggregateWith(const RideMetric &other) {
|
||||
elegain += other.value(true);
|
||||
}
|
||||
RideMetric *clone() const { return new ElevationGain(*this); }
|
||||
};
|
||||
@@ -162,10 +162,10 @@ class TotalWork : public RideMetric {
|
||||
}
|
||||
}
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) {
|
||||
assert(symbol() == other->symbol());
|
||||
TotalWork *tw = dynamic_cast<TotalWork*>(other);
|
||||
joules += tw->joules;
|
||||
void aggregateWith(const RideMetric &other) {
|
||||
assert(symbol() == other.symbol());
|
||||
const TotalWork &tw = dynamic_cast<const TotalWork&>(other);
|
||||
joules += tw.joules;
|
||||
}
|
||||
RideMetric *clone() const { return new TotalWork(*this); }
|
||||
};
|
||||
@@ -198,11 +198,11 @@ class AvgSpeed : public RideMetric {
|
||||
if (point->kph > 0.0) secsMoving += ride->recIntSecs();
|
||||
}
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) {
|
||||
assert(symbol() == other->symbol());
|
||||
AvgSpeed *as = dynamic_cast<AvgSpeed*>(other);
|
||||
secsMoving += as->secsMoving;
|
||||
km += as->km;
|
||||
void aggregateWith(const RideMetric &other) {
|
||||
assert(symbol() == other.symbol());
|
||||
const AvgSpeed &as = dynamic_cast<const AvgSpeed&>(other);
|
||||
secsMoving += as.secsMoving;
|
||||
km += as.km;
|
||||
}
|
||||
RideMetric *clone() const { return new AvgSpeed(*this); }
|
||||
};
|
||||
|
||||
@@ -91,11 +91,11 @@ class XPower : public RideMetric {
|
||||
|
||||
// added djconnel: allow RI to be combined across rides
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) {
|
||||
assert(symbol() == other->symbol());
|
||||
XPower *ap = dynamic_cast<XPower*>(other);
|
||||
xpower = pow(xpower, bikeScoreN) * secs + pow(ap->xpower, bikeScoreN) * ap->secs;
|
||||
secs += ap->secs;
|
||||
void aggregateWith(const RideMetric &other) {
|
||||
assert(symbol() == other.symbol());
|
||||
const XPower &ap = dynamic_cast<const XPower&>(other);
|
||||
xpower = pow(xpower, bikeScoreN) * secs + pow(ap.xpower, bikeScoreN) * ap.secs;
|
||||
secs += ap.secs;
|
||||
xpower = pow(xpower / secs, 1 / bikeScoreN);
|
||||
}
|
||||
// end added djconnel
|
||||
@@ -128,11 +128,11 @@ class RelativeIntensity : public RideMetric {
|
||||
|
||||
// added djconnel: allow RI to be combined across rides
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) {
|
||||
assert(symbol() == other->symbol());
|
||||
RelativeIntensity *ap = dynamic_cast<RelativeIntensity*>(other);
|
||||
reli = secs * pow(reli, bikeScoreN) + ap->secs * pow(ap->reli, bikeScoreN);
|
||||
secs += ap->secs;
|
||||
void aggregateWith(const RideMetric &other) {
|
||||
assert(symbol() == other.symbol());
|
||||
const RelativeIntensity &ap = dynamic_cast<const RelativeIntensity&>(other);
|
||||
reli = secs * pow(reli, bikeScoreN) + ap.secs * pow(ap.reli, bikeScoreN);
|
||||
secs += ap.secs;
|
||||
reli = pow(reli / secs, 1.0 / bikeScoreN);
|
||||
}
|
||||
// end added djconnel
|
||||
@@ -171,7 +171,7 @@ class BikeScore : public RideMetric {
|
||||
}
|
||||
RideMetric *clone() const { return new BikeScore(*this); }
|
||||
bool canAggregate() const { return true; }
|
||||
void aggregateWith(RideMetric *other) { score += other->value(true); }
|
||||
void aggregateWith(const RideMetric &other) { score += other.value(true); }
|
||||
};
|
||||
|
||||
static bool addAllThree() {
|
||||
|
||||
@@ -97,10 +97,7 @@ class DanielsPoints : public RideMetric {
|
||||
count(secsDelta, weighted);
|
||||
}
|
||||
}
|
||||
virtual void aggregateWith(RideMetric *other) {
|
||||
DanielsPoints *cs = (DanielsPoints*) other;
|
||||
score += cs->score;
|
||||
}
|
||||
void aggregateWith(const RideMetric &other) { score += other.value(true); }
|
||||
RideMetric *clone() const { return new DanielsPoints(*this); }
|
||||
};
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ struct RideMetric {
|
||||
assert(false);
|
||||
}
|
||||
virtual bool canAggregate() const { return false; }
|
||||
virtual void aggregateWith(RideMetric *other) {
|
||||
virtual void aggregateWith(const RideMetric &other) {
|
||||
(void) other;
|
||||
assert(false);
|
||||
}
|
||||
@@ -90,11 +90,11 @@ class AvgRideMetric : public RideMetric {
|
||||
if (count == 0) return 0.0;
|
||||
return total / count;
|
||||
}
|
||||
void aggregateWith(RideMetric *other) {
|
||||
assert(symbol() == other->symbol());
|
||||
AvgRideMetric *as = dynamic_cast<AvgRideMetric*>(other);
|
||||
count += as->count;
|
||||
total += as->total;
|
||||
void aggregateWith(const RideMetric &other) {
|
||||
assert(symbol() == other.symbol());
|
||||
const AvgRideMetric &as = dynamic_cast<const AvgRideMetric&>(other);
|
||||
count += as.count;
|
||||
total += as.total;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -205,35 +205,35 @@ WeeklySummaryWindow::refresh()
|
||||
|
||||
RideMetric *m;
|
||||
if ((m = item->metrics.value(weeklySeconds->symbol()))) {
|
||||
weeklySeconds->aggregateWith(m);
|
||||
dailySeconds[day]->aggregateWith(m);
|
||||
weeklySeconds->aggregateWith(*m);
|
||||
dailySeconds[day]->aggregateWith(*m);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value(weeklyDistance->symbol()))) {
|
||||
weeklyDistance->aggregateWith(m);
|
||||
dailyDistance[day]->aggregateWith(m);
|
||||
weeklyDistance->aggregateWith(*m);
|
||||
dailyDistance[day]->aggregateWith(*m);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value(weeklyWork->symbol()))) {
|
||||
weeklyWork->aggregateWith(m);
|
||||
dailyW[day]->aggregateWith(m);
|
||||
weeklyWork->aggregateWith(*m);
|
||||
dailyW[day]->aggregateWith(*m);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value(weeklyCS->symbol())))
|
||||
weeklyCS->aggregateWith(m);
|
||||
weeklyCS->aggregateWith(*m);
|
||||
|
||||
if ((m = item->metrics.value(weeklyBS->symbol()))) {
|
||||
weeklyBS->aggregateWith(m);
|
||||
dailyBS[day]->aggregateWith(m);
|
||||
weeklyBS->aggregateWith(*m);
|
||||
dailyBS[day]->aggregateWith(*m);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value(weeklyRelIntensity->symbol()))) {
|
||||
weeklyRelIntensity->aggregateWith(m);
|
||||
dailyRI[day]->aggregateWith(m);
|
||||
weeklyRelIntensity->aggregateWith(*m);
|
||||
dailyRI[day]->aggregateWith(*m);
|
||||
}
|
||||
|
||||
if ((m = item->metrics.value("skiba_xpower")))
|
||||
dailyXP[day]->aggregateWith(m);
|
||||
dailyXP[day]->aggregateWith(*m);
|
||||
|
||||
// compute time in zones
|
||||
if (zones) {
|
||||
|
||||
Reference in New Issue
Block a user