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

p_vertices_psite.hh

00001 // Copyright (C) 2008, 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_SITE_SET_P_VERTICES_PSITE_HH
00027 # define MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
00028 
00032 
00033 # include <mln/core/concept/pseudo_site.hh>
00034 # include <mln/core/internal/graph_psite_base.hh>
00035 # include <mln/util/vertex.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   // Forward declaration.
00042   template <typename G, typename F> class p_vertices;
00043   namespace internal { template <typename Subject, typename E> struct subject_impl; }
00044 
00045 
00046   template <typename G, typename F>
00047   class p_vertices_psite :
00048     public internal::graph_psite_base< p_vertices<G,F>, p_vertices_psite<G,F> >
00049   {
00050     typedef p_vertices_psite<G,F> self_;
00051     typedef internal::graph_psite_base<p_vertices<G,F>, self_> super_;
00052 
00053   public:
00054 
00055     typedef p_vertices<G,F> target_t;
00056 
00057     p_vertices_psite();
00058     p_vertices_psite(const p_vertices<G,F>& s);
00059     p_vertices_psite(const p_vertices<G,F>& s, unsigned id);
00060 
00061     const util::vertex<G>& v() const;
00062   };
00063 
00064 
00065   template <typename G, typename F>
00066   bool
00067   operator==(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs);
00068 
00069   template <typename G, typename F>
00070   bool
00071   operator!=(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs);
00072 
00073   template <typename G, typename F>
00074   bool
00075   operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs);
00076 
00077 
00078   namespace internal
00079   {
00080 
00082 
00083     template <typename G, typename F, typename E>
00084     struct subject_impl< const p_vertices_psite<G,F>&, E >
00085          : subject_impl< const graph_psite_base< p_vertices<G,F>,
00086                                                  p_vertices_psite<G,F> >&, E >
00087     {
00088       const util::vertex<G>& v() const;
00089 
00090     private:
00091       const E& exact_() const;
00092     };
00093 
00094     template <typename G, typename F, typename E>
00095     struct subject_impl<       p_vertices_psite<G,F>&, E >
00096       :    subject_impl< const p_vertices_psite<G,F>&, E >,
00097            subject_impl<       graph_psite_base< p_vertices<G,F>,
00098                                                  p_vertices_psite<G,F> >&, E >
00099     {
00100     };
00101 
00102   } // end of namespace mln::internal
00103 
00104 
00105 
00106 # ifndef MLN_INCLUDE_ONLY
00107 
00108   template <typename G, typename F>
00109   inline
00110   p_vertices_psite<G, F>::p_vertices_psite()
00111   {
00112   }
00113 
00114   template <typename G, typename F>
00115   inline
00116   p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s)
00117     : super_(s)
00118   {
00119   }
00120 
00121   template <typename G, typename F>
00122   inline
00123   p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s, unsigned i)
00124     : super_(s, i)
00125   {
00126   }
00127 
00128   template <typename G, typename F>
00129   inline
00130   const util::vertex<G>&
00131   p_vertices_psite<G, F>::v() const
00132   {
00133     return this->elt_;
00134   }
00135 
00136     /*--------------.
00137     | Comparisons.  |
00138     `--------------*/
00139 
00140   template <typename G, typename F>
00141   bool
00142   operator==(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
00143   {
00144     mln_assertion(lhs.target_() == rhs.target_());
00145     return lhs.id() == rhs.id();
00146   }
00147 
00148   template <typename G, typename F>
00149   bool
00150   operator!=(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
00151   {
00152     mln_assertion(lhs.target_() == rhs.target_());
00153     return lhs.id() != rhs.id();
00154   }
00155 
00156   template <typename G, typename F>
00157   bool
00158   operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
00159   {
00160     mln_assertion(lhs.target_() == rhs.target_());
00161     return lhs.id() < rhs.id();
00162   }
00163 
00164 
00165 
00166 
00167   namespace internal
00168   {
00169 
00171 
00172     template <typename G, typename F, typename E>
00173     inline
00174     const E&
00175     subject_impl< const p_vertices_psite<G,F>&, E >::exact_() const
00176     {
00177       return internal::force_exact<const E>(*this);
00178     }
00179 
00180     template <typename G, typename F, typename E>
00181     inline
00182     const util::vertex<G>&
00183     subject_impl< const p_vertices_psite<G,F>&, E >::v() const
00184     {
00185       return exact_().get_subject().v();
00186     }
00187 
00188   } // end of namespace mln::internal
00189 
00190 # endif // ! MLN_INCLUDE_ONLY
00191 
00192 } // end of namespace mln
00193 
00194 
00195 #endif // ! MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH

Generated on Thu Sep 8 2011 18:32:19 for Milena (Olena) by  doxygen 1.7.1