pixel_based.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // Copyright 2005-2007 Adobe Systems Incorporated
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #ifndef BOOST_GIL_CONCEPTS_PIXEL_BASED_HPP
  9. #define BOOST_GIL_CONCEPTS_PIXEL_BASED_HPP
  10. #include <boost/gil/concepts/basic.hpp>
  11. #include <boost/gil/concepts/channel.hpp>
  12. #include <boost/gil/concepts/color.hpp>
  13. #include <boost/gil/concepts/concept_check.hpp>
  14. #include <boost/gil/concepts/fwd.hpp>
  15. #include <cstddef>
  16. #if defined(BOOST_CLANG)
  17. #pragma clang diagnostic push
  18. #pragma clang diagnostic ignored "-Wunknown-pragmas"
  19. #pragma clang diagnostic ignored "-Wunused-local-typedefs"
  20. #endif
  21. #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
  22. #pragma GCC diagnostic push
  23. #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
  24. #endif
  25. namespace boost { namespace gil {
  26. /// \ingroup PixelBasedConcept
  27. /// \brief Concept for all pixel-based GIL constructs.
  28. ///
  29. /// Pixel-based constructs include pixels, iterators, locators, views and
  30. /// images whose value type is a pixel.
  31. ///
  32. /// \code
  33. /// concept PixelBasedConcept<typename T>
  34. /// {
  35. /// typename color_space_type<T>;
  36. /// where Metafunction<color_space_type<T> >;
  37. /// where ColorSpaceConcept<color_space_type<T>::type>;
  38. /// typename channel_mapping_type<T>;
  39. /// where Metafunction<channel_mapping_type<T> >;
  40. /// where ChannelMappingConcept<channel_mapping_type<T>::type>;
  41. /// typename is_planar<T>;
  42. /// where Metafunction<is_planar<T> >;
  43. /// where SameType<is_planar<T>::type, bool>;
  44. /// };
  45. /// \endcode
  46. template <typename P>
  47. struct PixelBasedConcept
  48. {
  49. void constraints()
  50. {
  51. using color_space_t = typename color_space_type<P>::type;
  52. gil_function_requires<ColorSpaceConcept<color_space_t>>();
  53. using channel_mapping_t = typename channel_mapping_type<P>::type ;
  54. gil_function_requires<ChannelMappingConcept<channel_mapping_t>>();
  55. static const bool planar = is_planar<P>::value;
  56. ignore_unused_variable_warning(planar);
  57. // This is not part of the concept, but should still work
  58. static const std::size_t nc = num_channels<P>::value;
  59. ignore_unused_variable_warning(nc);
  60. }
  61. };
  62. /// \brief Concept for homogeneous pixel-based GIL constructs
  63. /// \ingroup PixelBasedConcept
  64. /// \code
  65. /// concept HomogeneousPixelBasedConcept<PixelBasedConcept T>
  66. /// {
  67. /// typename channel_type<T>;
  68. /// where Metafunction<channel_type<T>>;
  69. /// where ChannelConcept<channel_type<T>::type>;
  70. /// };
  71. /// \endcode
  72. template <typename P>
  73. struct HomogeneousPixelBasedConcept
  74. {
  75. void constraints()
  76. {
  77. gil_function_requires<PixelBasedConcept<P>>();
  78. using channel_t = typename channel_type<P>::type;
  79. gil_function_requires<ChannelConcept<channel_t>>();
  80. }
  81. };
  82. }} // namespace boost::gil
  83. #if defined(BOOST_CLANG)
  84. #pragma clang diagnostic pop
  85. #endif
  86. #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
  87. #pragma GCC diagnostic pop
  88. #endif
  89. #endif