MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
file_source_manager.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace mbgl {
6 
7 class ClientOptions;
8 class ResourceOptions;
9 
20 public:
21  using FileSourceFactory = std::function<std::unique_ptr<FileSource>(const ResourceOptions&, const ClientOptions&)>;
22 
28  static FileSourceManager* get() noexcept;
29 
30  // Returns shared instance of a file source for (type, options) tuple.
31  // Creates new instance via registered factory if needed. If new instance cannot be
32  // created, nullptr would be returned.
33  [[nodiscard]] std::shared_ptr<FileSource> getFileSource(FileSourceType, const ResourceOptions&, const ClientOptions& = ClientOptions()) noexcept;
34 
35  // Registers file source factory for a provided FileSourceType type. If factory for the
36  // same type was already registered, will unregister previously registered factory.
37  // Provided factory must not be null.
39 
40  // Unregisters file source factory. If there are no registered factories for a FileSourceType
41  // invocation has no effect.
43 
44 protected:
46  class Impl;
47  std::unique_ptr<Impl> impl;
48  virtual ~FileSourceManager();
49 };
50 
51 } // namespace mbgl
Holds values for client options.
A singleton class responsible for managing file sources.
virtual FileSourceFactory unRegisterFileSourceFactory(FileSourceType) noexcept
virtual void registerFileSourceFactory(FileSourceType, FileSourceFactory &&) noexcept
std::shared_ptr< FileSource > getFileSource(FileSourceType, const ResourceOptions &, const ClientOptions &=ClientOptions()) noexcept
static FileSourceManager * get() noexcept
A singleton getter.
std::function< std::unique_ptr< FileSource >(const ResourceOptions &, const ClientOptions &)> FileSourceFactory
std::unique_ptr< Impl > impl
Holds values for resource options.
Definition: actor.hpp:15
FileSourceType
Definition: file_source.hpp:19
Definition: tile_id.hpp:256