Commit 9c2000d3 authored by Michaël Roynard's avatar Michaël Roynard
Browse files

WIP adaptor/transform

parent 99fb0c80
Pipeline #12645 passed with stages
in 14 minutes and 43 seconds
......@@ -93,8 +93,8 @@ namespace mln::archetypes
ViewImage() = delete;
ViewImage(const ViewImage&) = default;
ViewImage(ViewImage&&) = default;
ViewImage& operator=(const ViewImage&) = default;
ViewImage& operator=(ViewImage&&) = default;
ViewImage& operator=(const ViewImage&) = delete;
ViewImage& operator=(ViewImage&&) = delete;
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
......
......@@ -17,8 +17,8 @@ namespace mln::archetypes
Pixel() = delete;
Pixel(const Pixel&) = default;
Pixel(Pixel&&) = default;
Pixel& operator=(const Pixel&) = default;
Pixel& operator=(Pixel&&) = default;
Pixel& operator=(const Pixel&) = delete;
Pixel& operator=(Pixel&&) = delete;
point_type point() const;
reference val() const;
......
......@@ -32,8 +32,10 @@ namespace mln::concepts
template<typename Ima>
concept Image =
// FIXME: inheritance from New_Image required for the moment
stl::Movable<Ima> && // Minimum constraint on image object
stl::Copyable<Ima> && // Do not requires DefaultConstructible
// Minimum constraint on image object
// Do not requires DefaultConstructible
stl::CopyConstructible<Ima> &&
stl::MoveConstructible<Ima> &&
stl::DerivedFrom<image_category_t<Ima>, forward_image_tag> &&
requires {
typename image_pixel_t<Ima>;
......
......@@ -18,8 +18,10 @@ namespace mln::concepts
// Pixel
template<typename Pix>
concept Pixel =
stl::Movable<Pix> && // Minimum constraint on pixel object
stl::Copyable<Pix> && // Do not requires DefaultConstructible
// Minimum constraint on image object
// Do not requires DefaultConstructible
stl::CopyConstructible<Pix> &&
stl::MoveConstructible<Pix> &&
requires {
typename pixel_value_t<Pix>;
typename pixel_reference_t<Pix>;
......
......@@ -14,10 +14,10 @@ namespace mln
template <class Pixel>
struct pixel_adaptor
{
using point_type = typename Pixel::point_type;
using site_type [[deprecated]] = point_type;
using value_type = typename Pixel::value_type;
using reference = typename Pixel::reference;
using point_type = typename Pixel::point_type;
using site_type[[deprecated]] = point_type;
using value_type = typename Pixel::value_type;
using reference = typename Pixel::reference;
decltype(auto) val() const { return m_pix.val(); }
auto point() const { return m_pix.point(); }
......@@ -31,8 +31,8 @@ namespace mln
// no default constructor as Pixel may not be default constructible
pixel_adaptor(const pixel_adaptor&) = default;
pixel_adaptor(pixel_adaptor&&) = default;
pixel_adaptor& operator=(const pixel_adaptor&) = default;
pixel_adaptor& operator=(pixel_adaptor&&) = default;
pixel_adaptor& operator=(const pixel_adaptor&) = delete;
pixel_adaptor& operator=(pixel_adaptor&&) = delete;
protected:
Pixel& base() { return m_pix; }
......@@ -82,8 +82,8 @@ namespace mln
template <class I>
struct image_adaptor_base_indexable<I, std::enable_if_t<I::indexable::value>>
{
using size_type [[deprecated]] = image_index_t<I>;
using index_type = size_type;
using size_type[[deprecated]] = image_index_t<I>;
using index_type = size_type;
};
template <class I, class = void>
......@@ -143,8 +143,8 @@ namespace mln
// no default constructor as I may not be default constructible
image_adaptor(const image_adaptor<I>&) = default;
image_adaptor(image_adaptor<I>&&) = default;
image_adaptor<I>& operator=(const image_adaptor<I>&) = default;
image_adaptor<I>& operator=(image_adaptor<I>&&) = default;
image_adaptor<I>& operator=(const image_adaptor<I>&) = delete;
image_adaptor<I>& operator=(image_adaptor<I>&&) = delete;
auto domain() const { return m_ima.domain(); }
auto new_values() { return m_ima.new_values(); }
......
......@@ -52,8 +52,10 @@ namespace mln
/// \{
struct new_pixel_type : pixel_adaptor<image_pixel_t<I>>, Pixel<new_pixel_type>
{
using reference = transform_view::reference;
using value_type = transform_view::value_type;
using point_type = transform_view::point_type;
using site_type[[deprecated]] = transform_view::point_type;
using reference = transform_view::reference;
using value_type = transform_view::value_type;
new_pixel_type(fun_t fun, image_pixel_t<I> px)
: new_pixel_type::pixel_adaptor{px}
......@@ -71,28 +73,6 @@ namespace mln
, fun_(std::move(other.fun_))
{
}
new_pixel_type& operator=(const new_pixel_type& other)
{
if (this != &other)
{
new_pixel_type::pixel_adaptor::operator=(other);
fun_ = other.fun_;
}
return *this;
}
new_pixel_type& operator=(new_pixel_type&& other)
{
if (this != &other)
{
new_pixel_type::pixel_adaptor::operator=(std::move(other));
fun_ = std::move(other.fun_);
}
return *this;
}
reference val() const { return std::invoke(fun_, this->base().val()); }
......@@ -118,28 +98,6 @@ namespace mln
, fun_(std::move(other.fun_))
{
}
transform_view& operator=(const transform_view& other)
{
if (this != &other)
{
transform_view::image_adaptor::operator=(other);
fun_ = other.fun_;
}
return *this;
}
transform_view& operator=(transform_view&& other)
{
if (this != &other)
{
transform_view::image_adaptor::operator=(std::move(other));
fun_ = std::move(other.fun_);
}
return *this;
}
decltype(auto) concretize() const { return imchvalue<value_type>(this->base()); }
......@@ -225,35 +183,45 @@ namespace mln
public:
/// Pixel type definitions
/// \{
struct new_pixel_type : Pixel<new_pixel_type>
struct new_pixel_type : pixel_adaptor<image_pixel_t<I1>>, Pixel<new_pixel_type>
{
public:
using point_type = typename transform2_view::point_type;
using site_type [[deprecated]] = point_type;
using value_type = typename transform2_view::value_type;
using reference = typename transform2_view::reference;
using point_type = transform2_view::point_type;
using site_type[[deprecated]] = transform2_view::point_type;
using reference = transform2_view::reference;
using value_type = transform2_view::value_type;
new_pixel_type(fun_t fun, image_pixel_t<I1> px1, image_pixel_t<I2> px2)
: m_pix1{std::move(px1)}
: new_pixel_type::pixel_adaptor{std::move(px1)}
, m_pix2{std::move(px2)}
, fun_{std::move(fun)}
{
}
// FIXME: implement copy/move ctors/operators
new_pixel_type(const new_pixel_type& other)
: new_pixel_type::pixel_adaptor{other}
, m_pix2{other.m_pix2}
, fun_(other.fun_)
{
}
new_pixel_type(new_pixel_type&& other)
: new_pixel_type::pixel_adaptor{std::move(other)}
, m_pix2{std::move(other.m_pix2)}
, fun_(std::move(other.fun_))
{
}
reference val() const { return std::invoke(fun_, m_pix1.val(), m_pix2.val()); }
auto point() const { return m_pix1.point(); }
reference val() const { return std::invoke(fun_, new_pixel_type::pixel_adaptor::val(), m_pix2.val()); }
auto point() const { return new_pixel_type::pixel_adaptor::point(); }
void advance(point_type p)
{
m_pix1.advance(p);
new_pixel_type::pixel_adaptor::advance(p);
m_pix2.advance(p);
}
private:
fun_t fun_;
image_pixel_t<I1> m_pix1;
image_pixel_t<I2> m_pix2;
};
/// \}
......@@ -265,7 +233,18 @@ namespace mln
{
}
// FIXME: implement copy/move ctors/operators
transform2_view(const transform2_view& other)
: m_ima1(other.m_ima1)
, m_ima2(other.m_ima2) /*transform_view::image_adaptor{other}*/
, fun_(other.fun_)
{
}
transform2_view(transform2_view&& other)
: m_ima1(std::move(other.m_ima1))
, m_ima2(std::move(other.m_ima2)) /*transform_view::image_adaptor{std::move(other)}*/
, fun_(std::move(other.fun_))
{
}
decltype(auto) concretize() const { return imchvalue<value_type>(this->base()); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment