From 454398985c6bbd113cc051e5b7d17800de455b69 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Thu, 19 Mar 2015 13:42:17 -0500 Subject: [PATCH] Implementing < and == operators in image --- include/mapnik/image.hpp | 2 ++ include/mapnik/image_impl.hpp | 16 ++++++++++++---- include/mapnik/image_null.hpp | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/mapnik/image.hpp b/include/mapnik/image.hpp index 833a9989e..2b824af21 100644 --- a/include/mapnik/image.hpp +++ b/include/mapnik/image.hpp @@ -94,6 +94,8 @@ public: image(image && rhs) noexcept; image& operator=(image rhs); imageconst& operator=(image const& rhs) const; + bool operator==(image const& rhs) const; + bool operator<(image const& rhs) const; void swap(image & rhs); pixel_type& operator() (std::size_t i, std::size_t j); diff --git a/include/mapnik/image_impl.hpp b/include/mapnik/image_impl.hpp index e47f2a086..44d9bd298 100644 --- a/include/mapnik/image_impl.hpp +++ b/include/mapnik/image_impl.hpp @@ -20,9 +20,6 @@ * *****************************************************************************/ -#ifndef MAPNIK_IMAGE_IMPL_HPP -#define MAPNIK_IMAGE_IMPL_HPP - // mapnik #include @@ -134,6 +131,18 @@ image const& image::operator=(image const& rhs) const return rhs; } +template +bool image::operator==(image const& rhs) const +{ + return rhs.getBytes() == getBytes(); +} + +template +bool image::operator<(image const& rhs) const +{ + return getSize() < rhs.getSize(); +} + template void image::swap(image & rhs) { @@ -314,4 +323,3 @@ inline image_dtype image::get_dtype() const } // end ns -#endif // MAPNIK_IMAGE_IMPL_HPP diff --git a/include/mapnik/image_null.hpp b/include/mapnik/image_null.hpp index c882646d1..af7123ca6 100644 --- a/include/mapnik/image_null.hpp +++ b/include/mapnik/image_null.hpp @@ -25,7 +25,6 @@ // mapnik #include -//#include #include //stl @@ -50,6 +49,10 @@ public: bool painted = false) {} image(image const& rhs) {} image(image && rhs) noexcept {} + image& operator=(image rhs) { return *this; } + imageconst& operator=(image const& rhs) const { return rhs; } + bool operator==(image const& rhs) const { return true; } + bool operator<(image const& rhs) const { return false; } std::size_t width() const { return 0; } std::size_t height() const { return 0; }