[core] Return source and layer ownership (#7014)

When a source or layer is removed transfer ownership back to the
caller so it can (optionally) take it. Preserve the behavior that 
removing a CustomLayer triggers deinitialization.  Deinitialize all 
custom layers when a style is destroyed in case those layers are not 
explicitly removed.
This commit is contained in:
Jesse Bounds
2016-11-11 14:40:04 -08:00
parent 82fcd58121
commit 96a7a4402e
6 changed files with 43 additions and 17 deletions

View File

@@ -159,12 +159,12 @@ public:
// Sources
style::Source* getSource(const std::string& sourceID);
void addSource(std::unique_ptr<style::Source>);
void removeSource(const std::string& sourceID);
std::unique_ptr<style::Source> removeSource(const std::string& sourceID);
// Layers
style::Layer* getLayer(const std::string& layerID);
void addLayer(std::unique_ptr<style::Layer>, const optional<std::string>& beforeLayerID = {});
void removeLayer(const std::string& layerID);
std::unique_ptr<style::Layer> removeLayer(const std::string& layerID);
// Add image, bound to the style
void addImage(const std::string&, std::unique_ptr<const SpriteImage>);