00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifndef MLN_OPT_VALUE_HH
00027 # define MLN_OPT_VALUE_HH
00028 
00032 
00033 # include <mln/core/concept/image.hh>
00034 # include <mln/trait/images.hh>
00035 
00036 namespace mln
00037 {
00038 
00039   namespace opt
00040   {
00041 
00042     template <typename I>
00043     inline
00044     mln_rvalue(I) value(const Image<I>& ima);
00045 
00046     template <typename I>
00047     inline
00048     mln_lvalue(I) value(Image<I>& ima);
00049 
00050 
00051 # ifndef MLN_INCLUDE_ONLY
00052 
00053     namespace impl
00054     {
00055 
00056       template <typename I>
00057       inline
00058       mln_rvalue(I) value_impl(trait::image::category::domain_morpher,
00059                                const Image<I>& ima)
00060       {
00061         return value(*exact(ima).delegatee_());
00062       }
00063 
00064       template <typename I>
00065       inline
00066       mln_rvalue(I) value_impl(trait::image::category::any,
00067                                const Image<I>& ima)
00068       {
00069         mlc_is(mln_trait_image_value_storage(I),
00070                trait::image::value_storage::singleton)::check();
00071         return exact(ima).value_();
00072       }
00073 
00074 
00075 
00076 
00077       template <typename I>
00078       inline
00079       mln_lvalue(I) value_impl(trait::image::category::domain_morpher,
00080                                Image<I>& ima)
00081       {
00082         return value(*exact(ima).delegatee_());
00083       }
00084 
00085       template <typename I>
00086       inline
00087       mln_lvalue(I) value_impl(trait::image::category::any,
00088                                Image<I>& ima)
00089       {
00090         mlc_is(mln_trait_image_value_storage(I),
00091                trait::image::value_storage::singleton)::check();
00092         return exact(ima).value_();
00093       }
00094     }
00095 
00096 
00097     template <typename I>
00098     inline
00099     mln_rvalue(I) value(const Image<I>& ima)
00100     {
00101       return impl::value_impl(mln_trait_image_category(I)(), ima);
00102     }
00103 
00104     template <typename I>
00105     inline
00106     mln_lvalue(I) value(Image<I>& ima)
00107     {
00108       return impl::value_impl(mln_trait_image_category(I)(), ima);
00109     }
00110 
00111 
00112 
00113 
00114 # endif // ! MLN_INCLUDE_ONLY
00115 
00116   } 
00117 
00118 } 
00119 
00120 
00121 #endif // ! MLN_OPT_VALUE_HH