2608: Factor mln/core/image/complex_windows.hh using the preprocessor.

* mln/core/image/complex_windows.hh (mln_gen_complex_window): New (generator) macro. Use it to factor... (mln::complex_lower_window_p<D, G>) (mln::complex_higher_window_p<D, G>) (mln::complex_lower_higher_window_p<D, G>) (mln::complex_lower_dim_connected_n_face_window_p<D, G>) (mln::complex_higher_dim_connected_n_face_window_p<D, G>): ...the definitions of these classes, as well as... (trait::window_< complex_lower_window_p<D, G> >) (trait::window_< complex_higher_window_p<D, G> >) (trait::window_< complex_lower_higher_window_p<D, G> >) (trait::window_< complex_lower_dim_connected_n_face_window_p<D, G> >) (trait::window_< complex_higher_dim_connected_n_face_window_p<D, G> >): ...their traits. * mln/core/internal/complex_window_p_base.hh (mln::internal::complex_window_p_base<D, G, F, B, E>): Be more precise in documentation. --- milena/ChangeLog | 23 +++ milena/mln/core/image/complex_windows.hh | 167 +++++++-------------- milena/mln/core/internal/complex_window_p_base.hh | 6 +- 3 files changed, 84 insertions(+), 112 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 1aa444c..1ac37ac 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,28 @@ 2008-10-18 Roland Levillain <roland@lrde.epita.fr> + Factor mln/core/image/complex_windows.hh using the preprocessor. + + * mln/core/image/complex_windows.hh + (mln_gen_complex_window): New (generator) macro. + Use it to factor... + (mln::complex_lower_window_p<D, G>) + (mln::complex_higher_window_p<D, G>) + (mln::complex_lower_higher_window_p<D, G>) + (mln::complex_lower_dim_connected_n_face_window_p<D, G>) + (mln::complex_higher_dim_connected_n_face_window_p<D, G>): + ...the definitions of these classes, as well as... + (trait::window_< complex_lower_window_p<D, G> >) + (trait::window_< complex_higher_window_p<D, G> >) + (trait::window_< complex_lower_higher_window_p<D, G> >) + (trait::window_< complex_lower_dim_connected_n_face_window_p<D, G> >) + (trait::window_< complex_higher_dim_connected_n_face_window_p<D, G> >): + ...their traits. + * mln/core/internal/complex_window_p_base.hh + (mln::internal::complex_window_p_base<D, G, F, B, E>): + Be more precise in documentation. + +2008-10-18 Roland Levillain <roland@lrde.epita.fr> + Factor mln/core/image/complex_neighborhoods.hh using the preprocessor. * mln/core/image/complex_neighborhoods.hh diff --git a/milena/mln/core/image/complex_windows.hh b/milena/mln/core/image/complex_windows.hh index 6c074e7..66dba5d 100644 --- a/milena/mln/core/image/complex_windows.hh +++ b/milena/mln/core/image/complex_windows.hh @@ -37,137 +37,86 @@ # include <mln/topo/adj_higher_face_iter.hh> # include <mln/topo/adj_lower_higher_face_iter.hh> +/** \brief Generate a complex window class, as well as its traits. + + \param Win The name of the class to generate. + \param Fwd_Complex_Iter The underlying forward iterator type. + \param Bkd_Complex_Iter The underlying backward iterator type. + + The generated class inherits from + + mln:: internal::complex_window_p_base< D, G, + Fwd_Complex_Iter<D>, + Bkd_Complex_Iter<D>, + Win <D, G> > + + where D and G are template parameters of the generated Win class. */ +# define mln_gen_complex_window(Win, Fwd_Complex_Iter, Bkd_Complex_Iter) \ + /* Forward declaration. */ \ + template <unsigned D, typename G> struct Win; \ + \ + /* Traits. */ \ + namespace trait \ + { \ + template <unsigned D, typename G> \ + struct window_< Win <D, G> > \ + : window_< mln::internal::complex_window_p_base< D, G, \ + Fwd_Complex_Iter<D>, \ + Bkd_Complex_Iter <D>, \ + Win <D, G> > > \ + { \ + }; \ + } \ + \ + /* Definition. */ \ + template <unsigned D, typename G> \ + struct Win \ + : internal::complex_window_p_base< D, G, \ + Fwd_Complex_Iter <D>, \ + Bkd_Complex_Iter <D>, \ + Win <D, G> > \ + { \ + } + namespace mln { /// \brief Window centered on an n-face of complex returning its /// adjacent (n-1)-faces as well as the center n-face. - template <unsigned D, typename G> - struct complex_lower_window_p - : internal::complex_window_p_base< D, G, - topo::adj_lower_face_fwd_iter<D>, - topo::adj_lower_face_bkd_iter<D>, - complex_lower_window_p<D, G> > - { - }; + mln_gen_complex_window(complex_lower_window_p, + topo::adj_lower_face_fwd_iter, + topo::adj_lower_face_bkd_iter); /// \brief Window centered on an n-face of complex returning its /// adjacent (n+1)-faces as well as the center n-face. - template <unsigned D, typename G> - struct complex_higher_window_p - : internal::complex_window_p_base< D, G, - topo::adj_higher_face_fwd_iter<D>, - topo::adj_higher_face_bkd_iter<D>, - complex_higher_window_p<D, G> > - { - }; + mln_gen_complex_window(complex_higher_window_p, + topo::adj_higher_face_fwd_iter, + topo::adj_higher_face_bkd_iter); /// \brief Window centered on an n-face of complex returning its /// adjacent (n-1)-faces and (n+1)-faces as well as the center /// n-face. - template <unsigned D, typename G> - struct complex_lower_higher_window_p - : internal::complex_window_p_base< D, G, - topo::adj_lower_higher_face_fwd_iter<D>, - topo::adj_lower_higher_face_bkd_iter<D>, - complex_lower_higher_window_p<D, G> > - { - }; + mln_gen_complex_window(complex_lower_higher_window_p, + topo::adj_lower_higher_face_fwd_iter, + topo::adj_lower_higher_face_bkd_iter); /// \brief Window centered on an n-face of complex returning the /// n-faces sharing an (n-1)-face with the center n-face, as well as /// this center n-face. - template <unsigned D, typename G> - struct complex_lower_dim_connected_n_face_window_p - : internal::complex_window_p_base< - D, G, - topo::adj_lower_dim_connected_n_face_fwd_iter<D>, - topo::adj_lower_dim_connected_n_face_bkd_iter<D>, - complex_lower_dim_connected_n_face_window_p<D, G> - > - { - }; + mln_gen_complex_window(complex_lower_dim_connected_n_face_window_p, + topo::adj_lower_dim_connected_n_face_fwd_iter, + topo::adj_lower_dim_connected_n_face_bkd_iter); /// \brief Window centered on an n-face of complex returning the /// n-faces sharing an (n+1)-face with the center n-face, as well as /// this center n-face. - template <unsigned D, typename G> - struct complex_higher_dim_connected_n_face_window_p - : internal::complex_window_p_base< - D, G, - topo::adj_higher_dim_connected_n_face_fwd_iter<D>, - topo::adj_higher_dim_connected_n_face_bkd_iter<D>, - complex_higher_dim_connected_n_face_window_p<D, G> - > - { - }; - - - // -------- // - // Traits. // - // -------- // - - namespace trait - { - - template <unsigned D, typename G> - struct window_< mln::complex_lower_window_p<D, G> > - : window_< mln::internal::complex_window_p_base< - D, G, - mln::topo::adj_lower_face_fwd_iter<D>, - mln::topo::adj_lower_face_bkd_iter<D>, - mln::complex_lower_window_p<D, G> > - > - { - }; - - template <unsigned D, typename G> - struct window_< mln::complex_higher_window_p<D, G> > - : window_< mln::internal::complex_window_p_base< - D, G, - mln::topo::adj_higher_face_fwd_iter<D>, - mln::topo::adj_higher_face_bkd_iter<D>, - mln::complex_higher_window_p<D, G> > - > - { - }; - - template <unsigned D, typename G> - struct window_< mln::complex_lower_higher_window_p<D, G> > - : window_< mln::internal::complex_window_p_base< - D, G, - mln::topo::adj_lower_higher_face_fwd_iter<D>, - mln::topo::adj_lower_higher_face_bkd_iter<D>, - mln::complex_lower_higher_window_p<D, G> > - > - { - }; - - template <unsigned D, typename G> - struct window_< mln::complex_lower_dim_connected_n_face_window_p<D, G> > - : window_< mln::internal::complex_window_p_base< - D, G, - mln::topo::adj_lower_dim_connected_n_face_fwd_iter<D>, - mln::topo::adj_lower_dim_connected_n_face_bkd_iter<D>, - mln::complex_lower_dim_connected_n_face_window_p<D, G> > - > - { - }; - - template <unsigned D, typename G> - struct window_< mln::complex_higher_dim_connected_n_face_window_p<D, G> > - : window_< mln::internal::complex_window_p_base< - D, G, - mln::topo::adj_higher_dim_connected_n_face_fwd_iter<D>, - mln::topo::adj_higher_dim_connected_n_face_bkd_iter<D>, - mln::complex_higher_dim_connected_n_face_window_p<D, G> > - > - { - }; - - } // end of namespace mln::trait + mln_gen_complex_window(complex_higher_dim_connected_n_face_window_p, + topo::adj_higher_dim_connected_n_face_fwd_iter, + topo::adj_higher_dim_connected_n_face_bkd_iter); } // end of namespace mln +# undef mln_gen_complex_window + #endif // ! MLN_CORE_IMAGE_COMPLEX_WINDOWS_P_HH diff --git a/milena/mln/core/internal/complex_window_p_base.hh b/milena/mln/core/internal/complex_window_p_base.hh index 3494552..2362c54 100644 --- a/milena/mln/core/internal/complex_window_p_base.hh +++ b/milena/mln/core/internal/complex_window_p_base.hh @@ -78,9 +78,9 @@ namespace mln center (site) is part of the window. \tparam D The dimension of the complex. - \tparam G The geometry functor of the complex. - \tparam F The underlying forward iterator. - \tparam B The underlying backward iterator. + \tparam G The type of the geometry functor of the complex. + \tparam F The underlying forward iterator type. + \tparam B The underlying backward iterator type. \tparam E The exact type. */ template <unsigned D, typename G, typename F, typename B, typename E> class complex_window_p_base : public Window<E> -- 1.6.0.1
participants (1)
-
Roland Levillain