summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorartemp <artem@mapnik.org>2014-02-06 10:25:36 +0000
committerartemp <artem@mapnik.org>2014-02-06 10:33:46 +0000
commitd6654ccaed8b522b6de3156c1a271f6c60a67572 (patch)
tree1dbadb865cd7acb62a51a2b29fb5feefc820e684 /include
parent61c69f587283fc3f398e9521c5b30cf32632851a (diff)
downloadqtlocation-mapboxgl-d6654ccaed8b522b6de3156c1a271f6c60a67572.tar.gz
c++
* fix typedef's * fix virtual dtor's * make ctor's with one argument explicit * util::noncopyable utility class ( class my_object : private noncopyable {} ) * update kTileURL
Diffstat (limited to 'include')
-rw-r--r--include/llmr/geometry/binpack.hpp13
-rw-r--r--include/llmr/geometry/fill_buffer.hpp5
-rw-r--r--include/llmr/geometry/geometry.hpp14
-rw-r--r--include/llmr/geometry/line_buffer.hpp6
-rw-r--r--include/llmr/geometry/vertex_buffer.hpp5
-rw-r--r--include/llmr/map/map.hpp12
-rw-r--r--include/llmr/map/settings.hpp13
-rw-r--r--include/llmr/map/tile.hpp10
-rw-r--r--include/llmr/map/transform.hpp9
-rw-r--r--include/llmr/platform/platform.hpp2
-rw-r--r--include/llmr/renderer/bucket.hpp12
-rw-r--r--include/llmr/renderer/painter.hpp10
-rw-r--r--include/llmr/renderer/shader.hpp12
-rw-r--r--include/llmr/util/animation.hpp11
-rw-r--r--include/llmr/util/noncopyable.hpp23
15 files changed, 68 insertions, 89 deletions
diff --git a/include/llmr/geometry/binpack.hpp b/include/llmr/geometry/binpack.hpp
index 03b34c63da..d7405d7d35 100644
--- a/include/llmr/geometry/binpack.hpp
+++ b/include/llmr/geometry/binpack.hpp
@@ -1,6 +1,7 @@
#ifndef LLMR_GEOMETRY_BINPACK
#define LLMR_GEOMETRY_BINPACK
+#include <llmr/util/noncopyable.hpp>
#include <cstdint>
#include <list>
@@ -14,23 +15,15 @@ struct Rect {
};
template <typename T>
-class BinPack {
+class BinPack : private noncopyable {
public:
BinPack(T width, T height)
: free(1, { 0, 0, width, height }) {}
-
-private:
- // Make noncopyable
- BinPack(const BinPack&) = delete;
- BinPack(const BinPack&&) = delete;
- BinPack& operator=(const BinPack&) = delete;
- BinPack& operator=(const BinPack && ) = delete;
-
public:
Rect<T> allocate(T width, T height) {
// Find the smallest free rect angle
auto smallest = free.end();
- for (auto it = free.begin(); it != free.end(); it++) {
+ for (auto it = free.begin(); it != free.end(); ++it) {
const Rect<T>& ref = *it;
const Rect<T>& rect = *smallest;
if (width <= ref.w && height <= ref.h) {
diff --git a/include/llmr/geometry/fill_buffer.hpp b/include/llmr/geometry/fill_buffer.hpp
index 626d66179b..b141825fcb 100644
--- a/include/llmr/geometry/fill_buffer.hpp
+++ b/include/llmr/geometry/fill_buffer.hpp
@@ -9,6 +9,7 @@ namespace llmr {
class FillBuffer {
public:
typedef int16_t vertex_type;
+ typedef uint16_t element_type;
const uint8_t components = 2;
FillBuffer();
@@ -19,13 +20,13 @@ public:
void addDegenerate();
void addCoordinate(vertex_type x, vertex_type y);
- void addElements(uint16_t a, uint16_t b, uint16_t c);
+ void addElements(element_type a, element_type b, element_type c);
void bind();
private:
std::vector<vertex_type> vertices;
- std::vector<uint16_t> elements;
+ std::vector<element_type> elements;
uint32_t vertex_buffer;
uint32_t element_buffer;
bool dirty;
diff --git a/include/llmr/geometry/geometry.hpp b/include/llmr/geometry/geometry.hpp
index 6808324295..f8286402db 100644
--- a/include/llmr/geometry/geometry.hpp
+++ b/include/llmr/geometry/geometry.hpp
@@ -2,15 +2,17 @@
#define LLMR_GEOMETRY_GEOMETRY
#include <llmr/util/pbf.hpp>
+#include <llmr/util/noncopyable.hpp>
#include <cstdlib>
namespace llmr {
-class Geometry {
-public:
- inline Geometry(pbf& data);
+class Geometry : private util::noncopyable {
+public:
+ inline explicit Geometry(pbf& data);
+
enum command {
end = 0,
move_to = 1,
@@ -37,13 +39,13 @@ Geometry::Geometry(pbf& data)
Geometry::command Geometry::next(int32_t &rx, int32_t &ry) {
if (data.data < data.end) {
- if (!length) {
- uint32_t cmd_length = (uint32_t)data.varint();
+ if (length == 0) {
+ uint32_t cmd_length = static_cast<uint32_t>(data.varint());
cmd = cmd_length & 0x7;
length = cmd_length >> 3;
}
- length--;
+ --length;
if (cmd == move_to || cmd == line_to) {
rx = (x += data.svarint());
diff --git a/include/llmr/geometry/line_buffer.hpp b/include/llmr/geometry/line_buffer.hpp
index 4965a919ae..412ba860c8 100644
--- a/include/llmr/geometry/line_buffer.hpp
+++ b/include/llmr/geometry/line_buffer.hpp
@@ -9,6 +9,8 @@ namespace llmr {
class LineBuffer {
public:
+ typedef int16_t vertex_type;
+
~LineBuffer();
/*
@@ -30,7 +32,7 @@ public:
* @param {number} tx texture normal
* @param {number} ty texture normal
*/
- void add(int16_t x, int16_t y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar = 0);
+ void add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar = 0);
/*
* Add a degenerate triangle to the buffer
@@ -56,7 +58,7 @@ public:
private:
bool dirty = true;
- std::vector<int16_t> array;
+ std::vector<vertex_type> array;
uint32_t buffer = 0;
};
diff --git a/include/llmr/geometry/vertex_buffer.hpp b/include/llmr/geometry/vertex_buffer.hpp
index 667e3fc8a3..5dd5ec7195 100644
--- a/include/llmr/geometry/vertex_buffer.hpp
+++ b/include/llmr/geometry/vertex_buffer.hpp
@@ -9,7 +9,8 @@ namespace llmr {
class VertexBuffer {
public:
- VertexBuffer(std::initializer_list<int16_t> init);
+ typedef int16_t vertex_type;
+ VertexBuffer(std::initializer_list<vertex_type> init);
~VertexBuffer();
/*
@@ -24,7 +25,7 @@ public:
void bind();
private:
- const std::vector<int16_t> array;
+ const std::vector<vertex_type> array;
uint32_t buffer = 0;
};
diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp
index 46b7dfb3c3..189327c522 100644
--- a/include/llmr/map/map.hpp
+++ b/include/llmr/map/map.hpp
@@ -5,6 +5,7 @@
#include <llmr/map/transform.hpp>
#include <llmr/style/style.hpp>
#include <llmr/renderer/painter.hpp>
+#include <llmr/util/noncopyable.hpp>
#include <cstdint>
#include <string>
@@ -13,18 +14,11 @@ namespace llmr {
class Settings;
-class Map {
+class Map : private util::noncopyable {
public:
- Map(Settings& settings);
+ explicit Map(Settings& settings);
~Map();
-
- // Make noncopyable
- Map(const Map&) = delete;
- Map(const Map&&) = delete;
- Map &operator=(const Map&) = delete;
- Map &operator=(const Map&&) = delete;
-
/* setup */
void setup();
void loadStyle(const uint8_t *const data, uint32_t bytes);
diff --git a/include/llmr/map/settings.hpp b/include/llmr/map/settings.hpp
index 8f2e12810a..3e5395b803 100644
--- a/include/llmr/map/settings.hpp
+++ b/include/llmr/map/settings.hpp
@@ -1,19 +1,14 @@
#ifndef LLMR_MAP_SETTINGS
#define LLMR_MAP_SETTINGS
+#include <llmr/util/noncopyable.hpp>
+
namespace llmr {
-class Settings {
+class Settings : private util::noncopyable {
public:
virtual void save() = 0;
-
- // Make noncopyable
- Settings() = default;
- Settings(const Settings&) = delete;
- Settings(const Settings&&) = delete;
- Settings &operator=(const Settings&) = delete;
- Settings &operator=(const Settings&&) = delete;
-
+ virtual ~Settings() {}
public:
// position
double longitude = 0;
diff --git a/include/llmr/map/tile.hpp b/include/llmr/map/tile.hpp
index 2569764cc6..7896d91ebd 100644
--- a/include/llmr/map/tile.hpp
+++ b/include/llmr/map/tile.hpp
@@ -2,6 +2,7 @@
#define LLMR_MAP_TILE
#include <llmr/util/vec.hpp>
+#include <llmr/util/noncopyable.hpp>
#include <llmr/geometry/debug_font_buffer.hpp>
#include <llmr/geometry/vao.hpp>
@@ -24,7 +25,8 @@ class FillBuffer;
class LineBuffer;
class PlainShader;
-class Tile : public std::enable_shared_from_this<Tile> {
+class Tile : public std::enable_shared_from_this<Tile>,
+ private util::noncopyable {
public:
struct exception : std::exception {};
struct geometry_too_long_exception : exception {};
@@ -45,12 +47,6 @@ public:
Tile(ID id, const Style& style);
~Tile();
- // Make noncopyable
- Tile(const Tile&) = delete;
- Tile(const Tile&&) = delete;
- Tile& operator=(const Tile&) = delete;
- Tile& operator=(const Tile && ) = delete;
-
// Start loading the tile.
void request();
diff --git a/include/llmr/map/transform.hpp b/include/llmr/map/transform.hpp
index 9b39aa149a..521bcd75a1 100644
--- a/include/llmr/map/transform.hpp
+++ b/include/llmr/map/transform.hpp
@@ -4,6 +4,7 @@
#include <llmr/util/vec.hpp>
#include <llmr/util/mat4.hpp>
#include <llmr/util/animation.hpp>
+#include <llmr/util/noncopyable.hpp>
#include <forward_list>
@@ -11,16 +12,10 @@ namespace llmr {
struct box;
-class Transform {
+ class Transform : private util::noncopyable {
public:
Transform();
- // Make noncopyable
- Transform(const Transform&) = delete;
- Transform(const Transform&&) = delete;
- Transform &operator=(const Transform&) = delete;
- Transform &operator=(const Transform&&) = delete;
-
// Animations
bool needsAnimation() const;
void updateAnimations();
diff --git a/include/llmr/platform/platform.hpp b/include/llmr/platform/platform.hpp
index b31a112b87..ff6330241c 100644
--- a/include/llmr/platform/platform.hpp
+++ b/include/llmr/platform/platform.hpp
@@ -5,7 +5,7 @@
#include <functional>
#include <string>
-#define kTileURL "http://mapbox:magic@kkaefer.net/gl/tiles/plain/%d-%d-%d.vector.pbf"
+#define kTileURL "http://a.gl-api-us-east-1.tilestream.net/v3/mapbox.mapbox-streets-v4/%d/%d/%d.gl.pbf"
#define kSpriteURL "http://mapbox:magic@kkaefer.net/gl/debug/img/sprite"
namespace llmr {
diff --git a/include/llmr/renderer/bucket.hpp b/include/llmr/renderer/bucket.hpp
index 7ae0d2d008..9326aaed14 100644
--- a/include/llmr/renderer/bucket.hpp
+++ b/include/llmr/renderer/bucket.hpp
@@ -3,22 +3,16 @@
#include <string>
#include <llmr/map/tile.hpp>
+#include <llmr/util/noncopyable.hpp>
namespace llmr {
class Painter;
-class Bucket {
+class Bucket : private util::noncopyable {
public:
- Bucket() = default;
virtual void render(Painter& painter, const std::string& layer_name, const Tile::ID& id) = 0;
-
-private:
- // Make noncopyable
- Bucket(const Bucket&) = delete;
- Bucket(const Bucket&&) = delete;
- Bucket& operator=(const Bucket&) = delete;
- Bucket& operator=(const Bucket && ) = delete;
+ virtual ~Bucket() {}
};
}
diff --git a/include/llmr/renderer/painter.hpp b/include/llmr/renderer/painter.hpp
index b991c9592b..925defd035 100644
--- a/include/llmr/renderer/painter.hpp
+++ b/include/llmr/renderer/painter.hpp
@@ -5,6 +5,7 @@
#include <llmr/geometry/vao.hpp>
#include <llmr/geometry/vertex_buffer.hpp>
#include <llmr/util/mat4.hpp>
+#include <llmr/util/noncopyable.hpp>
#include <llmr/renderer/shader-plain.hpp>
#include <llmr/renderer/shader-outline.hpp>
@@ -22,18 +23,11 @@ class Tile;
class FillBucket;
class LineBucket;
-class Painter {
+class Painter : private util::noncopyable {
public:
Painter(Transform& transform, Settings& settings, Style& style);
- // Make noncopyable
- Painter(const Painter&) = delete;
- Painter(const Painter&&) = delete;
- Painter& operator=(const Painter&) = delete;
- Painter& operator=(const Painter && ) = delete;
-
void setup();
-
void clear();
void changeMatrix(const Tile::ID& id);
void render(const std::shared_ptr<Tile>& tile);
diff --git a/include/llmr/renderer/shader.hpp b/include/llmr/renderer/shader.hpp
index 26674d2d62..77fd7a6f62 100644
--- a/include/llmr/renderer/shader.hpp
+++ b/include/llmr/renderer/shader.hpp
@@ -2,20 +2,14 @@
#define LLMR_RENDERER_SHADER
#include <cstdint>
+#include <llmr/util/noncopyable.hpp>
namespace llmr {
-class Shader {
+class Shader : private util::noncopyable {
public:
Shader(const char *vertex, const char *fragment);
- virtual ~Shader();
-
- // Make noncopyable
- Shader(const Shader&) = delete;
- Shader(const Shader&&) = delete;
- Shader &operator=(const Shader&) = delete;
- Shader &operator=(const Shader&&) = delete;
-
+ ~Shader();
bool valid;
uint32_t program;
diff --git a/include/llmr/util/animation.hpp b/include/llmr/util/animation.hpp
index c31f1ff9db..4095fcba1e 100644
--- a/include/llmr/util/animation.hpp
+++ b/include/llmr/util/animation.hpp
@@ -1,10 +1,12 @@
#ifndef LLMR_UTIL_ANIMATION
#define LLMR_UTIL_ANIMATION
+#include <llmr/util/noncopyable.hpp>
+
namespace llmr {
namespace util {
-class animation {
+class animation : private noncopyable {
public:
enum state {
running,
@@ -12,13 +14,6 @@ public:
};
animation(double from, double to, double &value, double duration);
-
- // Make noncopyable
- animation(const animation&) = delete;
- animation(const animation&&) = delete;
- animation &operator=(const animation&) = delete;
- animation &operator=(const animation&&) = delete;
-
state update() const;
private:
diff --git a/include/llmr/util/noncopyable.hpp b/include/llmr/util/noncopyable.hpp
new file mode 100644
index 0000000000..7891e529e3
--- /dev/null
+++ b/include/llmr/util/noncopyable.hpp
@@ -0,0 +1,23 @@
+#ifndef LLMR_UTIL_NONCOPYABLE
+#define LLMR_UTIL_NONCOPYABLE
+
+namespace llmr { namespace util {
+
+namespace non_copyable_
+{
+
+class noncopyable
+{
+protected:
+ constexpr noncopyable() = default;
+ ~noncopyable() = default;
+ noncopyable( noncopyable const& ) = delete;
+ noncopyable& operator=(noncopyable const& ) = delete;
+};
+}
+
+typedef non_copyable_::noncopyable noncopyable;
+
+}}
+
+#endif //LLMR_UTIL_NONCOPYABLE