summaryrefslogtreecommitdiff
path: root/include/mbgl/storage
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-01-28 16:29:54 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-01-29 14:50:15 -0800
commitb41a73e1c1dfea982df4a0326d45a48babc22dd4 (patch)
treefc744d5953ad6ecf8e52d5653c499760b148cb5c /include/mbgl/storage
parent849e8b32b4b2febc63ad3df8539b483ccc67ac63 (diff)
downloadqtlocation-mapboxgl-b41a73e1c1dfea982df4a0326d45a48babc22dd4.tar.gz
[core] Rationalize Resource initialization
Diffstat (limited to 'include/mbgl/storage')
-rw-r--r--include/mbgl/storage/resource.hpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp
index 532feff14a..d684e16d1b 100644
--- a/include/mbgl/storage/resource.hpp
+++ b/include/mbgl/storage/resource.hpp
@@ -20,20 +20,6 @@ public:
SpriteJSON
};
- Resource(Kind kind_, const std::string& url_)
- : kind(kind_),
- url(url_) {
- }
-
- const Kind kind;
- const std::string url;
-
- optional<SystemTimePoint> priorModified;
- optional<SystemTimePoint> priorExpires;
- optional<std::string> priorEtag;
-
- // Includes auxiliary data if this is a tile request.
-
struct TileData {
std::string urlTemplate;
float pixelRatio;
@@ -42,7 +28,34 @@ public:
int8_t z;
};
+ Resource(Kind kind_, const std::string& url_, optional<TileData> tileData_ = {})
+ : kind(kind_),
+ url(url_),
+ tileData(tileData_) {
+ }
+
+ 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);
+ static Resource glyphs(const std::string& urlTemplate,
+ const std::string& 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);
+
+ const Kind kind;
+ const std::string url;
+
+ // Includes auxiliary data if this is a tile request.
optional<TileData> tileData;
+
+ optional<SystemTimePoint> priorModified = {};
+ optional<SystemTimePoint> priorExpires = {};
+ optional<std::string> priorEtag = {};
};
} // namespace mbgl