summaryrefslogtreecommitdiff
path: root/include/mbgl/sourcemanager
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/sourcemanager')
-rw-r--r--include/mbgl/sourcemanager/annotation_source_factory.hpp16
-rw-r--r--include/mbgl/sourcemanager/custom_geometry_source_factory.hpp16
-rw-r--r--include/mbgl/sourcemanager/geojson_source_factory.hpp16
-rw-r--r--include/mbgl/sourcemanager/image_source_factory.hpp16
-rw-r--r--include/mbgl/sourcemanager/raster_dem_source_factory.hpp16
-rw-r--r--include/mbgl/sourcemanager/raster_source_factory.hpp16
-rw-r--r--include/mbgl/sourcemanager/source_factory.hpp37
-rw-r--r--include/mbgl/sourcemanager/source_manager.hpp49
-rw-r--r--include/mbgl/sourcemanager/vector_source_factory.hpp16
9 files changed, 198 insertions, 0 deletions
diff --git a/include/mbgl/sourcemanager/annotation_source_factory.hpp b/include/mbgl/sourcemanager/annotation_source_factory.hpp
new file mode 100644
index 0000000000..0ea98bab99
--- /dev/null
+++ b/include/mbgl/sourcemanager/annotation_source_factory.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <mbgl/sourcemanager/source_factory.hpp>
+
+namespace mbgl {
+
+class AnnotationSourceFactory : public SourceFactory {
+protected:
+ const style::SourceTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept final;
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept final;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/custom_geometry_source_factory.hpp b/include/mbgl/sourcemanager/custom_geometry_source_factory.hpp
new file mode 100644
index 0000000000..12d8234182
--- /dev/null
+++ b/include/mbgl/sourcemanager/custom_geometry_source_factory.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <mbgl/sourcemanager/source_factory.hpp>
+
+namespace mbgl {
+
+class CustomGeometrySourceFactory : public SourceFactory {
+protected:
+ const style::SourceTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept final;
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept final;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/geojson_source_factory.hpp b/include/mbgl/sourcemanager/geojson_source_factory.hpp
new file mode 100644
index 0000000000..be6e64a6bc
--- /dev/null
+++ b/include/mbgl/sourcemanager/geojson_source_factory.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <mbgl/sourcemanager/source_factory.hpp>
+
+namespace mbgl {
+
+class GeoJSONSourceFactory : public SourceFactory {
+protected:
+ const style::SourceTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept final;
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept final;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/image_source_factory.hpp b/include/mbgl/sourcemanager/image_source_factory.hpp
new file mode 100644
index 0000000000..c560cb112d
--- /dev/null
+++ b/include/mbgl/sourcemanager/image_source_factory.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <mbgl/sourcemanager/source_factory.hpp>
+
+namespace mbgl {
+
+class ImageSourceFactory : public SourceFactory {
+protected:
+ const style::SourceTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept final;
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept final;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/raster_dem_source_factory.hpp b/include/mbgl/sourcemanager/raster_dem_source_factory.hpp
new file mode 100644
index 0000000000..a01b26eb0d
--- /dev/null
+++ b/include/mbgl/sourcemanager/raster_dem_source_factory.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <mbgl/sourcemanager/source_factory.hpp>
+
+namespace mbgl {
+
+class RasterDEMSourceFactory : public SourceFactory {
+protected:
+ const style::SourceTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept final;
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept final;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/raster_source_factory.hpp b/include/mbgl/sourcemanager/raster_source_factory.hpp
new file mode 100644
index 0000000000..d5f88e65d9
--- /dev/null
+++ b/include/mbgl/sourcemanager/raster_source_factory.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <mbgl/sourcemanager/source_factory.hpp>
+
+namespace mbgl {
+
+class RasterSourceFactory : public SourceFactory {
+protected:
+ const style::SourceTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept final;
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept final;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/source_factory.hpp b/include/mbgl/sourcemanager/source_factory.hpp
new file mode 100644
index 0000000000..31d392163b
--- /dev/null
+++ b/include/mbgl/sourcemanager/source_factory.hpp
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <mbgl/style/source.hpp>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+class Convertible;
+struct Error;
+} // namespace conversion
+} // namespace style
+
+class RenderSource;
+
+/**
+ * @brief The SourceFactory abstract class
+ *
+ * This class is responsible for creation of the source objects that belong to a concrete source type.
+ */
+class SourceFactory {
+public:
+ virtual ~SourceFactory() = default;
+
+ /// Returns the source type data.
+ virtual const style::SourceTypeInfo* getTypeInfo() const noexcept = 0;
+
+ /// Returns a new Source instance on success call; returns `nullptr` otherwise with Error updated
+ /// accordingly.
+ virtual std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept = 0;
+
+ /// Returns a new RenderSource instance.
+ virtual std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept = 0;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/source_manager.hpp b/include/mbgl/sourcemanager/source_manager.hpp
new file mode 100644
index 0000000000..4e4dea06ff
--- /dev/null
+++ b/include/mbgl/sourcemanager/source_manager.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+#include <mbgl/style/source.hpp>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+class Convertible;
+struct Error;
+} // namespace conversion
+} // namespace style
+
+class SourceFactory;
+class RenderSource;
+
+/**
+ * @brief A singleton class responsible for creating source instances.
+ *
+ * The SourceManager has implementation per platform. The SourceManager implementation
+ * defines what source types are available.
+ *
+ * Linker excludes the unreachable code for the disabled sources from the binaries,
+ * significantly reducing their size.
+ */
+class SourceManager {
+public:
+ /**
+ * @brief A singleton getter.
+ *
+ * @return SourceManager*
+ */
+ static SourceManager* get() noexcept;
+
+ /// Returns a new Source instance on success call; returns `nullptr` otherwise.
+ std::unique_ptr<style::Source> createSource(const std::string& type,
+ const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error& error) noexcept;
+
+ /// Returns a new RenderSource instance on success call; returns `nullptr` otherwise.
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept;
+
+protected:
+ virtual ~SourceManager() = default;
+ virtual SourceFactory* getFactory(const std::string& type) noexcept = 0;
+ virtual SourceFactory* getFactory(const style::SourceTypeInfo*) noexcept = 0;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/sourcemanager/vector_source_factory.hpp b/include/mbgl/sourcemanager/vector_source_factory.hpp
new file mode 100644
index 0000000000..05cae49af9
--- /dev/null
+++ b/include/mbgl/sourcemanager/vector_source_factory.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <mbgl/sourcemanager/source_factory.hpp>
+
+namespace mbgl {
+
+class VectorSourceFactory : public SourceFactory {
+protected:
+ const style::SourceTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Source> createSource(const std::string& id,
+ const style::conversion::Convertible& value,
+ style::conversion::Error&) noexcept final;
+ std::unique_ptr<RenderSource> createRenderSource(Immutable<style::Source::Impl>) noexcept final;
+};
+
+} // namespace mbgl