[core, darwin] Object identity for MGLSource*, MGLStyleLayer*

All `MGLSource` pointers referencing the same logical source will now be object identical; similarly for `MGLStyleLayer`.
This commit is contained in:
John Firebaugh
2017-04-04 11:33:22 -07:00
parent de6c9b35f3
commit 7b041b123c
12 changed files with 66 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/any.hpp>
#include <mbgl/style/types.hpp>
#include <memory>
@@ -118,6 +119,11 @@ public:
// Private implementation
const std::unique_ptr<Impl> baseImpl;
// For use in SDK bindings, which store a reference to a platform-native peer
// object here, so that separately-obtained references to this object share
// identical platform-native peers.
any peer;
friend std::string layoutKey(const Layer&);
};

View File

@@ -4,6 +4,7 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/range.hpp>
#include <mbgl/util/any.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/style/query.hpp>
@@ -64,6 +65,11 @@ public:
class Impl;
const std::unique_ptr<Impl> baseImpl;
// For use in SDK bindings, which store a reference to a platform-native peer
// object here, so that separately-obtained references to this object share
// identical platform-native peers.
any peer;
protected:
const SourceType type;
Source(SourceType, std::unique_ptr<Impl>);

10
include/mbgl/util/any.hpp Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
#include <linb/any.hpp>
namespace mbgl {
using linb::any;
using linb::any_cast;
} // namespace mbgl