Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
mln/core/concept/graph.hh
1 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_CONCEPT_GRAPH_HH
28 # define MLN_CORE_CONCEPT_GRAPH_HH
29 
33 
34 # include <mln/core/concept/object.hh>
35 # include <mln/util/graph_ids.hh>
36 
37 namespace mln
38 {
39 
40 
41  // Forward declaration.
42  template <typename E> struct Graph;
43 
44  // Graph category flag type.
45  template <>
46  struct Graph<void>
47  {
48  typedef Object<void> super;
49  };
50 
56  template <typename E>
57  struct Graph : public Object<E>
58  {
59  typedef Graph<void> category;
60 
61  /*
62  // provided by internal::image_base:
63 
64  typedef pset;
65  typedef site;
66  typedef psite;
67 
68  typedef fwd_piter;
69  typedef bkd_piter;
70 
71  // Misc.
72  const E& id() const;
73  template<typename G2>
74  bool is_subgraph_of(const G2& gr) const;
75  */
76  /*
77  // Vertex and edges oriented.
78  util::vertex_id_t v_other(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const;
79 
80  // Vertex oriented.
81  size_t v_nmax() const;
82  bool has(unsigned id_v) const;
83  size_t v_nmax_nbh_edges(const util::vertex_id_t& id_v) const;
84  util::edge_id_t v_ith_nbh_edge(const util::vertex_id_t& id_v, unsigned i) const;
85 
86  // Edge oriented.
87  size_t e_nmax() const;
88  bool has_e(const util::edge_id_t& id_e) const;
89  util::vertex_id_t v1(const util::edge_id_t& id_e) const;
90  util::vertex_id_t v2(const util::edge_id_t& id_e) const;
91  size_t e_nmax_nbh_edges(const util::edge_id_t& id_e) const;
92  util::edge_id_t e_ith_nbh_edge(const util::edge_id_t& id_e, unsigned i) const;
93 
94  */
95 
96  protected:
97  Graph();
98  };
99 
100 
101 # ifndef MLN_INCLUDE_ONLY
102 
103  template <typename E>
104  inline
106  {
107  // provided by internal::graph_base:
108 
109  //typedef mln_psite(E) psite;
110 
111  //typedef mln_fwd_piter(E) fwd_piter;
112  //typedef mln_bkd_piter(E) bkd_piter;
113 
114  // Check methods
115  const void* (E::*m1)() const = & E::id;
116  m1 = 0;
117  util::vertex_id_t (E::*m2)(const util::edge_id_t& id_e, const util::vertex_id_t& id_v) const = & E::v_other;
118  m2 = 0;
119  size_t (E::*m4)() const = & E::v_nmax;
120  m4 = 0;
121  bool (E::*m5)(const util::vertex_id_t& id_v) const = & E::has_v;
122  m5 = 0;
123  size_t (E::*m6)(const util::vertex_id_t& id_v) const = & E::v_nmax_nbh_edges;
124  m6 = 0;
125  util::edge_id_t (E::*m7)(const util::vertex_id_t& id_v, unsigned i) const = & E::v_ith_nbh_edge;
126  m7 = 0;
127  size_t (E::*m8)() const = & E::e_nmax;
128  m8 = 0;
129  bool (E::*m9)(const util::edge_id_t& id_e) const = & E::has_e;
130  m9 = 0;
131  util::vertex_id_t (E::*m10)(const util::edge_id_t& id_e) const = & E::v1;
132  m10 = 0;
133  util::vertex_id_t (E::*m11)(const util::edge_id_t& id_e) const = & E::v2;
134  m11 = 0;
135  size_t (E::*m12)(const util::edge_id_t& id_e) const = & E::e_nmax_nbh_edges;
136  m12 = 0;
137  util::edge_id_t (E::*m13)(const util::edge_id_t& id_e, unsigned i) const = & E::e_ith_nbh_edge;
138  m13 = 0;
139 
140  bool (E::*m14)() const = & E::is_valid;
141  m14 = 0;
142  void (E::*m15)() = & E::invalidate;
143  m15 = 0;
144  //FIXME: enable this test. Currently does not work because this is
145  // a templated method.
146  //bool (E::*m14)(...) = & E::is_subgraph_of;
147  //m14 = 0;
148  }
149 
150 
151 # endif // ! MLN_INCLUDE_ONLY
152 
153 } // end of namespace mln
154 
155 #endif // ! MLN_CORE_CONCEPT_GRAPH_HH