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

Pass source object in MapObserver::onSourceChanged - #8443

Merged
brunoabinader merged 4 commits into
masterfrom
mapobserver-onsourceattributionchanged
Mar 21, 2017
Merged

brunoabinader merged 4 commits into
masterfrom
mapobserver-onsourceattributionchanged

Conversation

@brunoabinader

Copy link
Copy Markdown
Contributor

Rename MapObserver::onSourceDidChange to MapObserver::onSourceAttributionChanged, passing both sourceID and attribution as strings.

Fixes #8397.

@brunoabinader brunoabinader added Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl macOS Mapbox Maps SDK for macOS Qt Mapbox Maps SDK for Qt, aka Qt Location Mapbox GL labels Mar 17, 2017
@brunoabinader brunoabinader self-assigned this Mar 17, 2017
@mention-bot

Copy link
Copy Markdown

@brunoabinader, thanks for your PR! By analyzing this pull request, we identified @1ec5, @jfirebaugh and @tmpsantos to be potential reviewers.

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The notification was intentionally generalized in #6465 so that it could be used in the future for any change to a source. Additionally, I think it would be better for the method to accept an mbgl::style::Source directly, from which the implementations could easily obtain the ID and attribution string.

/cc @jfirebaugh

@jfirebaugh

Copy link
Copy Markdown
Contributor

Agree with @1ec5, and we can generalize SourceObserver::onSourceAttributionChanged to SourceObserver::onSourceChanged() as well. Come to think of it, should we be exposing SourceObserver/StyleObserver directly, rather than partially exposing their APIs indirectly through MapObserver?

@brunoabinader

Copy link
Copy Markdown
Contributor Author

we can generalize SourceObserver::onSourceAttributionChanged to SourceObserver::onSourceChanged() as well.

This might sound confusing, as SourceObserver contains other notifications that can be also considered changes. Would then this new onSourceChanged be related to not only attribution, but also data changes?

Come to think of it, should we be exposing SourceObserver/StyleObserver directly, rather than partially exposing their APIs indirectly through MapObserver?

I'm okay with that - we could then be also exposing StyleObserver in case of onDidFinishLoadingStyle.

@brunoabinader

Copy link
Copy Markdown
Contributor Author

I think it would be better for the method to accept an mbgl::style::Source directly

I have concerns regarding data consistency if we forward the Source object to its listeners via pass-by-ref e.g. we're allowing listeners to make changes to the Source object while being notified of some other change. Thus why I decided to proceed with passing only the ID, which could then be used to obtain a pointer to the source via Map API.

If we proceed with passing the Source object, then I suggest we switch the paradigm to pass-by-const-ref.

@brunoabinader

brunoabinader commented Mar 20, 2017 •

Copy link
Copy Markdown
Contributor Author

I'm okay with that - we could then be also exposing StyleObserver in case of onDidFinishLoadingStyle.

Currently mbgl::style::Observer inherits from SourceObserver itself - so we could just end up exposing it as a combo.

@brunoabinader

Copy link
Copy Markdown
Contributor Author

Come to think of it, should we be exposing SourceObserver/StyleObserver directly, rather than partially exposing their APIs indirectly through MapObserver?

On a second thought, exposing StyleObserver involves exposing at least 4 other non-public headers, unless we reduce StyleObserver scope by removing GlyphAtlasObserver and SpriteAtlasObserver inheritances.

@brunoabinader
brunoabinader force-pushed the mapobserver-onsourceattributionchanged branch 2 times, most recently from fc56c6d to 79bdafa Compare March 20, 2017 15:09
@brunoabinader
brunoabinader force-pushed the mapobserver-onsourceattributionchanged branch from 79bdafa to c41d193 Compare March 20, 2017 15:35
@jfirebaugh

Copy link
Copy Markdown
Contributor

I have concerns regarding data consistency if we forward the Source object to its listeners via pass-by-ref e.g. we're allowing listeners to make changes to the Source object while being notified of some other change.

This is a possibility even if not passed as a reference or passed by const reference, right? The receiver could be holding a reference already, or could look up the source by ID.

@brunoabinader brunoabinader changed the title Pass sourceID, attribution in MapObserver::onSourceAttributionChanged Pass source object in MapObserver::onSourceChanged Mar 21, 2017
@brunoabinader
brunoabinader merged commit 2dbda72 into master Mar 21, 2017
@brunoabinader
brunoabinader deleted the mapobserver-onsourceattributionchanged branch March 21, 2017 15:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl macOS Mapbox Maps SDK for macOS Qt Mapbox Maps SDK for Qt, aka Qt Location Mapbox GL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants