00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory 00002 // (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 00026 00027 #ifndef MLN_CORE_CONCEPT_GRAPH_HH 00028 # define MLN_CORE_CONCEPT_GRAPH_HH 00029 00033 00034 # include <mln/core/concept/object.hh> 00035 # include <mln/util/graph_ids.hh> 00036 00037 namespace mln 00038 { 00039 00040 00041 // Forward declaration. 00042 template <typename E> struct Graph; 00043 00044 // Graph category flag type. 00045 template <> 00046 struct Graph<void> 00047 { 00048 typedef Object<void> super; 00049 }; 00050 00056 template <typename E> 00057 struct Graph : public Object<E> 00058 { 00059 typedef Graph<void> category; 00060 00061 /* 00062 // provided by internal::image_base: 00063 00064 typedef pset; 00065 typedef site; 00066 typedef psite; 00067 00068 typedef fwd_piter; 00069 typedef bkd_piter; 00070 00071 // Misc. 00072 const E& id() const; 00073 template<typename G2> 00074 bool is_subgraph_of(const G2& gr) const; 00075 */ 00076 /* 00077 // Vertex and edges oriented. 00078 util::vertex_id_t v_other(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const; 00079 00080 // Vertex oriented. 00081 size_t v_nmax() const; 00082 bool has(unsigned id_v) const; 00083 size_t v_nmax_nbh_edges(const util::vertex_id_t& id_v) const; 00084 util::edge_id_t v_ith_nbh_edge(const util::vertex_id_t& id_v, unsigned i) const; 00085 00086 // Edge oriented. 00087 size_t e_nmax() const; 00088 bool has_e(const util::edge_id_t& id_e) const; 00089 util::vertex_id_t v1(const util::edge_id_t& id_e) const; 00090 util::vertex_id_t v2(const util::edge_id_t& id_e) const; 00091 size_t e_nmax_nbh_edges(const util::edge_id_t& id_e) const; 00092 util::edge_id_t e_ith_nbh_edge(const util::edge_id_t& id_e, unsigned i) const; 00093 00094 */ 00095 00096 protected: 00097 Graph(); 00098 }; 00099 00100 00101 # ifndef MLN_INCLUDE_ONLY 00102 00103 template <typename E> 00104 inline 00105 Graph<E>::Graph() 00106 { 00107 // provided by internal::graph_base: 00108 00109 //typedef mln_psite(E) psite; 00110 00111 //typedef mln_fwd_piter(E) fwd_piter; 00112 //typedef mln_bkd_piter(E) bkd_piter; 00113 00114 // Check methods 00115 const void* (E::*m1)() const = & E::id; 00116 m1 = 0; 00117 util::vertex_id_t (E::*m2)(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const = & E::v_other; 00118 m2 = 0; 00119 size_t (E::*m4)() const = & E::v_nmax; 00120 m4 = 0; 00121 bool (E::*m5)(const util::vertex_id_t& id_v) const = & E::has_v; 00122 m5 = 0; 00123 size_t (E::*m6)(const util::vertex_id_t& id_v) const = & E::v_nmax_nbh_edges; 00124 m6 = 0; 00125 util::edge_id_t (E::*m7)(const util::vertex_id_t& id_v, unsigned i) const = & E::v_ith_nbh_edge; 00126 m7 = 0; 00127 size_t (E::*m8)() const = & E::e_nmax; 00128 m8 = 0; 00129 bool (E::*m9)(const util::edge_id_t& id_e) const = & E::has_e; 00130 m9 = 0; 00131 util::vertex_id_t (E::*m10)(const util::edge_id_t& id_e) const = & E::v1; 00132 m10 = 0; 00133 util::vertex_id_t (E::*m11)(const util::edge_id_t& id_e) const = & E::v2; 00134 m11 = 0; 00135 size_t (E::*m12)(const util::edge_id_t& id_e) const = & E::e_nmax_nbh_edges; 00136 m12 = 0; 00137 util::edge_id_t (E::*m13)(const util::edge_id_t& id_e, unsigned i) const = & E::e_ith_nbh_edge; 00138 m13 = 0; 00139 00140 bool (E::*m14)() const = & E::is_valid; 00141 m14 = 0; 00142 void (E::*m15)() = & E::invalidate; 00143 m15 = 0; 00144 //FIXME: enable this test. Currently does not work because this is 00145 // a templated method. 00146 //bool (E::*m14)(...) = & E::is_subgraph_of; 00147 //m14 = 0; 00148 } 00149 00150 00151 # endif // ! MLN_INCLUDE_ONLY 00152 00153 } // end of namespace mln 00154 00155 #endif // ! MLN_CORE_CONCEPT_GRAPH_HH