This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bring back const-ness of abstract GeometryTileLayer
- Loading branch information
Showing
6 changed files
with
7 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fbd5511
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love an eyeball on this @jfirebaugh when you have a moment. Because I am wanting to mutate
LiveTileLayer
(the whole point of the class), but we want to default to returningconst GeometryTileLayer
ingetLayer()
, I'm doing some pointer casting.fbd5511
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, these pointer casts are a code smell. What you want here is a covariant return type for
getLayer
, where the abstract base is declared as returningGeometryTileLayer
pointers, butLiveTile
is declared as returning aLiveTileLayer
pointer. C++ doesn't have a way to do this with smart pointers though. Your best bet is to define a separate getter that returns the desired type. See http://stackoverflow.com/questions/196733/how-can-i-use-covariant-return-types-with-smart-pointersWith regards to
const
ness,GeometryTileLayer
's interface is const, so it might make sense to go with autil::ptr<GeometryTileLayer>
return type for simplicity's sake. The thingconst
does is remind you to think about thread safety if you cast it away. Which thread is writingLiveTileLayer
s and which thread(s) are reading them?fbd5511
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, felt like it. Thanks for the pointers (heh); I will shore this up.
I am game for this approach right now. When we get into possible shape annotation style geometry mutation in future, will give it a re-think.