summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/map/map.hpp6
-rw-r--r--include/mbgl/map/map_options.hpp46
-rw-r--r--include/mbgl/platform/factory.hpp21
-rw-r--r--include/mbgl/renderer/renderer.hpp5
-rw-r--r--include/mbgl/storage/file_source_options.hpp89
-rw-r--r--include/mbgl/style/source.hpp2
-rw-r--r--include/mbgl/style/sources/custom_geometry_source.hpp3
-rw-r--r--include/mbgl/style/sources/geojson_source.hpp5
-rw-r--r--include/mbgl/style/sources/image_source.hpp5
-rw-r--r--include/mbgl/style/sources/raster_source.hpp3
-rw-r--r--include/mbgl/style/sources/vector_source.hpp3
-rw-r--r--include/mbgl/style/style.hpp4
12 files changed, 133 insertions, 59 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 56aaffbcb7..ea76240d74 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -11,6 +11,7 @@
#include <mbgl/map/camera.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/map/projection_mode.hpp>
+#include <mbgl/storage/file_source_options.hpp>
#include <cstdint>
#include <string>
@@ -20,7 +21,6 @@
namespace mbgl {
-class FileSource;
class RendererFrontend;
namespace style {
@@ -34,8 +34,8 @@ public:
MapObserver&,
Size size,
float pixelRatio,
- FileSource&,
- const MapOptions&);
+ const MapOptions&,
+ const FileSourceOptions&);
~Map();
// Register a callback that will get called (on the render thread) when all resources have
diff --git a/include/mbgl/map/map_options.hpp b/include/mbgl/map/map_options.hpp
index 1a72837c4c..a7507a8a2d 100644
--- a/include/mbgl/map/map_options.hpp
+++ b/include/mbgl/map/map_options.hpp
@@ -52,52 +52,6 @@ public:
ViewportMode viewportMode() const;
/**
- * @brief Sets the cache path.
- *
- * @param path Cache path.
- * @return reference to MapOptions for chaining options together.
- */
- MapOptions& withCachePath(std::string path);
-
- /**
- * @brief Gets the previously set (or default) cache path.
- *
- * @return cache path
- */
- const std::string& cachePath() const;
-
- /**
- * @brief Sets the asset path, which is the root directory from where
- * the asset:// scheme gets resolved in a style.
- *
- * @param path Asset path.
- * @return reference to MapOptions for chaining options together.
- */
- MapOptions& withAssetRoot(std::string path);
-
- /**
- * @brief Gets the previously set (or default) asset path.
- *
- * @return asset path
- */
- const std::string& assetRoot() const;
-
- /**
- * @brief Sets the maximum cache size.
- *
- * @param size Cache maximum size in bytes.
- * @return reference to MapOptions for chaining options together.
- */
- MapOptions& withMaximumCacheSize(uint64_t size);
-
- /**
- * @brief Gets the previously set (or default) maximum allowed cache size.
- *
- * @return maximum allowed cache database size in bytes.
- */
- uint64_t maximumCacheSize() const;
-
- /**
* @brief Specify whether to enable cross-source symbol collision detection
* or not. By default, it is set to true.
*
diff --git a/include/mbgl/platform/factory.hpp b/include/mbgl/platform/factory.hpp
new file mode 100644
index 0000000000..c4b6dcfce6
--- /dev/null
+++ b/include/mbgl/platform/factory.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <mbgl/storage/file_source_options.hpp>
+
+#include <memory>
+
+namespace mbgl {
+
+class FileSource;
+
+namespace platform {
+
+class Factory {
+public:
+ // This is also a singleton: it stores a weak reference to the managed object once it has been created upon first
+ // call of this function. It allows the initial value to be overriden.
+ static std::shared_ptr<FileSource> sharedFileSource(const FileSourceOptions& options = {}, std::shared_ptr<FileSource> initial = {});
+};
+
+} // namespace platform
+} // namespace mbgl
diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp
index d75d8363a6..0eb449d3d6 100644
--- a/include/mbgl/renderer/renderer.hpp
+++ b/include/mbgl/renderer/renderer.hpp
@@ -13,7 +13,7 @@
namespace mbgl {
-class FileSource;
+class FileSourceOptions;
class RendererBackend;
class RendererObserver;
class RenderedQueryOptions;
@@ -22,7 +22,8 @@ class UpdateParameters;
class Renderer {
public:
- Renderer(RendererBackend&, float pixelRatio_, FileSource&,
+ Renderer(RendererBackend&, float pixelRatio_,
+ const FileSourceOptions&,
GLContextMode = GLContextMode::Unique,
const optional<std::string> programCacheDir = {},
const optional<std::string> localFontFamily = {});
diff --git a/include/mbgl/storage/file_source_options.hpp b/include/mbgl/storage/file_source_options.hpp
new file mode 100644
index 0000000000..6e9d8d6081
--- /dev/null
+++ b/include/mbgl/storage/file_source_options.hpp
@@ -0,0 +1,89 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+namespace mbgl {
+
+/**
+ * @brief Holds values for FileSource options.
+ */
+
+class FileSourceOptions {
+public:
+ /**
+ * @brief Constructs a FileSourceOptions object with default values.
+ */
+ FileSourceOptions();
+ ~FileSourceOptions();
+
+ /**
+ * @brief Sets the Mapbox API access token.
+ * Details: https://docs.mapbox.com/help/glossary/access-token/
+ *
+ * @param accessToken Mapbox API access token, as string.
+ * @return reference to FileSourceOptions for chaining options together.
+ */
+ FileSourceOptions& withAccessToken(std::string accessToken);
+
+ /**
+ * @brief Gets the previously set Mapbox API access token.
+ * Details: https://docs.mapbox.com/help/glossary/access-token/
+ *
+ * @return Mapbox API access token, as string.
+ */
+ const std::string& accessToken() const;
+
+ /**
+ * @brief Sets the cache path.
+ *
+ * @param path Cache path.
+ * @return reference to FileSourceOptions for chaining options together.
+ */
+ FileSourceOptions& withCachePath(std::string path);
+
+ /**
+ * @brief Gets the previously set (or default) cache path.
+ *
+ * @return cache path
+ */
+ const std::string& cachePath() const;
+
+ /**
+ * @brief Sets the asset path, which is the root directory from where
+ * the asset:// scheme gets resolved in a style.
+ *
+ * @param path Asset path.
+ * @return reference to FileSourceOptions for chaining options together.
+ */
+ FileSourceOptions& withAssetRoot(std::string path);
+
+ /**
+ * @brief Gets the previously set (or default) asset path.
+ *
+ * @return asset path
+ */
+ const std::string& assetRoot() const;
+
+ /**
+ * @brief Sets the maximum cache size.
+ *
+ * @param size Cache maximum size in bytes.
+ * @return reference to FileSourceOptions for chaining options together.
+ */
+ FileSourceOptions& withMaximumCacheSize(uint64_t size);
+
+ /**
+ * @brief Gets the previously set (or default) maximum allowed cache size.
+ *
+ * @return maximum allowed cache database size in bytes.
+ */
+ uint64_t maximumCacheSize() const;
+
+private:
+ class Impl;
+ std::shared_ptr<Impl> impl_;
+};
+
+} // namespace mbgl \ No newline at end of file
diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp
index dc3a8d73fb..9f9443701f 100644
--- a/include/mbgl/style/source.hpp
+++ b/include/mbgl/style/source.hpp
@@ -69,7 +69,7 @@ public:
void setObserver(SourceObserver*);
SourceObserver* observer = nullptr;
- virtual void loadDescription(FileSource&) = 0;
+ virtual void loadDescription(std::shared_ptr<FileSource>) = 0;
void dumpDebugLogs() const;
bool loaded = false;
diff --git a/include/mbgl/style/sources/custom_geometry_source.hpp b/include/mbgl/style/sources/custom_geometry_source.hpp
index 9daeeb3819..183c45f79b 100644
--- a/include/mbgl/style/sources/custom_geometry_source.hpp
+++ b/include/mbgl/style/sources/custom_geometry_source.hpp
@@ -12,6 +12,7 @@ class OverscaledTileID;
class CanonicalTileID;
template <class T>
class Actor;
+class FileSource;
namespace style {
@@ -38,7 +39,7 @@ public:
public:
CustomGeometrySource(std::string id, CustomGeometrySource::Options options);
~CustomGeometrySource() final;
- void loadDescription(FileSource&) final;
+ void loadDescription(std::shared_ptr<FileSource>) final;
void setTileData(const CanonicalTileID&, const GeoJSON&);
void invalidateTile(const CanonicalTileID&);
void invalidateRegion(const LatLngBounds&);
diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp
index a03b910279..732b8cac75 100644
--- a/include/mbgl/style/sources/geojson_source.hpp
+++ b/include/mbgl/style/sources/geojson_source.hpp
@@ -5,9 +5,12 @@
#include <mbgl/util/optional.hpp>
#include <mbgl/util/constants.hpp>
+#include <memory>
+
namespace mbgl {
class AsyncRequest;
+class FileSource;
namespace style {
@@ -39,7 +42,7 @@ public:
class Impl;
const Impl& impl() const;
- void loadDescription(FileSource&) final;
+ void loadDescription(std::shared_ptr<FileSource>) final;
private:
optional<std::string> url;
diff --git a/include/mbgl/style/sources/image_source.hpp b/include/mbgl/style/sources/image_source.hpp
index 009764291f..2f3323a5b9 100644
--- a/include/mbgl/style/sources/image_source.hpp
+++ b/include/mbgl/style/sources/image_source.hpp
@@ -4,9 +4,12 @@
#include <mbgl/util/image.hpp>
#include <mbgl/util/optional.hpp>
+#include <memory>
+
namespace mbgl {
class LatLng;
class AsyncRequest;
+class FileSource;
namespace style {
@@ -26,7 +29,7 @@ public:
class Impl;
const Impl& impl() const;
- void loadDescription(FileSource&) final;
+ void loadDescription(std::shared_ptr<FileSource>) final;
private:
optional<std::string> url;
std::unique_ptr<AsyncRequest> req;
diff --git a/include/mbgl/style/sources/raster_source.hpp b/include/mbgl/style/sources/raster_source.hpp
index 5aa81aa979..7c6c2a52c1 100644
--- a/include/mbgl/style/sources/raster_source.hpp
+++ b/include/mbgl/style/sources/raster_source.hpp
@@ -7,6 +7,7 @@
namespace mbgl {
class AsyncRequest;
+class FileSource;
namespace style {
@@ -23,7 +24,7 @@ public:
class Impl;
const Impl& impl() const;
- void loadDescription(FileSource&) final;
+ void loadDescription(std::shared_ptr<FileSource>) final;
private:
const variant<std::string, Tileset> urlOrTileset;
diff --git a/include/mbgl/style/sources/vector_source.hpp b/include/mbgl/style/sources/vector_source.hpp
index 6f16974b40..e72244c361 100644
--- a/include/mbgl/style/sources/vector_source.hpp
+++ b/include/mbgl/style/sources/vector_source.hpp
@@ -7,6 +7,7 @@
namespace mbgl {
class AsyncRequest;
+class FileSource;
namespace style {
@@ -21,7 +22,7 @@ public:
class Impl;
const Impl& impl() const;
- void loadDescription(FileSource&) final;
+ void loadDescription(std::shared_ptr<FileSource>) final;
private:
const variant<std::string, Tileset> urlOrTileset;
diff --git a/include/mbgl/style/style.hpp b/include/mbgl/style/style.hpp
index 4a6a542b88..5568a1e33d 100644
--- a/include/mbgl/style/style.hpp
+++ b/include/mbgl/style/style.hpp
@@ -10,7 +10,7 @@
namespace mbgl {
-class FileSource;
+class FileSourceOptions;
namespace style {
@@ -21,7 +21,7 @@ class Layer;
class Style {
public:
- Style(FileSource&, float pixelRatio);
+ Style(float pixelRatio, const FileSourceOptions&);
~Style();
void loadJSON(const std::string&);