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

is_masked_impl_selector.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_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH
00027 # define MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH
00028 
00032 
00033 # include <mln/util/edge.hh>
00034 
00035 
00036 namespace mln
00037 {
00038 
00039   // Forward declarations.
00040   template <typename G, typename F> struct p_edges;
00041   template <typename G, typename F> struct p_vertices;
00042 
00043 
00044 
00045   namespace internal
00046   {
00047 
00050     template <typename S, typename D, typename E>
00051     struct is_masked_impl_selector
00052     {
00054       bool is_masked(const mln_graph_element(S)& center,
00055                      const mln_graph_element(S)& element) const;
00056     };
00057 
00059     template <typename G1, typename F1, typename G2, typename F2, typename E>
00060     struct is_masked_impl_selector< p_vertices<G1,F1>, p_edges<G2,F2>, E >
00061     {
00062       typedef p_vertices<G1,F1> S;
00063 
00065       bool is_masked(const mln_graph_element(S)& center,
00066                      const mln_graph_element(S)& element) const;
00067     };
00068 
00070     template <typename G1, typename F1, typename G2, typename F2, typename E>
00071     struct is_masked_impl_selector< p_edges<G1,F1>, p_vertices<G2,F2>, E >
00072     {
00073       typedef p_edges<G1,F1> S;
00074 
00076       bool is_masked(const mln_graph_element(S)& center,
00077                      const mln_graph_element(S)& element) const;
00078     };
00079 
00080 
00081 # ifndef MLN_INCLUDE_ONLY
00082 
00083 
00084     template <typename S, typename I, typename E>
00085     inline
00086     bool
00087     is_masked_impl_selector<S,I,E>::is_masked(const mln_graph_element(S)& center,
00088                                               const mln_graph_element(S)& element) const
00089     {
00090       (void) center;
00091       E& iter = internal::force_exact<E>(*this);
00092       return ! iter.target_()->mask()(element.id());
00093     }
00094 
00095 
00096     template <typename G1, typename F1, typename G2, typename F2, typename E>
00097     inline
00098     bool
00099     is_masked_impl_selector< p_vertices<G1,F1>, p_edges<G2,F2>, E >
00100       ::is_masked(const mln_graph_element(S)& center,
00101                   const mln_graph_element(S)& element) const
00102     {
00103       E& iter = internal::force_exact<E>(*this);
00104 
00105       util::edge<G1> e = center.edge_with(element);
00106       mln_postcondition(e.is_valid());
00107 
00108       return ! iter.target_()->mask()(e.id());
00109     }
00110 
00111 
00118     template <typename G1, typename F1, typename G2, typename F2, typename E>
00119     inline
00120     bool
00121     is_masked_impl_selector< p_edges<G1,F1>, p_vertices<G2,F2>, E >
00122       ::is_masked(const mln_graph_element(S)& center,
00123                   const mln_graph_element(S)& element) const
00124     {
00125       E& iter = internal::force_exact<E>(*this);
00126 
00127       if (center.v1() == element.v2() || center.v2() == element.v2())
00128         return ! iter.target_()->mask()(element.v1());
00129 
00130       //else if (center.v2() == element.v1() || center.v1() == element.v1())
00131       return ! iter.target_()->mask()(element.v2());
00132     }
00133 
00134 # endif // ! MLN_INCLUDE_ONLY
00135 
00136   } // end of namespace mln::internal
00137 
00138 } // end of namespace mln
00139 
00140 
00141 #endif // ! MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH

Generated on Fri Sep 16 2011 16:33:39 for Milena (Olena) by  doxygen 1.7.1