• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

graph_elt_window_if.hh

00001 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH
00027 # define MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH
00028 
00034 
00035 # include <mln/core/concept/window.hh>
00036 # include <mln/core/internal/neighborhood_base.hh>
00037 # include <mln/core/internal/graph_window_base.hh>
00038 # include <mln/core/internal/is_masked_impl_selector.hh>
00039 # include <mln/core/image/graph_window_if_piter.hh>
00040 
00041 
00042 namespace mln
00043 {
00044 
00046   template <typename G, typename S, typename I> class graph_elt_window_if;
00047   template <typename G, typename F> struct p_edges;
00048   template <typename G, typename F> struct p_vertices;
00049 
00050 
00051   namespace internal
00052   {
00053 
00054     template <typename G, typename S, typename I, typename E>
00055     struct neighborhood_impl<graph_elt_window_if<G,S,I>,E>
00056       : public neighborhood_extra_impl<graph_elt_window_if<G,S,I>,E>
00057     {
00058     };
00059 
00060 
00063     template <typename G, typename S>
00064     struct graph_window_if_iter_dispatch;
00065 
00066     template <typename G, typename F>
00067     struct graph_window_if_iter_dispatch<G, p_edges<G,F> >
00068     {
00069       typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
00070       typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
00071     };
00072 
00073     template <typename G, typename F>
00074     struct graph_window_if_iter_dispatch<G, p_vertices<G,F> >
00075     {
00076       typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_;
00077       typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_;
00078     };
00079 
00080 
00081   } // end of namespace mln::internal
00082 
00083 
00084   namespace trait
00085   {
00086 
00087     template <typename G, typename S, typename I>
00088     struct window_< mln::graph_elt_window_if<G,S,I> >
00089     {
00090       typedef trait::window::size::unknown       size;
00091       typedef trait::window::support::irregular  support;
00092       typedef trait::window::definition::varying definition;
00093     };
00094 
00095   } // end of namespace mln::trait
00096 
00097 
00104   template <typename G, typename S, typename I>
00105   class graph_elt_window_if
00106     : public graph_window_base<mln_result(S::fun_t),
00107                                graph_elt_window_if<G,S,I> >,
00108       public internal::graph_window_if_iter_dispatch<G,S>,
00109       private mlc_is(mln_value(I), bool)::check_t
00110   {
00111     typedef graph_elt_window_if<G,S,I> self_;
00112     typedef internal::graph_window_if_iter_dispatch<G,S> super_;
00113 
00114     typedef typename super_::nbh_fwd_iter_ nbh_fwd_iter_;
00115     typedef typename super_::nbh_bkd_iter_ nbh_bkd_iter_;
00116 
00117   public:
00119     typedef I mask_t;
00120 
00124     graph_elt_window_if();
00125 
00129     graph_elt_window_if(const Image<I>& mask);
00131 
00134 
00136     typedef S target;
00137 
00139     typedef mln_psite(target) psite;
00140 
00143     typedef graph_window_if_piter<target,self_,nbh_fwd_iter_> fwd_qiter;
00144 
00147     typedef graph_window_if_piter<target,self_,nbh_bkd_iter_> bkd_qiter;
00148 
00150     typedef fwd_qiter qiter;
00152 
00154     const I& mask() const;
00155 
00157     void change_mask(const Image<I>& mask);
00158 
00160     bool is_valid() const;
00161 
00162   private:
00163     // FIXME: Should be const!
00164     I mask_;
00165   };
00166 
00167 
00168 
00169 # ifndef MLN_INCLUDE_ONLY
00170 
00171 
00172   template <typename G, typename S, typename I>
00173   inline
00174   graph_elt_window_if<G,S,I>::graph_elt_window_if()
00175   {
00176   }
00177 
00178 
00179   template <typename G, typename S, typename I>
00180   inline
00181   graph_elt_window_if<G,S,I>::graph_elt_window_if(const Image<I>& mask)
00182     : mask_(exact(mask))
00183   {
00184   }
00185 
00186 
00187   template <typename G, typename S, typename I>
00188   inline
00189   const I&
00190   graph_elt_window_if<G,S,I>::mask() const
00191   {
00192     return mask_;
00193   }
00194 
00195 
00196   template <typename G, typename S, typename I>
00197   inline
00198   void
00199   graph_elt_window_if<G,S,I>::change_mask(const Image<I>& mask)
00200   {
00201     mln_precondition(exact(mask).is_valid());
00202     mask_ = exact(mask);
00203   }
00204 
00205   template <typename G, typename S, typename I>
00206   inline
00207   bool
00208   graph_elt_window_if<G,S,I>::is_valid() const
00209   {
00210     return mask_.is_valid();
00211   }
00212 
00213 
00214 # endif // ! MLN_INCLUDE_ONLY
00215 
00216 
00217 } // end of namespace mln
00218 
00219 
00220 #endif // ! MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_IF_HH

Generated on Tue Oct 4 2011 15:23:50 for Milena (Olena) by  doxygen 1.7.1