s/properties/propertyValues/

This list stores different values for the same property, but the
property itself remains the same.
This commit is contained in:
Bruno de Oliveira Abinader
2015-07-13 03:15:14 +03:00
parent 7023ea061c
commit 7d8b4dc6c0
3 changed files with 11 additions and 12 deletions

View File

@@ -10,15 +10,15 @@ AppliedClassProperty::AppliedClassProperty(ClassID class_id, TimePoint begin_, T
// Returns the ID of the most recent
ClassID AppliedClassProperties::mostRecent() const {
return properties.size() ? properties.back().name : ClassID::Fallback;
return propertyValues.empty() ? ClassID::Fallback : propertyValues.back().name;
}
void AppliedClassProperties::add(ClassID class_id, TimePoint begin, TimePoint end, const PropertyValue &value) {
properties.emplace_back(class_id, begin, end, value);
propertyValues.emplace_back(class_id, begin, end, value);
}
bool AppliedClassProperties::hasTransitions() const {
return properties.size() > 1;
return propertyValues.size() > 1;
}
// Erase all items in the property list that are before a completed transition.
@@ -26,19 +26,19 @@ bool AppliedClassProperties::hasTransitions() const {
void AppliedClassProperties::cleanup(TimePoint now) {
// Iterate backwards, but without using the rbegin/rend interface since we need forward
// iterators to use .erase().
for (auto it = properties.end(), begin = properties.begin(); it != begin;) {
for (auto it = propertyValues.end(), begin = propertyValues.begin(); it != begin;) {
// If the property is finished, break iteration and delete all remaining items.
if ((--it)->end <= now) {
// Removes all items that precede the current iterator, but *not* the element currently
// pointed to by the iterator. This preserves the last completed transition as the
// first element in the property list.
properties.erase(begin, it);
propertyValues.erase(begin, it);
// Also erase the pivot element if it's a fallback value. This means we can remove the
// entire applied properties object as well, because we already have the fallback
// value set as the default.
if (it->name == ClassID::Fallback) {
properties.erase(it);
propertyValues.erase(it);
}
break;
}
@@ -46,7 +46,7 @@ void AppliedClassProperties::cleanup(TimePoint now) {
}
bool AppliedClassProperties::empty() const {
return properties.empty();
return propertyValues.empty();
}
}

View File

@@ -23,14 +23,14 @@ public:
class AppliedClassProperties {
public:
std::list<AppliedClassProperty> properties;
std::list<AppliedClassProperty> propertyValues;
public:
// Returns the ID of the most recent
ClassID mostRecent() const;
void add(ClassID class_id, TimePoint begin, TimePoint end, const PropertyValue &value);
bool hasTransitions() const;
void cleanup(TimePoint now);
bool hasTransitions() const;
bool empty() const;
};

View File

@@ -140,7 +140,7 @@ void StyleLayer::applyStyleProperty(PropertyKey key, T &target, const float z, c
AppliedClassProperties &applied = it->second;
// Iterate through all properties that we need to apply in order.
const PropertyEvaluator<T> evaluator(z, zoomHistory);
for (auto& property : applied.properties) {
for (auto& property : applied.propertyValues) {
if (now >= property.begin) {
// We overwrite the current property with the new value.
target = mapbox::util::apply_visitor(evaluator, property.value);
@@ -158,7 +158,7 @@ void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, cons
AppliedClassProperties &applied = it->second;
// Iterate through all properties that we need to apply in order.
const PropertyEvaluator<T> evaluator(z, zoomHistory);
for (auto& property : applied.properties) {
for (auto& property : applied.propertyValues) {
if (now >= property.end) {
// We overwrite the current property with the new value.
target = mapbox::util::apply_visitor(evaluator, property.value);
@@ -271,7 +271,6 @@ bool StyleLayer::hasTransitions() const {
return false;
}
void StyleLayer::cleanupAppliedStyleProperties(TimePoint now) {
for (auto it = appliedStyle.begin(); it != appliedStyle.end();) {
AppliedClassProperties& appliedPropertyValues = it->second;