* [core] Introduce FileSourceManager and use it for default platform impl
- Add `FileSourceManager` interface that provides access to `FileSource`
instances and means of registering / unregistering `FileSource` factories
- Split `DefaultFileSource` into smaller parts
- Add `DatabaseFileSource` interface and it's default implementation
- Remove inter-dependencies between concrete `FileSource` classes
* [build] Add files to next build system
* [core] Add generic property setters / getters
* [core] Remove setOnlineStatus from OnlineFileSource interface
* [core] Hide threading implementation details from DatabaseFileSource interface
* [core] Make DB file source methods virtual
* [core] Add documentation for DatabaseFileSource and rename one method
* [core] Use simple callback instead of ActorRef
* [core] Remove ActorRef from OnlineFileSource public header
* [core] Add callback to FileSource::forward async API
* [core] Pass OfflineRegionDefinition by value
* [core] Update tests to use modular file sources
* [core] Update unit tests
* [core] Update unit tests after rebase
* [core] Backport low prio fix for cached requests
* [core] Backport pack database
* [core] Return removed factory from unRegisterFileSourceFactory
* [core] Rename shadowed args in onlinefilesource
* [core] Remove simple std::function callback aliases
* [core] Expose online file source property keys in public header file
* [test-runner] Add proxy file source test runner
* [cache] Update mbgl-cache utility to use new file source
* [metrics] Rebaseline binary size metrics
* [offline] Update offline utility
* [core] Update changelog
105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include <mbgl/storage/response.hpp>
|
|
#include <mbgl/util/bitmask_operations.hpp>
|
|
#include <mbgl/util/optional.hpp>
|
|
#include <mbgl/util/font_stack.hpp>
|
|
#include <mbgl/util/tileset.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace mbgl {
|
|
|
|
class Resource {
|
|
public:
|
|
enum Kind : uint8_t {
|
|
Unknown = 0,
|
|
Style,
|
|
Source,
|
|
Tile,
|
|
Glyphs,
|
|
SpriteImage,
|
|
SpriteJSON,
|
|
Image
|
|
};
|
|
|
|
enum class Priority : bool {
|
|
Regular,
|
|
Low
|
|
};
|
|
|
|
enum class Usage : bool {
|
|
Online,
|
|
Offline
|
|
};
|
|
|
|
struct TileData {
|
|
std::string urlTemplate;
|
|
uint8_t pixelRatio;
|
|
int32_t x;
|
|
int32_t y;
|
|
int8_t z;
|
|
};
|
|
|
|
enum class LoadingMethod : uint8_t {
|
|
None = 0b00,
|
|
Cache = 0b01,
|
|
Network = 0b10,
|
|
|
|
CacheOnly = Cache,
|
|
NetworkOnly = Network,
|
|
All = Cache | Network,
|
|
};
|
|
|
|
Resource(Kind kind_,
|
|
std::string url_,
|
|
optional<TileData> tileData_ = {},
|
|
LoadingMethod loadingMethod_ = LoadingMethod::All)
|
|
: kind(kind_),
|
|
loadingMethod(loadingMethod_),
|
|
url(std::move(url_)),
|
|
tileData(std::move(tileData_)) {
|
|
}
|
|
|
|
void setPriority(Priority p) { priority = p; }
|
|
void setUsage(Usage u) { usage = u; }
|
|
|
|
bool hasLoadingMethod(LoadingMethod method) const;
|
|
|
|
static Resource style(const std::string& url);
|
|
static Resource source(const std::string& url);
|
|
static Resource tile(const std::string& urlTemplate,
|
|
float pixelRatio,
|
|
int32_t x,
|
|
int32_t y,
|
|
int8_t z,
|
|
Tileset::Scheme scheme,
|
|
LoadingMethod = LoadingMethod::All);
|
|
static Resource glyphs(const std::string& urlTemplate,
|
|
const FontStack& fontStack,
|
|
const std::pair<uint16_t, uint16_t>& glyphRange);
|
|
static Resource spriteImage(const std::string& base, float pixelRatio);
|
|
static Resource spriteJSON(const std::string& base, float pixelRatio);
|
|
static Resource image(const std::string& url);
|
|
|
|
Kind kind;
|
|
LoadingMethod loadingMethod;
|
|
Usage usage{ Usage::Online };
|
|
Priority priority{ Priority::Regular };
|
|
std::string url;
|
|
|
|
// Includes auxiliary data if this is a tile request.
|
|
optional<TileData> tileData;
|
|
|
|
optional<Timestamp> priorModified = {};
|
|
optional<Timestamp> priorExpires = {};
|
|
optional<std::string> priorEtag = {};
|
|
std::shared_ptr<const std::string> priorData;
|
|
};
|
|
|
|
inline bool Resource::hasLoadingMethod(Resource::LoadingMethod method) const {
|
|
return (loadingMethod & method);
|
|
}
|
|
|
|
} // namespace mbgl
|