summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-13 14:24:26 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-13 14:24:26 -0700
commit36bef2157595e1455aa55c64c6c526f096dd1c8e (patch)
tree908c2ff48dc5a5a9957f8675e9c18f8b7a03c598
parent040bdb1994106516a27edfef8c83c8d6aea3ec87 (diff)
downloadqtlocation-mapboxgl-36bef2157595e1455aa55c64c6c526f096dd1c8e.tar.gz
[core] Eliminate duplicate Necessity types
-rw-r--r--src/mbgl/tile/raster_tile.cpp2
-rw-r--r--src/mbgl/tile/tile.hpp11
-rw-r--r--src/mbgl/tile/tile_loader.hpp13
-rw-r--r--src/mbgl/tile/vector_tile.cpp2
4 files changed, 12 insertions, 16 deletions
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index ef67820277..5cfd41a164 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -60,7 +60,7 @@ Bucket* RasterTile::getBucket(const style::Layer&) {
}
void RasterTile::setNecessity(Necessity necessity) {
- loader.setNecessity(static_cast<TileLoader<RasterTile>::Necessity>(necessity));
+ loader.setNecessity(necessity);
}
void RasterTile::cancel() {
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index 931317463a..65f3aaa245 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -8,6 +8,7 @@
#include <mbgl/renderer/bucket.hpp>
#include <mbgl/text/placement_config.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
+#include <mbgl/storage/resource.hpp>
#include <string>
#include <memory>
@@ -32,10 +33,12 @@ public:
void setObserver(TileObserver* observer);
- enum class Necessity : bool {
- Optional = false,
- Required = true,
- };
+ // Tiles can have two states: optional or required.
+ // - optional means that only low-cost actions should be taken to obtain the data
+ // (e.g. load from cache, but accept stale data)
+ // - required means that every effort should be taken to obtain the data (e.g. load
+ // from internet and keep the data fresh if it expires)
+ using Necessity = Resource::Necessity;
virtual void setNecessity(Necessity) = 0;
diff --git a/src/mbgl/tile/tile_loader.hpp b/src/mbgl/tile/tile_loader.hpp
index cab1907741..1086f4ed33 100644
--- a/src/mbgl/tile/tile_loader.hpp
+++ b/src/mbgl/tile/tile_loader.hpp
@@ -2,6 +2,7 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/storage/resource.hpp>
+#include <mbgl/tile/tile.hpp>
namespace mbgl {
@@ -17,21 +18,13 @@ class UpdateParameters;
template <typename T>
class TileLoader : private util::noncopyable {
public:
- // TileSources can have two states: optional or required.
- // - optional means that only low-cost actions should be taken to obtain the data
- // (e.g. load from cache, but accept stale data)
- // - required means that every effort should be taken to obtain the data (e.g. load
- // from internet and keep the data fresh if it expires)
- enum class Necessity : bool {
- Optional = false,
- Required = true,
- };
-
TileLoader(T&,
const OverscaledTileID&,
const style::UpdateParameters&,
const Tileset&);
+ using Necessity = Resource::Necessity;
+
void setNecessity(Necessity newNecessity) {
if (newNecessity != necessity) {
necessity = newNecessity;
diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp
index 8050f51a94..2184fb24dd 100644
--- a/src/mbgl/tile/vector_tile.cpp
+++ b/src/mbgl/tile/vector_tile.cpp
@@ -77,7 +77,7 @@ VectorTile::VectorTile(const OverscaledTileID& id_,
}
void VectorTile::setNecessity(Necessity necessity) {
- loader.setNecessity(static_cast<TileLoader<VectorTile>::Necessity>(necessity));
+ loader.setNecessity(necessity);
}
void VectorTile::setData(std::shared_ptr<const std::string> data_,