Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Layer type evaluators - #9064

Closed
ivovandongen wants to merge 3 commits into
masterfrom
8758-layer-type-evaluators
Closed

ivovandongen wants to merge 3 commits into
masterfrom
8758-layer-type-evaluators

Conversation

@ivovandongen

Copy link
Copy Markdown
Contributor

Fixes #8758

@ivovandongen ivovandongen added the Android Mapbox Maps SDK for Android label May 21, 2017
@ivovandongen ivovandongen self-assigned this May 21, 2017
@ivovandongen
ivovandongen requested a review from tobrun May 21, 2017 17:36
@ivovandongen
ivovandongen force-pushed the 8758-layer-type-evaluators branch from 9c03448 to a7b5317 Compare May 22, 2017 09:22
@ivovandongen
ivovandongen requested a review from kkaefer May 22, 2017 09:23
@ivovandongen

Copy link
Copy Markdown
Contributor Author

@kkaefer Do the changes to Layer::accept pose any risks?

@ivovandongen
ivovandongen force-pushed the 8758-layer-type-evaluators branch from a7b5317 to f94fc38 Compare May 22, 2017 09:38
Layer* operator()(style::LineLayer&) && { return new LineLayer(map, cast<style::LineLayer>()); }
Layer* operator()(style::RasterLayer&) && { return new RasterLayer(map, cast<style::RasterLayer>()); }
Layer* operator()(style::SymbolLayer&) && { return new SymbolLayer(map, cast<style::SymbolLayer>()); }
Layer* operator()(style::CustomLayer&) && { return new CustomLayer(map, cast<style::CustomLayer>()); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a template function?

@ivovandongen ivovandongen May 22, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kkaefer I was hoping the same, but don't quite know how. The classes involved are not the same type, but named the same, eg mbgl::style::LineLayer and mbgl::android::LineLayer. Where the latter is a Peer class wrapping the former.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be done by adding a typedef member to the mbgl::android::LineLayer with a shared name (e.g. using LayerType = style::LineLayer in mbgl::android::LineLayer, then using a function like

template <class PeerType>
Layer* operator(typename PeerType::LayerType&) && {
    return new PeerType(map, cast<typename PeerType::LayerType>());
}

Layer* operator()(style::LineLayer& layer) { return new LineLayer(map, layer); }
Layer* operator()(style::RasterLayer& layer) { return new RasterLayer(map, layer); }
Layer* operator()(style::SymbolLayer& layer) { return new SymbolLayer(map, layer); }
Layer* operator()(style::CustomLayer& layer) { return new CustomLayer(map, layer); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a template function?

@ivovandongen

Copy link
Copy Markdown
Contributor Author

Closing as this PR won't trigger CI. Replaced by #9069

@ivovandongen
ivovandongen deleted the 8758-layer-type-evaluators branch May 23, 2017 07:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Android Mapbox Maps SDK for Android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants