]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/gil/extension/dynamic_image/any_image_view.hpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / boost / gil / extension / dynamic_image / any_image_view.hpp
CommitLineData
7c673cae
FG
1/*
2 Copyright 2005-2007 Adobe Systems Incorporated
3
4 Use, modification and distribution are subject to the Boost Software License,
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
7
8 See http://opensource.adobe.com/gil for most recent version including documentation.
9*/
10
11/*************************************************************************************************/
12
13#ifndef GIL_DYNAMICIMAGE_ANY_IMAGEVIEW_HPP
14#define GIL_DYNAMICIMAGE_ANY_IMAGEVIEW_HPP
15
16////////////////////////////////////////////////////////////////////////////////////////
17/// \file
18/// \brief Support for run-time instantiated image view
19/// \author Lubomir Bourdev and Hailin Jin \n
20/// Adobe Systems Incorporated
21///
22///
23////////////////////////////////////////////////////////////////////////////////////////
24
25#include "variant.hpp"
26#include "../../image_view.hpp"
27#include "../../image.hpp"
28
29namespace boost { namespace gil {
30
31namespace detail {
32 template <typename View> struct get_const_t { typedef typename View::const_t type; };
33 template <typename Views> struct views_get_const_t : public mpl::transform<Views, get_const_t<mpl::_1> > {};
34}
35template <typename View> struct dynamic_xy_step_type;
36template <typename View> struct dynamic_xy_step_transposed_type;
37
38namespace detail {
39 struct any_type_get_num_channels { // works for both image_view and image
40 typedef int result_type;
41 template <typename T> result_type operator()(const T& v) const { return num_channels<T>::value; }
42 };
43 struct any_type_get_dimensions { // works for both image_view and image
44 typedef point2<std::ptrdiff_t> result_type;
45 template <typename T> result_type operator()(const T& v) const { return v.dimensions(); }
46 };
47}
48
49////////////////////////////////////////////////////////////////////////////////////////
50/// CLASS any_image_view
51///
52/// \ingroup ImageViewModel
53/// \brief Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeConcept, Note that this class does NOT model ImageViewConcept
54///
55/// Represents a view whose type (color space, layout, planar/interleaved organization, etc) can be specified at run time.
56/// It is the runtime equivalent of \p image_view.
57/// Some of the requirements of ImageViewConcept, such as the \p value_type typedef cannot be fulfilled, since the language does not allow runtime type specification.
58/// Other requirements, such as access to the pixels, would be inefficient to provide. Thus \p any_image_view does not fully model ImageViewConcept.
59/// However, many algorithms provide overloads taking runtime specified views and thus in many cases \p any_image_view can be used in places taking a view.
60///
61/// To perform an algorithm on any_image_view, put the algorithm in a function object and invoke it by calling \p apply_operation(runtime_view, algorithm_fn);
62////////////////////////////////////////////////////////////////////////////////////////
63template <typename ImageViewTypes>
64class any_image_view : public variant<ImageViewTypes> {
65 typedef variant<ImageViewTypes> parent_t;
66public:
67 typedef any_image_view<typename detail::views_get_const_t<ImageViewTypes>::type> const_t;
68 typedef std::ptrdiff_t x_coord_t;
69 typedef std::ptrdiff_t y_coord_t;
70 typedef point2<std::ptrdiff_t> point_t;
71
72 any_image_view() : parent_t() {}
73 template <typename T> explicit any_image_view(const T& obj) : parent_t(obj) {}
74 any_image_view(const any_image_view& v) : parent_t((const parent_t&)v) {}
75
76 template <typename T> any_image_view& operator=(const T& obj) { parent_t::operator=(obj); return *this; }
77 any_image_view& operator=(const any_image_view& v) { parent_t::operator=((const parent_t&)v); return *this;}
78
79 std::size_t num_channels() const { return apply_operation(*this, detail::any_type_get_num_channels()); }
80 point_t dimensions() const { return apply_operation(*this, detail::any_type_get_dimensions()); }
81 x_coord_t width() const { return dimensions().x; }
82 y_coord_t height() const { return dimensions().y; }
83};
84
85/////////////////////////////
86// HasDynamicXStepTypeConcept
87/////////////////////////////
88
89template <typename IVTypes>
90struct dynamic_x_step_type<any_image_view<IVTypes> > {
91 typedef any_image_view<typename mpl::transform<IVTypes, dynamic_x_step_type<mpl::_1> >::type> type;
92};
93
94/////////////////////////////
95// HasDynamicYStepTypeConcept
96/////////////////////////////
97
98template <typename IVTypes>
99struct dynamic_y_step_type<any_image_view<IVTypes> > {
100 typedef any_image_view<typename mpl::transform<IVTypes, dynamic_y_step_type<mpl::_1> >::type> type;
101};
102
103template <typename IVTypes>
104struct dynamic_xy_step_type<any_image_view<IVTypes> > {
105 typedef any_image_view<typename mpl::transform<IVTypes, dynamic_xy_step_type<mpl::_1> >::type> type;
106};
107
108template <typename IVTypes>
109struct dynamic_xy_step_transposed_type<any_image_view<IVTypes> > {
110 typedef any_image_view<typename mpl::transform<IVTypes, dynamic_xy_step_transposed_type<mpl::_1> >::type> type;
111};
112
113} } // namespace boost::gil
114
115#endif