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

Write writable archetypes for images

Fix archetypes name + writable concepts
parent 6cfbc4de
......@@ -4,13 +4,13 @@
#include <mln/core/concept/new/domains.hpp>
namespace mln::concepts::archetype
namespace mln::archetypes
{
struct domain_archetype final
struct Domain final
{
using value_type = point_archetype;
using reference = point_archetype&;
using value_type = Point;
using reference = Point&;
value_type* begin();
value_type* end();
......@@ -21,7 +21,7 @@ namespace mln::concepts::archetype
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(Domain<domain_archetype>, "domain_archetype does not model the Domain concept!");
static_assert(mln::concepts::Domain<Domain>, "Domain archetype does not model the Domain concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::concepts::archetype
} // namespace mln::archetypes
......@@ -11,37 +11,35 @@
#include <type_traits>
namespace mln::concepts::archetype
namespace mln::archetypes
{
struct image_archetype;
struct Image;
struct image_archetype final
struct Image
{
using new_pixel_type = pixel_archetype;
using value_type = pixel_value_t<pixel_archetype>;
using reference = pixel_reference_t<pixel_archetype>;
using new_point_type = domain_point_t<domain_archetype>;
using domain_type = domain_archetype;
using new_pixel_type = Pixel;
using value_type = pixel_value_t<Pixel>;
using reference = pixel_reference_t<Pixel>;
using new_point_type = domain_point_t<Domain>;
using domain_type = Domain;
using category_type = forward_image_tag;
using concrete_type = image_archetype;
using concrete_type = Image;
#ifdef PYLENE_CONCEPT_TS_ENABLED
template <Value Val>
template <mln::concepts::Value Val>
#else
template <typename Val>
#endif // PYLENE_CONCEPT_TS_ENABLED
using ch_value_type = image_archetype;
using ch_value_type = Image;
// additional traits
using extension_category = mln::extension::none_extension_tag;
using indexable = std::false_type;
using accessible = std::false_type;
using bidirectional = std::false_type;
using raw = std::false_type;
#ifdef PYLENE_CONCEPT_TS_ENABLED
template <Value Val>
template <mln::concepts::Value Val>
#else
template <typename Val>
#endif // PYLENE_CONCEPT_TS_ENABLED
......@@ -50,30 +48,274 @@ namespace mln::concepts::archetype
domain_type domain() const;
struct pixel_range_archetype final
struct PixelRange
{
using value_type = new_pixel_type;
using reference = new_pixel_type&;
using value_type = image_pixel_t<Image>;
using reference = image_pixel_t<Image>&;
new_pixel_type* begin();
new_pixel_type* end();
};
PixelRange new_pixels();
struct ValueRange
{
using value_type = image_value_t<Image>;
using reference = image_reference_t<Image>;
image_value_t<Image>* begin();
image_value_t<Image>* end();
};
ValueRange new_values();
};
#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 final : Image
{
using new_pixel_type = OutputPixel;
struct OutputPixelRange final
{
using value_type = image_pixel_t<OutputImage>;
using reference = image_pixel_t<OutputImage>&;
new_pixel_type* begin();
new_pixel_type* end();
};
OutputPixelRange new_pixels();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::Image<OutputImage> && mln::concepts::OutputImage<OutputImage>,
"OuputImage archetype does not model the OuputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct 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
{
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::ForwardImage<ForwardImage>,
"ForwardImage archetype does not model the ForwardImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct IndexableImage : Image
{
using index_type = int;
using indexable = std::true_type;
image_reference_t<IndexableImage> operator[](image_index_t<IndexableImage>) const;
image_point_t<IndexableImage> point_of_index(image_index_t<IndexableImage>) const;
image_index_t<IndexableImage> index_at_point(image_point_t<IndexableImage>) const;
image_index_t<IndexableImage> delta_index(image_point_t<IndexableImage>) const;
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::IndexableImage<IndexableImage>,
"IndexableImage archetype does not model the IndexableImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputIndexableImage final : IndexableImage
{
using IndexableImage:: operator[];
image_reference_t<OutputIndexableImage> operator[](image_index_t<OutputIndexableImage>);
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::IndexableImage<OutputIndexableImage> && mln::concepts::OutputImage<OutputIndexableImage>,
"OutputIndexableImage archetype does not model the OutputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct AccessibleImage : Image
{
using accessible = std::true_type;
image_reference_t<AccessibleImage> operator()(image_point_t<AccessibleImage>) const;
image_reference_t<AccessibleImage> at(image_point_t<AccessibleImage>) const;
image_pixel_t<AccessibleImage> new_pixel(image_point_t<AccessibleImage>) const;
image_pixel_t<AccessibleImage> new_pixel_at(image_point_t<AccessibleImage>) const;
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::AccessibleImage<AccessibleImage>,
"AccessibleImage archetype does not model the AccessibleImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputAccessibleImage final : AccessibleImage
{
using AccessibleImage:: operator();
image_reference_t<OutputAccessibleImage> operator[](image_point_t<OutputAccessibleImage>);
using AccessibleImage::at;
image_reference_t<OutputAccessibleImage> at(image_point_t<OutputAccessibleImage>);
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::AccessibleImage<OutputAccessibleImage> &&
mln::concepts::OutputImage<OutputAccessibleImage>,
"OutputAccessibleImage archetype does not model the OutputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct BidirectionalImage : Image
{
using category_type = bidirectional_image_tag;
struct ReversiblePixelRange final : Image::PixelRange
{
Image::PixelRange reversed();
};
ReversiblePixelRange new_pixels();
struct ReversibleValueRange final : Image::ValueRange
{
Image::ValueRange reversed();
};
ReversibleValueRange new_values();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::BidirectionalImage<BidirectionalImage>,
"BidirectionalImage archetype does not model the BidirectionalImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputBidirectionalImage : BidirectionalImage
{
using new_pixel_type = OutputPixel;
struct OutputPixelRange
{
using value_type = image_pixel_t<OutputBidirectionalImage>;
using reference = image_pixel_t<OutputBidirectionalImage>&;
new_pixel_type* begin();
new_pixel_type* end();
};
pixel_range_archetype new_pixels();
struct ReversibleOutputPixelRange final : OutputPixelRange
{
OutputPixelRange reversed();
};
ReversibleOutputPixelRange new_pixels();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::BidirectionalImage<OutputBidirectionalImage> &&
mln::concepts::OutputImage<OutputBidirectionalImage>,
"OutputBidirectionalImage archetype does not model the OutputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct value_range_archetype final
struct RawImage : Image
{
using category_type = raw_image_tag;
using index_type = int;
using indexable = std::true_type;
using accessible = std::true_type;
image_reference_t<RawImage> operator[](image_index_t<RawImage>) const;
image_point_t<RawImage> point_of_index(image_index_t<RawImage>) const;
image_index_t<RawImage> index_at_point(image_point_t<RawImage>) const;
image_index_t<RawImage> delta_index(image_point_t<RawImage>) const;
image_reference_t<RawImage> operator()(image_point_t<RawImage>) const;
image_reference_t<RawImage> at(image_point_t<RawImage>) const;
image_pixel_t<RawImage> new_pixel(image_point_t<RawImage>) const;
image_pixel_t<RawImage> new_pixel_at(image_point_t<RawImage>) const;
struct ReversiblePixelRange final : Image::PixelRange
{
Image::PixelRange reversed();
};
ReversiblePixelRange new_pixels();
struct ReversibleValueRange final : Image::ValueRange
{
Image::ValueRange reversed();
};
ReversibleValueRange new_values();
const image_value_t<RawImage>* data() const;
std::size_t strides(int) const;
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::RawImage<RawImage>, "RawImage archetype does not model the RawImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputRawImage final : RawImage
{
using new_pixel_type = OutputPixel;
using RawImage:: operator[];
image_reference_t<OutputRawImage> operator[](image_index_t<OutputRawImage>);
using RawImage:: operator();
image_reference_t<OutputRawImage> operator[](image_point_t<OutputRawImage>);
using RawImage::at;
image_reference_t<OutputRawImage> at(image_point_t<OutputRawImage>);
// Need to be redefined as pixel_type has changed
image_pixel_t<OutputRawImage> new_pixel(image_point_t<OutputRawImage>) const;
image_pixel_t<OutputRawImage> new_pixel_at(image_point_t<OutputRawImage>) const;
struct OutputPixelRange
{
using value_type = image_value_t<image_archetype>;
using reference = image_reference_t<image_archetype>;
image_value_t<image_archetype>* begin();
image_value_t<image_archetype>* end();
using value_type = image_pixel_t<OutputRawImage>;
using reference = image_pixel_t<OutputRawImage>&;
new_pixel_type* begin();
new_pixel_type* end();
};
struct ReversibleOutputPixelRange final : OutputPixelRange
{
OutputPixelRange reversed();
};
value_range_archetype new_values();
ReversibleOutputPixelRange new_pixels();
using RawImage::data;
image_value_t<OutputRawImage>* data();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(Image<image_archetype>, "image_archetype does not model the Image concept!");
#endif // #ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::RawImage<OutputRawImage> && mln::concepts::OutputImage<OutputRawImage>,
"OutputRawImage archetype does not model the OutputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::concepts::archetype
\ No newline at end of file
} // namespace mln::archetypes
......@@ -3,13 +3,13 @@
#include <mln/core/concept/new/indexes.hpp>
namespace mln::concepts::archetype
namespace mln::archetypes
{
using index_archetype = int;
using Index = int;
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(Index<index_archetype>, "index_archetype does not model the Index concept!");
static_assert(mln::concepts::Index<Index>, "Index archetype does not model the Index concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::concepts::archetype
} // namespace mln::archetypes
......@@ -5,24 +5,36 @@
#include <mln/core/concept/new/pixels.hpp>
namespace mln::concepts::archetype
namespace mln::archetypes
{
struct pixel_archetype final
struct Pixel
{
using value_type = value_archetype;
using point_type = point_archetype;
using reference = value_archetype&;
using value_type = Value;
using point_type = Point;
using reference = Value&;
point_type point() const;
reference val() const;
};
bool operator==(const pixel_archetype& lhs, const pixel_archetype& rhs);
bool operator!=(const pixel_archetype& lhs, const pixel_archetype& rhs);
bool operator==(const Pixel& lhs, const Pixel& rhs);
bool operator!=(const Pixel& lhs, const Pixel& rhs);
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(Pixel<pixel_archetype>, "pixel_archetype does not model the Pixel concept!");
static_assert(mln::concepts::Pixel<Pixel>, "Pixel archetype does not model the Pixel concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::concepts::archetype
struct OutputPixel final : Pixel
{
using Pixel::val;
reference val();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::OutputPixel<OutputPixel>,
"OutputPixel archetype does not model the OutputPixel concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::archetypes
......@@ -3,22 +3,22 @@
#include <mln/core/concept/new/points.hpp>
namespace mln::concepts::archetype
namespace mln::archetypes
{
struct point_archetype final
struct Point final
{
};
bool operator==(const point_archetype&, const point_archetype&);
bool operator!=(const point_archetype&, const point_archetype&);
bool operator<(const point_archetype&, const point_archetype&);
bool operator>(const point_archetype&, const point_archetype&);
bool operator<=(const point_archetype&, const point_archetype&);
bool operator>=(const point_archetype&, const point_archetype&);
bool operator==(const Point&, const Point&);
bool operator!=(const Point&, const Point&);
bool operator<(const Point&, const Point&);
bool operator>(const Point&, const Point&);
bool operator<=(const Point&, const Point&);
bool operator>=(const Point&, const Point&);
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(Point<point_archetype>, "point_archetype does not model the Point concept!");
static_assert(mln::concepts::Point<Point>, "Point archetype does not model the Point concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::concepts::archetype
} // namespace mln::archetypes
......@@ -3,77 +3,77 @@
#include <mln/core/concept/new/archetype/value.hpp>
#include <mln/core/concept/new/ranges.hpp>
namespace mln::concepts::archetype
namespace mln::archetypes
{
namespace detail
{
struct randomaccess_range_archetype
struct RandomAccessRange
{
using value_type = value_archetype;
using reference = value_archetype&;
using value_type = Value;
using reference = Value&;
value_type* begin();
value_type* end();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(stl::RandomAccessRange<randomaccess_range_archetype>,
"randomaccess_range_archetype does not model the stl::RandomAccessRange concept!");
static_assert(mln::concepts::stl::RandomAccessRange<RandomAccessRange>,
"RandomAccessRange archetype does not model the stl::RandomAccessRange concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace detail
struct segmented_range_archetype final : detail::randomaccess_range_archetype
struct SegmentedRange final : detail::RandomAccessRange
{
struct nested_segmented_range_archetype final
struct NestedSegmentedRange final
{
using value_type = detail::randomaccess_range_archetype;
using reference = detail::randomaccess_range_archetype&;
using value_type = detail::RandomAccessRange;
using reference = detail::RandomAccessRange&;
detail::randomaccess_range_archetype* begin();
detail::randomaccess_range_archetype* end();
detail::RandomAccessRange* begin();
detail::RandomAccessRange* end();
};
nested_segmented_range_archetype rows();
NestedSegmentedRange rows();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(SegmentedRange<segmented_range_archetype>,
"segmented_range_archetype does not model the SegmentedRange concept!");
static_assert(mln::concepts::SegmentedRange<SegmentedRange>,
"SegmentedRange archetype does not model the SegmentedRange concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct reversible_range_archetype final : detail::randomaccess_range_archetype
struct ReversibleRange final : detail::RandomAccessRange
{
detail::randomaccess_range_archetype reversed();
detail::RandomAccessRange reversed();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(ReversibleRange<reversible_range_archetype>,
static_assert(mln::concepts::ReversibleRange<ReversibleRange>,
"reversible_range_archetype does not model the ReversibleRange concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct segmented_and_reversible_range_archetype final : detail::randomaccess_range_archetype
struct SegmentedAndReversibleRange final : detail::RandomAccessRange
{
struct nested_segmented_range_archetype final
struct NestedSegmentedRange final
{
using value_type = detail::randomaccess_range_archetype;
using reference = detail::randomaccess_range_archetype&;
detail::randomaccess_range_archetype* begin();
detail::randomaccess_range_archetype* end();
using value_type = detail::RandomAccessRange;
using reference = detail::RandomAccessRange&;
detail::RandomAccessRange* begin();
detail::RandomAccessRange* end();
};
nested_segmented_range_archetype rows();
detail::randomaccess_range_archetype reversed();
NestedSegmentedRange rows();
detail::RandomAccessRange reversed();
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(SegmentedRange<segmented_and_reversible_range_archetype>,
"segmented_and_reversible_range_archetype does not model the SegmentedRange concept!");
static_assert(ReversibleRange<segmented_and_reversible_range_archetype>,
"segmented_and_reversible_range_archetype does not model the ReversibleRange concept!");
static_assert(mln::concepts::SegmentedRange<SegmentedAndReversibleRange>,
"SegmentedAndReversibleRange archetype does not model the SegmentedRange concept!");
static_assert(mln::concepts::ReversibleRange<SegmentedAndReversibleRange>,
"SegmentedAndReversibleRange archetype does not model the ReversibleRange concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::concepts::archetype
} // namespace mln::archetypes
<
......@@ -3,43 +3,43 @@
#include <mln/core/concept/new/values.hpp>
namespace mln::concepts::archetype
namespace mln::archetypes
{
struct value_archetype final
struct Value final
{
};