pixel_based.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 "-Wunused-local-typedefs"
  19. #endif
  20. #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
  21. #pragma GCC diagnostic push
  22. #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
  23. #endif
  24. namespace boost { namespace gil {
  25. /// \ingroup PixelBasedConcept
  26. /// \brief Concept for all pixel-based GIL constructs.
  27. ///
  28. /// Pixel-based constructs include pixels, iterators, locators, views and
  29. /// images whose value type is a pixel.
  30. ///
  31. /// \code
  32. /// concept PixelBasedConcept<typename T>
  33. /// {
  34. /// typename color_space_type<T>;
  35. /// where Metafunction<color_space_type<T> >;
  36. /// where ColorSpaceConcept<color_space_type<T>::type>;
  37. /// typename channel_mapping_type<T>;
  38. /// where Metafunction<channel_mapping_type<T> >;
  39. /// where ChannelMappingConcept<channel_mapping_type<T>::type>;
  40. /// typename is_planar<T>;
  41. /// where Metafunction<is_planar<T> >;
  42. /// where SameType<is_planar<T>::type, bool>;
  43. /// };
  44. /// \endcode
  45. template <typename P>
  46. struct PixelBasedConcept
  47. {
  48. void constraints()
  49. {
  50. using color_space_t = typename color_space_type<P>::type;
  51. gil_function_requires<ColorSpaceConcept<color_space_t>>();
  52. using channel_mapping_t = typename channel_mapping_type<P>::type ;
  53. gil_function_requires<ChannelMappingConcept<channel_mapping_t>>();
  54. static const bool planar = is_planar<P>::value;
  55. ignore_unused_variable_warning(planar);
  56. // This is not part of the concept, but should still work
  57. static const std::size_t nc = num_channels<P>::value;
  58. ignore_unused_variable_warning(nc);
  59. }
  60. };
  61. /// \brief Concept for homogeneous pixel-based GIL constructs
  62. /// \ingroup PixelBasedConcept
  63. /// \code
  64. /// concept HomogeneousPixelBasedConcept<PixelBasedConcept T>
  65. /// {
  66. /// typename channel_type<T>;
  67. /// where Metafunction<channel_type<T>>;
  68. /// where ChannelConcept<channel_type<T>::type>;
  69. /// };
  70. /// \endcode
  71. template <typename P>
  72. struct HomogeneousPixelBasedConcept
  73. {
  74. void constraints()
  75. {
  76. gil_function_requires<PixelBasedConcept<P>>();
  77. using channel_t = typename channel_type<P>::type;
  78. gil_function_requires<ChannelConcept<channel_t>>();
  79. }
  80. };
  81. }} // namespace boost::gil
  82. #if defined(BOOST_CLANG)
  83. #pragma clang diagnostic pop
  84. #endif
  85. #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
  86. #pragma GCC diagnostic pop
  87. #endif
  88. #endif