Commit 9b053495 authored by Edwin Carlinet's avatar Edwin Carlinet Committed by Michaël Roynard
Browse files

Move conflicting experimental features in experimental namespace.

parent a3b58a0b
......@@ -30,9 +30,11 @@ namespace mln
template <typename OutputImage, typename Value>
OutputImage&& fill(Image<OutputImage>&& output, const Value& val);
template <class I, class Value>
std::enable_if_t<!is_a<I, Image>::value> fill(const New_Image<I>& f, const Value& v);
namespace experimental
{
template <class OutputImage, class Value>
void fill(const Image<OutputImage>& f, const Value& v);
}
/******************************************/
/**** Implementation ****/
......@@ -64,18 +66,20 @@ namespace mln
return output;
}
template <class I, class Value>
std::enable_if_t<!is_a<I, Image>::value>
fill(const New_Image<I>& f_, const Value& v)
namespace experimental
{
I f = static_cast<const I&>(f_);
template <class OutputImage, class Value>
void fill(const Image<OutputImage>& f_, const Value& v)
{
OutputImage f = static_cast<const OutputImage&>(f_);
for (auto row : ranges::rows(f.new_values()))
::ranges::fill(row, v);
for (auto row : ranges::rows(f.new_values()))
::ranges::fill(row, v);
}
}
} // end of namespace mln
#endif //! MLN_CORE_ALGORITHM_IMFILL_HPP
......@@ -10,13 +10,11 @@
#include <mln/core/image_traits.hpp>
#include <boost/concept_check.hpp>
#include <mln/core/concept/new/images.hpp>
namespace mln
{
template <typename I>
struct New_Image;
template <typename I>
struct Image;
template <typename I>
......@@ -32,11 +30,6 @@ namespace mln
template <typename I>
struct ImageWithExtension;
template <typename I>
struct New_Image
{
};
template <typename I>
struct Image : Object_<I>
......
......@@ -17,7 +17,8 @@ namespace mln::archetypes
struct ConcreteImage;
struct ConcreteImage
struct ConcreteImage : mln::experimental::Image<ConcreteImage>
{
using new_pixel_type = Pixel;
using value_type = pixel_value_t<Pixel>;
......@@ -86,7 +87,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct ViewImage : ConcreteImage
struct ViewImage : ConcreteImage, mln::experimental::Image<ViewImage>
{
using view = std::true_type;
......@@ -102,16 +103,14 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct Image : ViewImage
{
};
using Image = ViewImage;
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::Image<Image>, "Image archetype does not model the Image concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputImage : Image
struct OutputImage : Image, mln::experimental::Image<OutputImage>
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
......@@ -135,18 +134,14 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct InputImage : Image
{
};
using InputImage = Image;
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::InputImage<InputImage>, "InputImage archetype does not model the InputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct ForwardImage final : InputImage
{
};
using ForwardImage = InputImage;
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::ForwardImage<ForwardImage>,
......@@ -154,9 +149,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputForwardImage final : OutputImage
{
};
using OutputForwardImage = OutputImage;
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::ForwardImage<OutputForwardImage> && mln::concepts::OutputImage<OutputForwardImage>,
......@@ -164,7 +157,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct IndexableImage : Image
struct IndexableImage : Image, mln::experimental::Image<IndexableImage>
{
using index_type = int;
using indexable = std::true_type;
......@@ -178,7 +171,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputIndexableImage final : IndexableImage
struct OutputIndexableImage final : IndexableImage, mln::experimental::Image<OutputIndexableImage>
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
......@@ -206,7 +199,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct AccessibleImage : Image
struct AccessibleImage : Image, mln::experimental::Image<AccessibleImage>
{
using accessible = std::true_type;
......@@ -222,7 +215,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputAccessibleImage : AccessibleImage
struct OutputAccessibleImage : AccessibleImage, mln::experimental::Image<OutputAccessibleImage>
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
......@@ -255,7 +248,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct IndexableAndAccessibleImage : AccessibleImage
struct IndexableAndAccessibleImage : AccessibleImage, mln::experimental::Image<IndexableAndAccessibleImage>
{
using index_type = int;
using indexable = std::true_type;
......@@ -273,7 +266,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputIndexableAndAccessibleImage : OutputAccessibleImage
struct OutputIndexableAndAccessibleImage : OutputAccessibleImage, mln::experimental::Image<OutputIndexableAndAccessibleImage>
{
using index_type = int;
using indexable = std::true_type;
......@@ -297,20 +290,20 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct BidirectionalImage : Image
struct BidirectionalImage : Image, mln::experimental::Image<BidirectionalImage>
{
using category_type = bidirectional_image_tag;
struct ReversiblePixelRange final : Image::PixelRange
struct ReversiblePixelRange final : mln::archetypes::Image::PixelRange
{
Image::PixelRange reversed();
mln::archetypes::Image::PixelRange reversed();
};
ReversiblePixelRange new_pixels();
struct ReversibleValueRange final : Image::ValueRange
struct ReversibleValueRange final : mln::archetypes::Image::ValueRange
{
Image::ValueRange reversed();
mln::archetypes::Image::ValueRange reversed();
};
ReversibleValueRange new_values();
......@@ -322,7 +315,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputBidirectionalImage : BidirectionalImage
struct OutputBidirectionalImage : BidirectionalImage, mln::experimental::Image<OutputBidirectionalImage>
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
......@@ -351,21 +344,21 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct RawImage : IndexableAndAccessibleImage
struct RawImage : IndexableAndAccessibleImage, mln::experimental::Image<RawImage>
{
using category_type = raw_image_tag;
struct ReversiblePixelRange final : Image::PixelRange
struct ReversiblePixelRange final : mln::archetypes::Image::PixelRange
{
Image::PixelRange reversed();
mln::archetypes::Image::PixelRange reversed();
};
ReversiblePixelRange new_pixels();
struct ReversibleValueRange final : Image::ValueRange
struct ReversibleValueRange final : mln::archetypes::Image::ValueRange
{
Image::ValueRange reversed();
mln::archetypes::Image::ValueRange reversed();
};
ReversibleValueRange new_values();
......@@ -380,7 +373,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputRawImage final : RawImage
struct OutputRawImage final : RawImage, mln::experimental::Image<OutputRawImage>
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
......@@ -426,7 +419,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct WithExtensionImage : Image
struct WithExtensionImage : Image, mln::experimental::Image<WithExtensionImage>
{
struct Extension
{
......
......@@ -10,7 +10,6 @@
#include <mln/core/concept/new/values.hpp>
#include <mln/core/concept/new/archetype/value.hpp>
#include <mln/core/extension/extension_traits.hpp>
#include <mln/core/image/private/image_traits.hpp>
#include <mln/core/image/private/pixel_traits.hpp>
......@@ -21,6 +20,14 @@
#include <type_traits>
#include <utility>
namespace mln::experimental
{
template <typename I>
struct Image
{
};
}
namespace mln::concepts
{
......@@ -29,50 +36,50 @@ namespace mln::concepts
#ifdef PYLENE_CONCEPT_TS_ENABLED
// Image
template<typename Ima>
template<typename I>
concept Image =
// FIXME: inheritance from New_Image required for the moment
// Minimum constraint on image object
// Do not requires DefaultConstructible
stl::CopyConstructible<Ima> &&
stl::MoveConstructible<Ima> &&
stl::DerivedFrom<image_category_t<Ima>, forward_image_tag> &&
std::is_base_of_v<mln::experimental::Image<I>, I> &&
stl::CopyConstructible<I> &&
stl::MoveConstructible<I> &&
stl::DerivedFrom<image_category_t<I>, forward_image_tag> &&
requires {
typename image_pixel_t<Ima>;
typename image_point_t<Ima>;
typename image_value_t<Ima>;
typename image_domain_t<Ima>;
typename image_reference_t<Ima>;
typename image_concrete_t<Ima>;
typename image_ch_value_t<Ima, mln::archetypes::Value>;
typename image_pixel_t<I>;
typename image_point_t<I>;
typename image_value_t<I>;
typename image_domain_t<I>;
typename image_reference_t<I>;
typename image_concrete_t<I>;
typename image_ch_value_t<I, mln::archetypes::Value>;
// traits
typename image_indexable_t<Ima>;
typename image_accessible_t<Ima>;
typename image_extension_category_t<Ima>;
typename image_category_t<Ima>;
typename image_view_t<Ima>;
typename image_indexable_t<I>;
typename image_accessible_t<I>;
typename image_extension_category_t<I>;
typename image_category_t<I>;
typename image_view_t<I>;
} &&
Pixel<image_pixel_t<Ima>> &&
Point<image_point_t<Ima>> &&
Value<image_value_t<Ima>> &&
Domain<image_domain_t<Ima>> &&
stl::ConvertibleTo<pixel_point_t<image_pixel_t<Ima>>, image_point_t<Ima>> &&
stl::ConvertibleTo<pixel_reference_t<image_pixel_t<Ima>>, image_reference_t<Ima>> &&
Pixel<image_pixel_t<I>> &&
Point<image_point_t<I>> &&
Value<image_value_t<I>> &&
Domain<image_domain_t<I>> &&
stl::ConvertibleTo<pixel_point_t<image_pixel_t<I>>, image_point_t<I>> &&
stl::ConvertibleTo<pixel_reference_t<image_pixel_t<I>>, image_reference_t<I>> &&
// Here we don't want a convertible constraint as value_type is the decayed type and should really be the same
stl::Same<pixel_value_t<image_pixel_t<Ima>>, image_value_t<Ima>> &&
stl::CommonReference<image_reference_t<Ima>&&, image_value_t<Ima>&> &&
stl::CommonReference<image_reference_t<Ima>&&, image_value_t<Ima>&&> &&
stl::CommonReference<image_value_t<Ima>&&, const image_value_t<Ima>&> &&
requires(Ima ima, const Ima cima, image_domain_t<Ima> d, image_point_t<Ima> p) {
stl::Same<pixel_value_t<image_pixel_t<I>>, image_value_t<I>> &&
stl::CommonReference<image_reference_t<I>&&, image_value_t<I>&> &&
stl::CommonReference<image_reference_t<I>&&, image_value_t<I>&&> &&
stl::CommonReference<image_value_t<I>&&, const image_value_t<I>&> &&
requires(I ima, const I cima, image_domain_t<I> d, image_point_t<I> p) {
{ cima.template ch_value<mln::archetypes::Value>() }
-> stl::ConvertibleTo<image_ch_value_t<Ima, mln::archetypes::Value>>&&; // Image builder (FIXME: improve builder design)
{ cima.concretize() } -> stl::ConvertibleTo<image_concrete_t<Ima>>&&; // Image builder (FIXME: improve builder design)
{ cima.domain() } -> image_domain_t<Ima>;
-> stl::ConvertibleTo<image_ch_value_t<I, mln::archetypes::Value>>&&; // Image builder (FIXME: improve builder design)
{ cima.concretize() } -> stl::ConvertibleTo<image_concrete_t<I>>&&; // Image builder (FIXME: improve builder design)
{ cima.domain() } -> image_domain_t<I>;
{ ima.new_pixels() } -> stl::ForwardRange&&;
{ ima.new_values() } -> stl::ForwardRange&&;
requires detail::RangeValueTypeConvertibleTo<decltype(ima.new_pixels()), image_pixel_t<Ima>>;
requires detail::RangeValueTypeConvertibleTo<decltype(ima.new_values()), image_value_t<Ima>>;
requires detail::RangeValueTypeConvertibleTo<decltype(ima.new_pixels()), image_pixel_t<I>>;
requires detail::RangeValueTypeConvertibleTo<decltype(ima.new_values()), image_value_t<I>>;
};
......@@ -80,42 +87,42 @@ namespace mln::concepts
{
// WritableImage
template<typename WIma>
template<typename I>
concept WritableImage =
Image<WIma> &&
OutputPixel<image_pixel_t<WIma>> &&
requires(WIma ima) {
{ ima.new_values() } -> stl::OutputRange<image_value_t<WIma>>&&;
Image<I> &&
OutputPixel<image_pixel_t<I>> &&
requires(I ima) {
{ ima.new_values() } -> stl::OutputRange<image_value_t<I>>&&;
// Check Writability of each pixel of the range
requires OutputPixel<
std::common_type_t<
stl::iter_value_t<stl::iterator_t<decltype(ima.new_pixels())>>,
image_pixel_t<WIma>>>;
image_pixel_t<I>>>;
};
} // namespace detail
// InputImage
template <typename Ima>
concept InputImage = Image<Ima>;
template <typename I>
concept InputImage = Image<I>;
// ForwardImage
template <typename Ima>
concept ForwardImage = InputImage<Ima>;
template <typename I>
concept ForwardImage = InputImage<I>;
// IndexableImage
template <typename Ima>
template <typename I>
concept IndexableImage =
Image<Ima> &&
Image<I> &&
requires {
typename image_index_t<Ima>;
typename image_index_t<I>;
} &&
image_indexable_v<Ima> &&
requires (Ima ima, image_index_t<Ima> k) {
{ ima[k] } -> image_reference_t<Ima>; // For concrete image it returns a const_reference
image_indexable_v<I> &&
requires (I ima, image_index_t<I> k) {
{ ima[k] } -> image_reference_t<I>; // For concrete image it returns a const_reference
};
......@@ -123,27 +130,27 @@ namespace mln::concepts
{
// WritableIndexableImage
template<typename WIma>
template<typename I>
concept WritableIndexableImage =
WritableImage<WIma> &&
IndexableImage<WIma> &&
requires(WIma ima, image_index_t<WIma> k, image_value_t<WIma> v) {
{ ima[k] = v } -> image_reference_t<WIma>;
WritableImage<I> &&
IndexableImage<I> &&
requires(I ima, image_index_t<I> k, image_value_t<I> v) {
{ ima[k] = v } -> image_reference_t<I>;
};
} // namespace detail
// AccessibleImage
template <typename Ima>
template <typename I>
concept AccessibleImage =
Image<Ima> &&
image_accessible_v<Ima> &&
requires (Ima ima, image_point_t<Ima> p) {
{ ima(p) } -> image_reference_t<Ima>; // For concrete image it returns a const_reference
{ ima.at(p) } -> image_reference_t<Ima>; // idem
{ ima.new_pixel(p) } -> image_pixel_t<Ima>; // For concrete image pixel may propagate constness
{ ima.new_pixel_at(p) } -> image_pixel_t<Ima>; // idem
Image<I> &&
image_accessible_v<I> &&
requires (I ima, image_point_t<I> p) {
{ ima(p) } -> image_reference_t<I>; // For concrete image it returns a const_reference
{ ima.at(p) } -> image_reference_t<I>; // idem
{ ima.new_pixel(p) } -> image_pixel_t<I>; // For concrete image pixel may propagate constness
{ ima.new_pixel_at(p) } -> image_pixel_t<I>; // idem
};
......@@ -151,27 +158,27 @@ namespace mln::concepts
{
// WritableAccessibleImage
template<typename WIma>
template<typename I>
concept WritableAccessibleImage =
detail::WritableImage<WIma> &&
AccessibleImage<WIma> &&
requires(WIma ima, image_point_t<WIma> p, image_value_t<WIma> v) {
{ ima(p) = v } -> image_reference_t<WIma>;
{ ima.at(p) = v } -> image_reference_t<WIma>;
detail::WritableImage<I> &&
AccessibleImage<I> &&
requires(I ima, image_point_t<I> p, image_value_t<I> v) {
{ ima(p) = v } -> image_reference_t<I>;
{ ima.at(p) = v } -> image_reference_t<I>;
};
} // namespace detail
// IndexableAndAccessibleImage
template <typename Ima>
template <typename I>
concept IndexableAndAccessibleImage =
IndexableImage<Ima> &&
AccessibleImage<Ima> &&
requires (const Ima cima, image_index_t<Ima> k, image_point_t<Ima> p) {
{ cima.point_at_index(k) } -> image_point_t<Ima>;
{ cima.index_of_point(p) } -> image_index_t<Ima>;
{ cima.delta_index(p) } -> image_index_t<Ima>;
IndexableImage<I> &&
AccessibleImage<I> &&
requires (const I cima, image_index_t<I> k, image_point_t<I> p) {
{ cima.point_at_index(k) } -> image_point_t<I>;
{ cima.index_of_point(p) } -> image_index_t<I>;
{ cima.delta_index(p) } -> image_index_t<I>;
};
......@@ -179,21 +186,21 @@ namespace mln::concepts
{
// WritableIndexableAndAccessibleImage
template<typename WIma>
template<typename I>
concept WritableIndexableAndAccessibleImage =
IndexableAndAccessibleImage<WIma> &&
detail::WritableImage<WIma> &&
detail::WritableIndexableImage<WIma>;
IndexableAndAccessibleImage<I> &&
detail::WritableImage<I> &&
detail::WritableIndexableImage<I>;
} // namespace detail
// BidirectionalImage (not in STL term)
template <typename Ima>
template <typename I>
concept BidirectionalImage =
Image<Ima> &&
stl::DerivedFrom<image_category_t<Ima>, bidirectional_image_tag> &&
requires (Ima ima) {
Image<I> &&
stl::DerivedFrom<image_category_t<I>, bidirectional_image_tag> &&
requires (I ima) {
{ ima.new_pixels() } -> ReversibleRange&&;
{ ima.new_values() } -> ReversibleRange&&;
};
......@@ -203,22 +210,22 @@ namespace mln::concepts
{
// WritableBidirectionalImage
template<typename WIma>
template<typename I>
concept WritableBidirectionalImage =
WritableImage<WIma> &&
BidirectionalImage<WIma>;
WritableImage<I> &&
BidirectionalImage<I>;
} // namespace detail
// RawImage (not contiguous, stride = padding)
template <typename Ima>
template <typename I>
concept RawImage =
IndexableAndAccessibleImage<Ima> &&
BidirectionalImage<Ima> &&
stl::DerivedFrom<image_category_t<Ima>, raw_image_tag> &&
requires (Ima ima, const Ima cima, int dim) {
{ ima.data() } -> stl::ConvertibleTo<const image_value_t<Ima>*>&&; // data() may be proxied by a view
IndexableAndAccessibleImage<I> &&
BidirectionalImage<I> &&
stl::DerivedFrom<image_category_t<I>, raw_image_tag> &&
requires (I ima, const I cima, int dim) {
{ ima.data() } -> stl::ConvertibleTo<const image_value_t<I>*>&&; // data() may be proxied by a view
{ cima.strides(dim) } -> std::ptrdiff_t;
};
......@@ -227,59 +234,59 @@ namespace mln::concepts
{
// WritableRawImage
template<typename WIma>
template<typename I>
concept WritableRawImage =
WritableImage<WIma> &&
WritableIndexableAndAccessibleImage<WIma> &&
WritableBidirectionalImage<WIma> &&
RawImage<WIma> &&
requires(WIma ima, image_value_t<WIma> v) {
{ ima.data() } -> stl::ConvertibleTo<image_value_t<WIma>*>&&;
WritableImage<I> &&
WritableIndexableAndAccessibleImage<I> &&
WritableBidirectionalImage<I> &&