LEMUR Packages: ompl_lemur or_lemur pr_bgl prpy_lemur
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Groups Pages
compose_property_map.hpp
1 // Copyright (C) 2013 Eurodecision
2 // Authors: Guillaume Pinot
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // See http://www.boost.org/libs/property_map for documentation.
9 
10 #ifndef PR_BGL_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP
11 #define PR_BGL_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP
12 
13 #include <boost/property_map/property_map.hpp>
14 #include <boost/type_traits.hpp>
15 
16 namespace pr_bgl {
17 
18 // A compose property map: make_compose_property_map(f, g)[x] == f[g[x]]
19 //
20 // g must be a readable property map.
21 // The category of compose_property_map(f, g) is the category of f.
22 
23 template <typename FPMap, typename GPMap>
25 {
26 public:
27  typedef typename boost::property_traits<FPMap>::category category;
28  typedef typename boost::property_traits<GPMap>::key_type key_type;
29  typedef typename boost::property_traits<FPMap>::value_type value_type;
30  typedef typename boost::property_traits<FPMap>::reference reference;
31 
32  inline compose_property_map(const FPMap &f_p, const GPMap &g_p):
33  f(f_p), g(g_p)
34  {}
35 
36  inline compose_property_map() {}
37 
38  inline reference
39  operator[](const key_type &v) const {
40  return f[get(g, v)];
41  }
42 
43  // return type of get():
44  // if (reference is not a ref)
45  // value_type
46  // else if (reference is const)
47  // reference
48  // else
49  // const value_type&
50  inline friend typename boost::mpl::if_<
51  boost::mpl::not_< boost::is_reference<reference> >,
52  value_type,
53  typename boost::mpl::if_<
54  boost::is_const<reference>,
55  reference,
56  const value_type&
57  >::type
58  >::type
59  get(const compose_property_map &m, const key_type &k) {
60  return get(m.f, get(m.g, k));
61  }
62 
63  inline friend void
64  put(const compose_property_map &m, const key_type &k, const value_type &v) {
65  put(m.f, get(m.g, k), v);
66  }
67 
68 private:
69  FPMap f;
70  GPMap g;
71 };
72 
73 template <class FPMap, class GPMap>
75 make_compose_property_map(const FPMap &f, const GPMap &g) {
77 }
78 
79 } // namespace pr_bgl
80 
81 #endif // PR_BGL_PROPERTY_MAP_COMPOSE_PROPERTY_MAP_HPP
Definition: compose_property_map.hpp:24