summaryrefslogtreecommitdiff
path: root/include/mbgl/sourcemanager/source_manager.hpp
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2020-04-29 12:28:50 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2020-05-26 20:35:03 +0300
commit57972231e864cf4af18f12664dbb4a838e9e99db (patch)
tree7d39fcbfe12ad7c6b3355acd444d1413960d3a70 /include/mbgl/sourcemanager/source_manager.hpp
parent1d892b1feef4a4d15711d4596f36e6f558afae26 (diff)
downloadqtlocation-mapboxgl-57972231e864cf4af18f12664dbb4a838e9e99db.tar.gz
source manager and factories
Diffstat (limited to 'include/mbgl/sourcemanager/source_manager.hpp')
-rw-r--r--include/mbgl/sourcemanager/source_manager.hpp49
1 files changed, 49 insertions, 0 deletions
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