diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-01-16 14:04:41 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-02-04 10:46:37 +0100 |
commit | b9bf66e67ed1d0d1b1d3163255cab099a6ba4a95 (patch) | |
tree | 93ad6df882442e18d9a9771d4b4f06a0a764a0a9 /include/mbgl/storage/resource.hpp | |
parent | 3bfea8bf30c978173f1ec2fab6f89d6b33afea86 (diff) | |
download | qtlocation-mapboxgl-b9bf66e67ed1d0d1b1d3163255cab099a6ba4a95.tar.gz |
rewrite storage layer to be independent of the Map's event loop
Diffstat (limited to 'include/mbgl/storage/resource.hpp')
-rw-r--r-- | include/mbgl/storage/resource.hpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp new file mode 100644 index 0000000000..e499f84a28 --- /dev/null +++ b/include/mbgl/storage/resource.hpp @@ -0,0 +1,39 @@ +#ifndef MBGL_STORAGE_RESOURCE +#define MBGL_STORAGE_RESOURCE + +#include <string> +#include <functional> + +namespace mbgl { + +struct Resource { + enum Kind : uint8_t { + Unknown = 0, + Tile = 1, + Glyphs = 2, + Image = 3, + JSON = 4, + }; + + const Kind kind; + const std::string url; + + inline bool operator==(const Resource &res) const { + return kind == res.kind && url == res.url; + } +}; + +} + +// Specialize std::hash for use in std::unordered_map +namespace std { + +template<> struct hash<mbgl::Resource> { + std::size_t operator()(mbgl::Resource const& r) const { + return std::hash<std::string>()(r.url) ^ (std::hash<uint8_t>()(r.kind) << 1); + } +}; + +} + +#endif |