summaryrefslogtreecommitdiff
path: root/include/mbgl/style
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-09-16 16:38:32 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-09-24 16:14:09 +0200
commitf26bb724dc164b69b5358f30c6248fdf5cbd076b (patch)
tree4c719a97ff02c86a22bcdcec6fc0f781c3bcd3e9 /include/mbgl/style
parent6c526e56370a0f4dee9a4b6ed45489fcb14e3ff1 (diff)
downloadqtlocation-mapboxgl-f26bb724dc164b69b5358f30c6248fdf5cbd076b.tar.gz
use util::ptr as a wrapper around std::shared_ptr that asserts nonemptiness
Diffstat (limited to 'include/mbgl/style')
-rw-r--r--include/mbgl/style/style.hpp4
-rw-r--r--include/mbgl/style/style_bucket.hpp6
-rw-r--r--include/mbgl/style/style_layer.hpp7
-rw-r--r--include/mbgl/style/style_layer_group.hpp2
-rw-r--r--include/mbgl/style/style_parser.hpp18
-rw-r--r--include/mbgl/style/style_source.hpp7
6 files changed, 22 insertions, 22 deletions
diff --git a/include/mbgl/style/style.hpp b/include/mbgl/style/style.hpp
index c09de6ebba..56f318ecbb 100644
--- a/include/mbgl/style/style.hpp
+++ b/include/mbgl/style/style.hpp
@@ -6,6 +6,7 @@
#include <mbgl/util/time.hpp>
#include <mbgl/util/uv.hpp>
+#include <mbgl/util/ptr.hpp>
#include <cstdint>
#include <map>
@@ -13,7 +14,6 @@
#include <unordered_map>
#include <vector>
#include <set>
-#include <memory>
namespace mbgl {
@@ -49,7 +49,7 @@ public:
const std::string &getSpriteURL() const;
public:
- std::shared_ptr<StyleLayerGroup> layers;
+ util::ptr<StyleLayerGroup> layers;
std::vector<std::string> appliedClasses;
std::string glyph_url;
diff --git a/include/mbgl/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp
index c2cde52aa5..c4a8f6037e 100644
--- a/include/mbgl/style/style_bucket.hpp
+++ b/include/mbgl/style/style_bucket.hpp
@@ -8,8 +8,8 @@
#include <mbgl/util/vec.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/ptr.hpp>
-#include <memory>
#include <forward_list>
namespace mbgl {
@@ -93,12 +93,12 @@ typedef mapbox::util::variant<StyleBucketFill, StyleBucketLine, StyleBucketSymbo
class StyleBucket {
public:
- typedef std::shared_ptr<StyleBucket> Ptr;
+ typedef util::ptr<StyleBucket> Ptr;
StyleBucket(StyleLayerType type);
std::string name;
- std::shared_ptr<StyleSource> style_source;
+ util::ptr<StyleSource> style_source;
std::string source_layer;
FilterExpression filter;
StyleBucketRender render = std::false_type();
diff --git a/include/mbgl/style/style_layer.hpp b/include/mbgl/style/style_layer.hpp
index 84981e3fb4..641dc1e71c 100644
--- a/include/mbgl/style/style_layer.hpp
+++ b/include/mbgl/style/style_layer.hpp
@@ -6,8 +6,9 @@
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/applied_class_properties.hpp>
+#include <mbgl/util/ptr.hpp>
+
#include <vector>
-#include <memory>
#include <string>
#include <map>
#include <set>
@@ -64,7 +65,7 @@ public:
// Bucket information, telling the renderer how to generate the geometries
// for this layer (feature property filters, tessellation instructions, ...).
- std::shared_ptr<StyleBucket> bucket;
+ util::ptr<StyleBucket> bucket;
// Contains all style classes that can be applied to this layer.
const std::map<ClassID, ClassProperties> styles;
@@ -80,7 +81,7 @@ public:
StyleProperties properties;
// Child layer array (if this layer has child layers).
- std::shared_ptr<StyleLayerGroup> layers;
+ util::ptr<StyleLayerGroup> layers;
};
}
diff --git a/include/mbgl/style/style_layer_group.hpp b/include/mbgl/style/style_layer_group.hpp
index 983dd136f0..1af6e23bd7 100644
--- a/include/mbgl/style/style_layer_group.hpp
+++ b/include/mbgl/style/style_layer_group.hpp
@@ -15,7 +15,7 @@ public:
bool hasTransitions() const;
public:
- std::vector<std::shared_ptr<StyleLayer>> layers;
+ std::vector<util::ptr<StyleLayer>> layers;
};
}
diff --git a/include/mbgl/style/style_parser.hpp b/include/mbgl/style/style_parser.hpp
index e4e1b7f632..fc253bb1dd 100644
--- a/include/mbgl/style/style_parser.hpp
+++ b/include/mbgl/style/style_parser.hpp
@@ -27,7 +27,7 @@ public:
void parse(JSVal document);
- std::shared_ptr<StyleLayerGroup> getLayers() {
+ util::ptr<StyleLayerGroup> getLayers() {
return root;
}
@@ -46,14 +46,14 @@ private:
void parseSources(JSVal value);
std::unique_ptr<StyleLayerGroup> createLayers(JSVal value);
- std::shared_ptr<StyleLayer> createLayer(JSVal value);
+ util::ptr<StyleLayer> createLayer(JSVal value);
void parseLayers();
- void parseLayer(std::pair<JSVal, std::shared_ptr<StyleLayer>> &pair);
+ void parseLayer(std::pair<JSVal, util::ptr<StyleLayer>> &pair);
void parseStyles(JSVal value, std::map<ClassID, ClassProperties> &styles);
void parseStyle(JSVal, ClassProperties &properties);
- void parseReference(JSVal value, std::shared_ptr<StyleLayer> &layer);
- void parseBucket(JSVal value, std::shared_ptr<StyleLayer> &layer);
- void parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer);
+ void parseReference(JSVal value, util::ptr<StyleLayer> &layer);
+ void parseBucket(JSVal value, util::ptr<StyleLayer> &layer);
+ void parseRender(JSVal value, util::ptr<StyleLayer> &layer);
void parseSprite(JSVal value);
void parseGlyphURL(JSVal value);
@@ -94,13 +94,13 @@ private:
private:
std::unordered_map<std::string, const rapidjson::Value *> constants;
- std::unordered_map<std::string, const std::shared_ptr<StyleSource>> sources;
+ std::unordered_map<std::string, const util::ptr<StyleSource>> sources;
// This stores the root layer.
- std::shared_ptr<StyleLayerGroup> root;
+ util::ptr<StyleLayerGroup> root;
// This maps ids to Layer objects, with all items being at the root level.
- std::unordered_map<std::string, std::pair<JSVal, std::shared_ptr<StyleLayer>>> layers;
+ std::unordered_map<std::string, std::pair<JSVal, util::ptr<StyleLayer>>> layers;
// Store a stack of layers we're parsing right now. This is to prevent reference cycles.
std::forward_list<StyleLayer *> stack;
diff --git a/include/mbgl/style/style_source.hpp b/include/mbgl/style/style_source.hpp
index b598550c65..4b89a6557c 100644
--- a/include/mbgl/style/style_source.hpp
+++ b/include/mbgl/style/style_source.hpp
@@ -2,13 +2,12 @@
#define MBGL_STYLE_STYLE_SOURCE
#include <mbgl/style/types.hpp>
+#include <mbgl/util/ptr.hpp>
+#include <rapidjson/document.h>
-#include <memory>
#include <vector>
#include <string>
-#include <rapidjson/document.h>
-
namespace mbgl {
class Source;
@@ -34,7 +33,7 @@ public:
SourceInfo info;
bool enabled = false;
- std::shared_ptr<Source> source;
+ util::ptr<Source> source;
StyleSource(const SourceInfo &info)
: info(info)