• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Bimap
2 //
3 // Copyright (c) 2006-2007 Matias Capeletto
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 /// \file relation/support/data_extractor.hpp
10 /// \brief Data extraction functor.
11 
12 #ifndef BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
13 #define BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
14 
15 #if defined(_MSC_VER)
16 #pragma once
17 #endif
18 
19 #include <boost/config.hpp>
20 
21 #include <boost/bimap/relation/detail/metadata_access_builder.hpp>
22 
23 /** \struct boost::bimaps::relation::support::data_extractor
24 
25 \brief Data extraction functor.
26 
27 \ingroup relation_group
28                                                                     **/
29 
30 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
31 
32 namespace boost {
33 namespace bimaps {
34 namespace relation {
35 namespace support {
36 
37 template< class Tag, class Relation >
38 struct data_extractor_implementation;
39 
40 template< class Relation >
41 struct data_extractor_implementation< member_at::left, Relation >
42 {
43     typedef Relation argument_type;
44     typedef BOOST_DEDUCED_TYPENAME Relation::left_value_type result_type;
45 
46     BOOST_DEDUCED_TYPENAME Relation::left_value_type const &
operator ()boost::bimaps::relation::support::data_extractor_implementation47         operator()(Relation const & rel) const
48     {
49         return rel.left;
50     }
51 
52     BOOST_DEDUCED_TYPENAME Relation::left_value_type &
operator ()boost::bimaps::relation::support::data_extractor_implementation53         operator()(Relation       & rel) const
54     {
55         return rel.left;
56     }
57 };
58 
59 template< class Relation >
60 struct data_extractor_implementation< member_at::right, Relation >
61 {
62     typedef Relation argument_type;
63     typedef BOOST_DEDUCED_TYPENAME Relation::right_value_type result_type;
64 
65     BOOST_DEDUCED_TYPENAME Relation::right_value_type const &
operator ()boost::bimaps::relation::support::data_extractor_implementation66         operator()(Relation const & rel) const
67     {
68         return rel.right;
69     }
70 
71     BOOST_DEDUCED_TYPENAME Relation::right_value_type &
operator ()boost::bimaps::relation::support::data_extractor_implementation72         operator()(Relation       & rel) const
73     {
74         return rel.right;
75     }
76 };
77 
78 template< class Tag, class Relation >
79 struct data_extractor
80 {
81     typedef data_extractor_implementation
82     <
83         BOOST_DEDUCED_TYPENAME member_with_tag<Tag,Relation>::type,
84         Relation
85 
86     > type;
87 };
88 
89 template< class Relation >
90 struct both_keys_extractor
91 {
92     typedef BOOST_DEDUCED_TYPENAME Relation::storage_base result_type;
93 
operator ()boost::bimaps::relation::support::both_keys_extractor94      const result_type & operator()(const Relation & rel) const
95     {
96         return rel;
97     }
98 
operator ()boost::bimaps::relation::support::both_keys_extractor99     result_type & operator()( Relation & rel) const
100     {
101         return rel;
102     }
103 };
104 
105 } // namespace support
106 } // namespace relation
107 } // namespace bimaps
108 } // namespace boost
109 
110 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
111 
112 #endif // BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
113 
114