00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GIL_DYNAMICIMAGE_ANY_IMAGE_FACTORY_HPP
00010 #define GIL_DYNAMICIMAGE_ANY_IMAGE_FACTORY_HPP
00011
00020
00021 #include "type_vector.hpp"
00022 #include "../../core/metafunctions.hpp"
00023
00024 ADOBE_GIL_NAMESPACE_BEGIN
00025
00027
00028
00030
00031 namespace detail {
00032 typedef boost::mpl::vector<boost::mpl::false_> vec_false_t;
00033 typedef boost::mpl::vector<boost::mpl::true_> vec_true_t;
00034 typedef boost::mpl::vector<boost::mpl::false_, boost::mpl::true_> vec_false_true_t;
00035 }
00036
00037 typedef detail::vec_false_t kInterleavedOnly;
00038 typedef detail::vec_true_t kPlanarOnly;
00039 typedef detail::vec_false_true_t kInterleavedAndPlanar;
00040
00041 typedef detail::vec_false_t kNonStepOnly;
00042 typedef detail::vec_true_t kStepOnly;
00043 typedef detail::vec_false_true_t kNonStepAndStep;
00044
00050
00051 template <typename CHAN_VEC, typename CS_VEC, typename ORDER_VEC, typename STEP_VEC, bool MUTABLE>
00052 struct cross_vector_image_view_types {
00053
00054 struct generate_fn {
00055 template <typename ELEMENTS>
00056 struct apply {
00057 typedef typename view_type<typename boost::mpl::at_c<ELEMENTS,0>::type,
00058 typename boost::mpl::at_c<ELEMENTS,1>::type,
00059 boost::mpl::at_c<ELEMENTS,2>::type::value,
00060 boost::mpl::at_c<ELEMENTS,3>::type::value,
00061 MUTABLE
00062 >::type type;
00063 };
00064 };
00065
00066 typedef boost::mpl::cross_vector<boost::mpl::vector4<CHAN_VEC, CS_VEC, ORDER_VEC, STEP_VEC>, generate_fn> type;
00067 };
00068
00074
00075 template <typename CHAN_VEC, typename CS_VEC, typename ORDER_VEC>
00076 struct cross_vector_image_types {
00077
00078 struct generate_fn {
00079 template <typename ELEMENTS>
00080 struct apply {
00081 typedef typename image_type<typename boost::mpl::at_c<ELEMENTS,0>::type,
00082 typename boost::mpl::at_c<ELEMENTS,1>::type,
00083 boost::mpl::at_c<ELEMENTS,2>::type::value
00084 >::type type;
00085 };
00086 };
00087 public:
00088 typedef boost::mpl::cross_vector<boost::mpl::vector3<CHAN_VEC, CS_VEC, ORDER_VEC>, generate_fn> type;
00089 };
00090
00092
00093
00094
00096
00097 namespace detail {
00099
00101 template <typename IMAGE_VIEW_TYPES>
00102 struct get_dynamic_step_views {
00103 private:
00104 struct get_dynamic_step_t { template <typename T> struct apply { typedef typename T::dynamic_step_t type; }; };
00105 public:
00106 typedef typename boost::mpl::transform<IMAGE_VIEW_TYPES, get_dynamic_step_t>::type type;
00107 };
00108
00109 template <typename CHAN_VEC, typename CS_VEC, typename ORDER_VEC, typename STEP_VEC, typename GEN_FN>
00110 struct get_dynamic_step_views<boost::mpl::cross_vector<boost::mpl::vector4<CHAN_VEC, CS_VEC, ORDER_VEC, STEP_VEC>, GEN_FN> > {
00111 typedef boost::mpl::cross_vector<boost::mpl::vector4<CHAN_VEC, CS_VEC, ORDER_VEC, kStepOnly>, GEN_FN> type;
00112 };
00113
00114 template <typename TYPES1, typename TYPES2>
00115 struct get_dynamic_step_views<boost::mpl::concat_vector<TYPES1, TYPES2> > {
00116 typedef boost::mpl::concat_vector<typename get_dynamic_step_views<TYPES1>::type, typename get_dynamic_step_views<TYPES2>::type> type;
00117 };
00118
00119
00121
00123 template <typename IMAGE_VIEW_TYPES>
00124 struct get_const_views_from_views {
00125 private:
00126 struct get_const_t { template <typename T> struct apply { typedef typename T::const_t type; }; };
00127 public:
00128 typedef typename boost::mpl::transform<IMAGE_VIEW_TYPES, get_const_t>::type type;
00129 };
00130
00131 template <typename CHAN_VEC, typename CS_VEC, typename ORDER_VEC, typename STEP_VEC>
00132 struct get_const_views_from_views<boost::mpl::cross_vector<boost::mpl::vector4<CHAN_VEC, CS_VEC, ORDER_VEC, STEP_VEC>,
00133 typename cross_vector_image_view_types<CHAN_VEC,CS_VEC,ORDER_VEC,STEP_VEC,true>::generate_fn> > {
00134 typedef typename cross_vector_image_view_types<CHAN_VEC, CS_VEC, ORDER_VEC, STEP_VEC, false>::type type;
00135 };
00136
00137 template <typename CHAN_VEC, typename CS_VEC, typename ORDER_VEC, typename STEP_VEC>
00138 struct get_const_views_from_views<boost::mpl::cross_vector<boost::mpl::vector4<CHAN_VEC, CS_VEC, ORDER_VEC, STEP_VEC>,
00139 typename cross_vector_image_view_types<CHAN_VEC,CS_VEC,ORDER_VEC,STEP_VEC,false>::generate_fn> > {
00140 typedef typename cross_vector_image_view_types<CHAN_VEC, CS_VEC, ORDER_VEC, STEP_VEC, false>::type type;
00141 };
00142
00143 template <typename TYPES1, typename TYPES2>
00144 struct get_const_views_from_views<boost::mpl::concat_vector<TYPES1, TYPES2> > {
00145 typedef boost::mpl::concat_vector<typename get_const_views_from_views<TYPES1>::type, typename get_const_views_from_views<TYPES2>::type> type;
00146 };
00147
00149
00151 template <typename ITYPES>
00152 struct get_views_from_images {
00153 private:
00154 struct get_view_t { template <typename T> struct apply { typedef typename T::view_t type; }; };
00155 public:
00156 typedef typename boost::mpl::transform<ITYPES, get_view_t>::type type;
00157 };
00158
00159 template <typename CHAN_VEC, typename CS_VEC, typename ORDER_VEC>
00160 struct get_views_from_images<boost::mpl::cross_vector<boost::mpl::vector3<CHAN_VEC, CS_VEC, ORDER_VEC>,
00161 typename cross_vector_image_types<CHAN_VEC, CS_VEC, ORDER_VEC>::generate_fn> > {
00162 typedef typename cross_vector_image_view_types<CHAN_VEC, CS_VEC, ORDER_VEC, kNonStepOnly, true>::type type;
00163 };
00164
00165 template <typename ITYPES1, typename ITYPES2>
00166 struct get_views_from_images<boost::mpl::concat_vector<ITYPES1, ITYPES2> > {
00167 typedef boost::mpl::concat_vector<typename get_views_from_images<ITYPES1>::type, typename get_views_from_images<ITYPES2>::type> type;
00168 };
00169
00171
00173 template <typename ITYPES>
00174 struct get_const_views_from_images {
00175 private:
00176 struct get_const_view_t { template <typename T> struct apply { typedef typename T::const_view_t type; }; };
00177 public:
00178 typedef typename boost::mpl::transform<ITYPES, get_const_view_t>::type type;
00179 };
00180
00181 template <typename CHAN_VEC, typename CS_VEC, typename ORDER_VEC>
00182 struct get_const_views_from_images<boost::mpl::cross_vector<boost::mpl::vector3<CHAN_VEC, CS_VEC, ORDER_VEC>,
00183 typename cross_vector_image_types<CHAN_VEC, CS_VEC, ORDER_VEC>::generate_fn> > {
00184 typedef typename cross_vector_image_view_types<CHAN_VEC, CS_VEC, ORDER_VEC, kNonStepOnly, false>::type type;
00185 };
00186
00187 template <typename ITYPES1, typename ITYPES2>
00188 struct get_const_views_from_images<boost::mpl::concat_vector<ITYPES1, ITYPES2> > {
00189 typedef boost::mpl::concat_vector<typename get_const_views_from_images<ITYPES1>::type, typename get_const_views_from_images<ITYPES2>::type> type;
00190 };
00191 }
00192
00193 ADOBE_GIL_NAMESPACE_END
00194 #endif