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_CONCEPT_GRAPH_HH 00027 # define MLN_CORE_CONCEPT_GRAPH_HH 00028 00032 00033 # include <mln/core/concept/object.hh> 00034 # include <mln/util/graph_ids.hh> 00035 00036 namespace mln 00037 { 00038 00039 00040 // Forward declaration. 00041 template <typename E> struct Graph; 00042 00043 // Graph category flag type. 00044 template <> 00045 struct Graph<void> 00046 { 00047 typedef Object<void> super; 00048 }; 00049 00055 template <typename E> 00056 struct Graph : public Object<E> 00057 { 00058 typedef Graph<void> category; 00059 00060 /* 00061 // provided by internal::image_base: 00062 00063 typedef pset; 00064 typedef site; 00065 typedef psite; 00066 00067 typedef fwd_piter; 00068 typedef bkd_piter; 00069 00070 // Misc. 00071 const E& id() const; 00072 template<typename G2> 00073 bool is_subgraph_of(const G2& gr) const; 00074 */ 00077 bool is_valid() const; 00080 void invalidate(); 00081 /* 00082 // Vertex and edges oriented. 00083 util::vertex_id_t v_other(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const; 00084 00085 // Vertex oriented. 00086 size_t v_nmax() const; 00087 bool has(unsigned id_v) const; 00088 size_t v_nmax_nbh_edges(const util::vertex_id_t& id_v) const; 00089 util::edge_id_t v_ith_nbh_edge(const util::vertex_id_t& id_v, unsigned i) const; 00090 00091 // Edge oriented. 00092 size_t e_nmax() const; 00093 bool has_e(const util::edge_id_t& id_e) const; 00094 util::vertex_id_t v1(const util::edge_id_t& id_e) const; 00095 util::vertex_id_t v2(const util::edge_id_t& id_e) const; 00096 size_t e_nmax_nbh_edges(const util::edge_id_t& id_e) const; 00097 util::edge_id_t e_ith_nbh_edge(const util::edge_id_t& id_e, unsigned i) const; 00098 00099 */ 00100 00101 protected: 00102 Graph(); 00103 }; 00104 00105 00106 # ifndef MLN_INCLUDE_ONLY 00107 00108 template <typename E> 00109 inline 00110 Graph<E>::Graph() 00111 { 00112 // provided by internal::graph_base: 00113 00114 //typedef mln_psite(E) psite; 00115 00116 //typedef mln_fwd_piter(E) fwd_piter; 00117 //typedef mln_bkd_piter(E) bkd_piter; 00118 00119 // Check methods 00120 const void* (E::*m1)() const = & E::id; 00121 m1 = 0; 00122 util::vertex_id_t (E::*m2)(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const = & E::v_other; 00123 m2 = 0; 00124 size_t (E::*m4)() const = & E::v_nmax; 00125 m4 = 0; 00126 bool (E::*m5)(const util::vertex_id_t& id_v) const = & E::has_v; 00127 m5 = 0; 00128 size_t (E::*m6)(const util::vertex_id_t& id_v) const = & E::v_nmax_nbh_edges; 00129 m6 = 0; 00130 util::edge_id_t (E::*m7)(const util::vertex_id_t& id_v, unsigned i) const = & E::v_ith_nbh_edge; 00131 m7 = 0; 00132 size_t (E::*m8)() const = & E::e_nmax; 00133 m8 = 0; 00134 bool (E::*m9)(const util::edge_id_t& id_e) const = & E::has_e; 00135 m9 = 0; 00136 util::vertex_id_t (E::*m10)(const util::edge_id_t& id_e) const = & E::v1; 00137 m10 = 0; 00138 util::vertex_id_t (E::*m11)(const util::edge_id_t& id_e) const = & E::v2; 00139 m11 = 0; 00140 size_t (E::*m12)(const util::edge_id_t& id_e) const = & E::e_nmax_nbh_edges; 00141 m12 = 0; 00142 util::edge_id_t (E::*m13)(const util::edge_id_t& id_e, unsigned i) const = & E::e_ith_nbh_edge; 00143 m13 = 0; 00144 00145 //FIXME: enable this test. Currently does not work because this is 00146 // a templated method. 00147 //bool (E::*m14)(...) = & E::is_subgraph_of; 00148 //m14 = 0; 00149 } 00150 00151 template <typename E> 00152 inline 00153 bool 00154 Graph<E>::is_valid() const 00155 { 00156 //FIXME: should not always return true! 00157 return true; 00158 } 00159 00160 template <typename E> 00161 inline 00162 void 00163 Graph<E>::invalidate() 00164 { 00165 //FIXME: No op! Should do something. 00166 } 00167 00168 00169 # endif // ! MLN_INCLUDE_ONLY 00170 00171 } // end of namespace mln 00172 00173 #endif // ! MLN_CORE_CONCEPT_GRAPH_HH
1.7.1