annotate DEPENDENCIES/generic/include/boost/gil/extension/io/dynamic_io.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright 2005-2007 Adobe Systems Incorporated
Chris@16 3
Chris@16 4 Use, modification and distribution are subject to the Boost Software License,
Chris@16 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 http://www.boost.org/LICENSE_1_0.txt).
Chris@16 7
Chris@16 8 See http://opensource.adobe.com/gil for most recent version including documentation.
Chris@16 9 */
Chris@16 10 /*************************************************************************************************/
Chris@16 11
Chris@16 12 #ifndef GIL_DYNAMIC_IO_H
Chris@16 13 #define GIL_DYNAMIC_IO_H
Chris@16 14
Chris@16 15 /// \file
Chris@16 16 /// \brief Generic io functions for dealing with dynamic images
Chris@16 17 //
Chris@16 18 /// \author Hailin Jin and Lubomir Bourdev \n
Chris@16 19 /// Adobe Systems Incorporated
Chris@16 20 /// \date 2005-2007 \n Last updated May 30, 2006
Chris@16 21
Chris@16 22 #include <boost/mpl/at.hpp>
Chris@16 23 #include <boost/mpl/size.hpp>
Chris@16 24 #include "../../gil_config.hpp"
Chris@16 25 #include "io_error.hpp"
Chris@16 26 #include "../dynamic_image/any_image.hpp"
Chris@16 27
Chris@16 28 namespace boost { namespace gil {
Chris@16 29
Chris@16 30 namespace detail {
Chris@16 31
Chris@16 32 template <long N>
Chris@16 33 struct construct_matched_t {
Chris@16 34 template <typename Images,typename Pred>
Chris@16 35 static bool apply(any_image<Images>& im,Pred pred) {
Chris@16 36 if (pred.template apply<typename mpl::at_c<Images,N-1>::type>()) {
Chris@16 37 typename mpl::at_c<Images,N-1>::type x;
Chris@16 38 im.move_in(x);
Chris@16 39 return true;
Chris@16 40 } else return construct_matched_t<N-1>::apply(im,pred);
Chris@16 41 }
Chris@16 42 };
Chris@16 43 template <>
Chris@16 44 struct construct_matched_t<0> {
Chris@16 45 template <typename Images,typename Pred>
Chris@16 46 static bool apply(any_image<Images>&,Pred) {return false;}
Chris@16 47 };
Chris@16 48
Chris@16 49 // A function object that can be passed to apply_operation.
Chris@16 50 // Given a predicate IsSupported taking a view type and returning an MPL boolean,
Chris@16 51 // calls the apply method of OpClass with the view if the given view IsSupported, or throws an exception otherwise
Chris@16 52 template <typename IsSupported, typename OpClass>
Chris@16 53 class dynamic_io_fnobj {
Chris@16 54 OpClass* _op;
Chris@16 55
Chris@16 56 template <typename View>
Chris@16 57 void apply(const View& view,mpl::true_ ) {_op->apply(view);}
Chris@16 58 template <typename View>
Chris@16 59 void apply(const View& view,mpl::false_) {io_error("dynamic_io: unsupported view type for the given file format");}
Chris@16 60 public:
Chris@16 61 dynamic_io_fnobj(OpClass* op) : _op(op) {}
Chris@16 62
Chris@16 63 typedef void result_type;
Chris@16 64
Chris@16 65 template <typename View>
Chris@16 66 void operator()(const View& view) {apply(view,typename IsSupported::template apply<View>::type());}
Chris@16 67 };
Chris@16 68
Chris@16 69 } // namespace detail
Chris@16 70
Chris@16 71 /// \brief Within the any_image, constructs an image with the given dimensions
Chris@16 72 /// and a type that satisfies the given predicate
Chris@16 73 template <typename Images,typename Pred>
Chris@16 74 inline bool construct_matched(any_image<Images>& im,Pred pred) {
Chris@16 75 return detail::construct_matched_t<mpl::size<Images>::value>::apply(im,pred);
Chris@16 76 }
Chris@16 77
Chris@16 78 } } // namespace boost::gil
Chris@16 79
Chris@16 80 #endif