Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Tangram::Map implementation private #844

Merged
merged 1 commit into from
Jul 21, 2016
Merged

Conversation

matteblair
Copy link
Member

@matteblair matteblair commented Jul 19, 2016

Instead of holding all of our subsystem objects directly in the Map class, Map now holds a unique_ptr to an object of the private class Map::Impl and all of the subsystem objects are members of Map::Impl.

This significantly reduces the declarations needed in tangram.h and in the future will allow us to change the implementation of Map without changing this header.

@karimnaaji
Copy link
Member

Could we clear tiles for all map instance when triggering a debug flag that requests tile reloading?

@matteblair
Copy link
Member Author

Maybe! We'd have to register all map instances to a global variable somewhere, which seemed undesirable.

I had a weird idea on fixing this: getDebugFlag() should remain a global because it means we can use these test conditions from anywhere in the code, and that's really useful. But setDebugFlag() could be a non-static function in Map so that we have access to the tile sets whenever we set a flag that needs to refresh them. It's weirdly asymmetrical, but kinda fits our needs.

@tallytalwar
Copy link
Member

Reviewing this now.

std::array<Ease, 4> m_eases;
bool m_cacheGlState;
class Impl;
std::unique_ptr<Impl> impl;
Copy link
Member

Choose a reason for hiding this comment

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

Just a note here that Map::Impl class has its move constructor suppressed, unless explicitly defined/defaulted. This might have an affect if the user of the Map class tries to move an instance.
Reference: http://en.cppreference.com/w/cpp/language/pimpl

Copy link
Member

Choose a reason for hiding this comment

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

On similar note, should we restrict copying of a Map object by explicitly deleting copy constructor? RFC!

Copy link
Member Author

Choose a reason for hiding this comment

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

Map is implicitly non-copyable - the compiler can't generate a copy constructor because of the unique_ptr

Supporting move semantics for Map would be trivial, I don't know if there's a serious need for it though.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I also do not see a serious need or use case for a move for Map. Wanted to bring this out, just in case, someone has a use case in mind.

@tallytalwar
Copy link
Member

This looks good to me. If no one has further comments will merge (squash, to save one merge commit) this.

@matteblair
Copy link
Member Author

Thanks! Yeah, squash makes sense to me.

@tallytalwar tallytalwar merged commit 1009af7 into master Jul 21, 2016
@tallytalwar tallytalwar deleted the private-map-impl branch July 21, 2016 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants