MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vector_source.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/style/source.hpp>
4 #include <mbgl/util/tileset.hpp>
5 #include <mbgl/util/variant.hpp>
6 
7 namespace mbgl {
8 
9 class AsyncRequest;
10 
11 namespace style {
12 
13 class VectorSource final : public Source {
14 public:
15  VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset, std::optional<float> maxZoom = std::nullopt,
16  std::optional<float> minZoom = std::nullopt);
17  ~VectorSource() final;
18 
19  const variant<std::string, Tileset>& getURLOrTileset() const;
20  std::optional<std::string> getURL() const;
21 
22  class Impl;
23  const Impl& impl() const;
24 
26 
27  bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
28 
29  mapbox::base::WeakPtr<Source> makeWeakPtr() override {
30  return weakFactory.makeWeakPtr();
31  }
32 
33 protected:
34  Mutable<Source::Impl> createMutable() const noexcept final;
35 
36 private:
37  const variant<std::string, Tileset> urlOrTileset;
38  std::unique_ptr<AsyncRequest> req;
39  mapbox::base::WeakPtrFactory<Source> weakFactory {this};
40  std::optional<float> maxZoom;
41  std::optional<float> minZoom;
42 };
43 
44 template <>
45 inline bool Source::is<VectorSource>() const {
46  return getType() == SourceType::Vector;
47 }
48 
49 } // namespace style
50 } // namespace mbgl
VectorSource(std::string id, variant< std::string, Tileset > urlOrTileset, std::optional< float > maxZoom=std::nullopt, std::optional< float > minZoom=std::nullopt)
mapbox::base::WeakPtr< Source > makeWeakPtr() override
Mutable< Source::Impl > createMutable() const noexcept final
const Impl & impl() const
void loadDescription(FileSource &) final
bool supportsLayerType(const mbgl::style::LayerTypeInfo *) const override
const variant< std::string, Tileset > & getURLOrTileset() const
std::optional< std::string > getURL() const
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
Definition: actor.hpp:15
mapbox::util::variant< T... > variant
Definition: variant.hpp:17
Definition: tile_id.hpp:256