diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2020-04-29 12:28:50 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2020-05-26 20:35:03 +0300 |
commit | 57972231e864cf4af18f12664dbb4a838e9e99db (patch) | |
tree | 7d39fcbfe12ad7c6b3355acd444d1413960d3a70 /src/mbgl/sourcemanager/source_manager.cpp | |
parent | 1d892b1feef4a4d15711d4596f36e6f558afae26 (diff) | |
download | qtlocation-mapboxgl-57972231e864cf4af18f12664dbb4a838e9e99db.tar.gz |
source manager and factories
Diffstat (limited to 'src/mbgl/sourcemanager/source_manager.cpp')
-rw-r--r-- | src/mbgl/sourcemanager/source_manager.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mbgl/sourcemanager/source_manager.cpp b/src/mbgl/sourcemanager/source_manager.cpp new file mode 100644 index 0000000000..742cedef2d --- /dev/null +++ b/src/mbgl/sourcemanager/source_manager.cpp @@ -0,0 +1,30 @@ +#include <mbgl/renderer/render_source.hpp> +#include <mbgl/sourcemanager/source_factory.hpp> +#include <mbgl/sourcemanager/source_manager.hpp> +#include <mbgl/style/conversion_impl.hpp> +#include <mbgl/style/source.hpp> +#include <mbgl/style/source_impl.hpp> + +namespace mbgl { + +std::unique_ptr<style::Source> SourceManager::createSource(const std::string& type, + const std::string& id, + const style::conversion::Convertible& value, + style::conversion::Error& error) noexcept { + SourceFactory* factory = getFactory(type); + if (factory) { + return factory->createSource(id, value, error); + } else { + error.message = "Null factory for type: " + type; + } + error.message = "Unsupported source type! " + error.message; + return nullptr; +} + +std::unique_ptr<RenderSource> SourceManager::createRenderSource(Immutable<style::Source::Impl> impl) noexcept { + SourceFactory* factory = getFactory(impl->getTypeInfo()); + assert(factory); + return factory->createRenderSource(std::move(impl)); +} + +} // namespace mbgl |