diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-15 15:47:25 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-15 17:48:36 +0200 |
commit | ff09c94d0825f5dbe7dddce52b64e74d61978976 (patch) | |
tree | 86833d95d8bf7abbcb8e6965aaba65d666ffff52 /include/mbgl/style/layer.hpp | |
parent | 73dcfe2d0d3475ad9584969c7908ba681a3f5bfa (diff) | |
download | qtlocation-mapboxgl-ff09c94d0825f5dbe7dddce52b64e74d61978976.tar.gz |
[core][android] Introduce mbgl::style::LayerTypeInfoupstream/mikhail_LayerTypeInfo
The `LayerTypeInfo` contains static meta data about certain layer type.
Each layer module should have a single immutable `LayerTypeInfo` instance
for the represented layer type. Both `LayerImpl` and `LayerFactory` from the
module always refer to the same `LayerTypeInfo` instance, so address of this
instance can be used as a layer module Id during the process life time.
Diffstat (limited to 'include/mbgl/style/layer.hpp')
-rw-r--r-- | include/mbgl/style/layer.hpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 1e1e97dd0d..21ed3adbce 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -19,6 +19,21 @@ class LayerObserver; class Filter; /** + * @brief Holds static data for a certain layer type. + */ +struct LayerTypeInfo { + /** + * @brief contains the layer type as defined in the style specification; + */ + const char* type; + /** + * @brief contains \c SourceRequired if the corresponding layer type requires source; + * contains \c SourceNotRequired otherwise. + */ + const enum { SourceRequired, SourceNotRequired } source; +}; + +/** * The runtime representation of a [layer](https://www.mapbox.com/mapbox-gl-style-spec/#layers) from the Mapbox Style * Specification. * @@ -83,12 +98,16 @@ public: // identical platform-native peers. util::peer peer; Layer(Immutable<Impl>); + + const LayerTypeInfo* getTypeInfo() const noexcept; + protected: virtual Mutable<Impl> mutableBaseImpl() const = 0; LayerObserver* observer; }; + /** * @brief The LayerFactory abstract class * @@ -97,8 +116,8 @@ protected: class LayerFactory { public: virtual ~LayerFactory() = default; - /// Returns \c true if this factory can produce layers of the given type of the layers; returns \c false otherwise. - virtual bool supportsType(const std::string& type) const noexcept = 0; + /// Returns the layer type data. + virtual const LayerTypeInfo* getTypeInfo() const noexcept = 0; /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. virtual std::unique_ptr<Layer> createLayer(const std::string& id, const conversion::Convertible& value) = 0; |