get_writer.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. Copyright 2012 Christian Henning
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. */
  7. /*************************************************************************************************/
  8. #ifndef BOOST_GIL_IO_GET_WRITER_HPP
  9. #define BOOST_GIL_IO_GET_WRITER_HPP
  10. ////////////////////////////////////////////////////////////////////////////////////////
  11. /// \file
  12. /// \brief
  13. /// \author Christian Henning \n
  14. ///
  15. /// \date 2012 \n
  16. ///
  17. ////////////////////////////////////////////////////////////////////////////////////////
  18. #include "get_write_device.hpp"
  19. namespace boost { namespace gil {
  20. /// \brief Helper metafunction to generate writer type.
  21. template< typename T
  22. , typename FormatTag
  23. , class Enable = void
  24. >
  25. struct get_writer
  26. {};
  27. template< typename String
  28. , typename FormatTag
  29. >
  30. struct get_writer< String
  31. , FormatTag
  32. , typename enable_if< mpl::and_< detail::is_supported_path_spec< String >
  33. , is_format_tag< FormatTag >
  34. >
  35. >::type
  36. >
  37. {
  38. typedef typename get_write_device< String
  39. , FormatTag
  40. >::type device_t;
  41. typedef writer< device_t
  42. , FormatTag
  43. > type;
  44. };
  45. template< typename Device
  46. , typename FormatTag
  47. >
  48. struct get_writer< Device
  49. , FormatTag
  50. , typename enable_if< mpl::and_< detail::is_adaptable_output_device< FormatTag
  51. , Device
  52. >
  53. , is_format_tag< FormatTag >
  54. >
  55. >::type
  56. >
  57. {
  58. typedef typename get_write_device< Device
  59. , FormatTag
  60. >::type device_t;
  61. typedef writer< device_t
  62. , FormatTag
  63. > type;
  64. };
  65. /// \brief Helper metafunction to generate dynamic image writer type.
  66. template< typename T
  67. , typename FormatTag
  68. , class Enable = void
  69. >
  70. struct get_dynamic_image_writer
  71. {};
  72. template< typename String
  73. , typename FormatTag
  74. >
  75. struct get_dynamic_image_writer< String
  76. , FormatTag
  77. , typename enable_if< mpl::and_< detail::is_supported_path_spec< String >
  78. , is_format_tag< FormatTag >
  79. >
  80. >::type
  81. >
  82. {
  83. typedef typename get_write_device< String
  84. , FormatTag
  85. >::type device_t;
  86. typedef dynamic_image_writer< device_t
  87. , FormatTag
  88. > type;
  89. };
  90. template< typename Device
  91. , typename FormatTag
  92. >
  93. struct get_dynamic_image_writer< Device
  94. , FormatTag
  95. , typename enable_if< mpl::and_< detail::is_write_device< FormatTag
  96. , Device
  97. >
  98. , is_format_tag< FormatTag >
  99. >
  100. >::type
  101. >
  102. {
  103. typedef typename get_write_device< Device
  104. , FormatTag
  105. >::type device_t;
  106. typedef dynamic_image_writer< device_t
  107. , FormatTag
  108. > type;
  109. };
  110. } // namespace gil
  111. } // namespace boost
  112. #endif