#ifndef OSRM_ENGINE_DATAFACADE_PROVIDER_HPP #define OSRM_ENGINE_DATAFACADE_PROVIDER_HPP #include "engine/data_watchdog.hpp" #include "engine/datafacade.hpp" #include "engine/datafacade/contiguous_internalmem_datafacade.hpp" #include "engine/datafacade/mmap_memory_allocator.hpp" #include "engine/datafacade/process_memory_allocator.hpp" #include "engine/datafacade_factory.hpp" namespace osrm { namespace engine { namespace detail { template class FacadeT> class DataFacadeProvider { public: using Facade = FacadeT; virtual ~DataFacadeProvider() = default; virtual std::shared_ptr Get(const api::BaseParameters &) const = 0; virtual std::shared_ptr Get(const api::TileParameters &) const = 0; }; template class FacadeT> class ExternalProvider final : public DataFacadeProvider { public: using Facade = typename DataFacadeProvider::Facade; ExternalProvider(const storage::StorageConfig &config) : facade_factory(std::make_shared(config)) { } std::shared_ptr Get(const api::TileParameters ¶ms) const override final { return facade_factory.Get(params); } std::shared_ptr Get(const api::BaseParameters ¶ms) const override final { return facade_factory.Get(params); } private: DataFacadeFactory facade_factory; }; template class FacadeT> class ImmutableProvider final : public DataFacadeProvider { public: using Facade = typename DataFacadeProvider::Facade; ImmutableProvider(const storage::StorageConfig &config) : facade_factory(std::make_shared(config)) { } std::shared_ptr Get(const api::TileParameters ¶ms) const override final { return facade_factory.Get(params); } std::shared_ptr Get(const api::BaseParameters ¶ms) const override final { return facade_factory.Get(params); } private: DataFacadeFactory facade_factory; }; template class FacadeT> class WatchingProvider : public DataFacadeProvider { DataWatchdog watchdog; public: using Facade = typename DataFacadeProvider::Facade; WatchingProvider(const std::string &dataset_name) : watchdog(dataset_name) {} std::shared_ptr Get(const api::TileParameters ¶ms) const override final { return watchdog.Get(params); } std::shared_ptr Get(const api::BaseParameters ¶ms) const override final { return watchdog.Get(params); } }; } template using DataFacadeProvider = detail::DataFacadeProvider; template using WatchingProvider = detail::WatchingProvider; template using ImmutableProvider = detail::ImmutableProvider; template using ExternalProvider = detail::ExternalProvider; } } #endif