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 
00027 #ifndef MLN_CORE_CONCEPT_META_ACCUMULATOR_HH
00028 # define MLN_CORE_CONCEPT_META_ACCUMULATOR_HH
00029 
00033 
00034 # include <mln/core/concept/object.hh>
00035 # include <mln/core/concept/accumulator.hh>
00036 
00037 
00038 # define mln_accu_with(A, T) \
00039 typename mln::internal::accu_with_helper<A,T>::ret
00040 
00041 # define mln_accu_with_(A, T) \
00042 mln::internal::accu_with_helper<A,T>::ret
00043 
00044 
00045 # define mln_meta_accu_result(A, T) \
00046 typename mln::internal::meta_accu_ret_result_helper<A,T>::result
00047 
00048 
00049 # define mln_meta_accu_result_(A, T)                            \
00050 mln::internal::meta_accu_ret_result_helper<A,T>::result
00051 
00052 
00053 
00054 
00055 namespace mln
00056 {
00057 
00058   
00059   template <typename E> struct Meta_Accumulator;
00060 
00061 
00062   namespace internal
00063   {
00064 
00067     
00068     template <typename A, typename T>
00069     struct meta_accu_ret_result_helper
00070     {
00071         typedef typename A::template with< T >::ret::result result;
00072     };
00073 
00074 
00077     
00078     template <typename A, typename T>
00079     struct accu_with_helper
00080     {
00081         typedef typename A::template with< T >::ret ret;
00082     };
00083 
00084 
00085   } 
00086 
00087 
00088   
00089   template <>
00090   struct Meta_Accumulator<void>
00091   {
00092     typedef Object<void> super;
00093   };
00094 
00102   template <typename E>
00103   struct Meta_Accumulator : public Object<E>
00104   {
00105     typedef Meta_Accumulator<void> category;
00106   protected:
00107     Meta_Accumulator();
00108   };
00109 
00110 
00111   namespace accu
00112   {
00113 
00114     
00115     
00116     
00117     template <typename M, typename T>
00118     mln_accu_with(M, T)
00119     unmeta(const M&, T);
00120 
00121     template <typename M, typename T>
00122     void
00123     unmeta(const Meta_Accumulator<M>&, T); 
00124 
00125   } 
00126 
00127 
00128 
00129 # ifndef MLN_INCLUDE_ONLY
00130 
00131   template <typename E>
00132   inline
00133   Meta_Accumulator<E>::Meta_Accumulator()
00134   {
00135     
00136   }
00137 
00138   namespace accu
00139   {
00140 
00141     template <typename M, typename T>
00142     inline
00143     mln_accu_with(M, T)
00144     unmeta(const M&, T)
00145     {
00146       mlc_is_a(M, Meta_Accumulator)::check();
00147       mln_accu_with(M, T) a;
00148       return a;
00149     }
00150 
00151   } 
00152 
00153 # endif // ! MLN_INCLUDE_ONLY
00154 
00155 } 
00156 
00157 
00158 #endif // ! MLN_CORE_CONCEPT_META_ACCUMULATOR_HH