Boost C++ Libraries Boost.Bimap Home Libraries People FAQ More

PrevUpHomeNext

manage_additional_parameters.hpp

Go to the documentation of this file.
00001 // Boost.Bimap
00002 //
00003 // Copyright (c) 2006-2007 Matias Capeletto
00004 //
00005 // Distributed under the Boost Software License, Version 1.0.
00006 // (See accompanying file LICENSE_1_0.txt or copy at
00007 // http://www.boost.org/LICENSE_1_0.txt)
00008 
00009 /// \file detail/manage_additional_parameters.hpp
00010 /// \brief Utility class to extract the additional parameters from the template parameters.
00011 
00012 #ifndef BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
00013 #define BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
00014 
00015 #if defined(_MSC_VER) && (_MSC_VER>=1200)
00016 #pragma once
00017 #endif
00018 
00019 #include <boost/config.hpp>
00020 
00021 #include <memory>
00022 
00023 // Boost.MPL
00024 #include <boost/mpl/bool.hpp>
00025 #include <boost/mpl/if.hpp>
00026 #include <boost/mpl/aux_/na.hpp>
00027 #include <boost/type_traits/is_same.hpp>
00028 
00029 #include <boost/bimap/detail/is_set_type_of.hpp>
00030 
00031 namespace boost {
00032 namespace bimaps {
00033 namespace detail {
00034 
00035 /// \brief Metafunction to check if a given type is a data_hook specification.
00036 
00037 template< class Type >
00038 struct is_data_hook : ::boost::mpl::false_ {};
00039 
00040 /** \struct boost::bimaps::detail::manage_additional_parameters
00041 \brief Utility class to extract the additional parameters from the template parameters.
00042 
00043 \code
00044 template< class AP1, class AP2, class AP3 >
00045 struct manage_additional_parameters
00046 {
00047     struct parameters
00048     {
00049         typedef -unspecified- set_type_of_relation;
00050         typedef -unspecified- data_hook;
00051         typedef -unspecified- allocator;
00052     };
00053 
00054     typedef parameters type;
00055 };
00056 \endcode
00057 
00058 See also bimap, bimap_core.
00059                                                                                 **/
00060 
00061 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
00062 
00063 template< class AP1, class AP2, class AP3 >
00064 struct manage_additional_parameters
00065 {
00066     // (1) manage_additional_parameters<
00067     //         not_specified,not_specified,not_specified>
00068     //
00069     //     set_type_of_relation: based on the left key type
00070     //     hook_data:            no additional data
00071     //     allocator:            default allocator
00072 
00073     struct case_NNN
00074     {
00075         typedef left_based set_type_of_relation;
00076         typedef std::allocator<void> allocator;
00077     };
00078 
00079     // (2) manage_additional_parameters<Allocator,not_specified,not_specified>
00080     //
00081     //     set_type_of_relation: based on the left key type
00082     //     hook_data:            no additional data
00083     //     allocator:            Allocator
00084 
00085     struct case_ANN
00086     {
00087         typedef left_based set_type_of_relation;
00088         typedef AP1 allocator;
00089     };
00090 
00091     // (3) manage_additional_parameters<
00092     //         SetOfRelationType,not_specified,not_specified>
00093     //
00094     //     set_type_of_relation: SetTypeOfRelation
00095     //     hook_data:            no additional data
00096     //     allocator:            default allocator
00097 
00098     struct case_SNN
00099     {
00100         typedef AP1 set_type_of_relation;
00101         typedef std::allocator<void> allocator;
00102     };
00103 
00104     // (4) manage_additional_parameters<
00105     //          SetTypeOfRelation,Allocator,not_specified>
00106     //
00107     //     set_type_of_relation: SetTypeOfRelation
00108     //     hook_data:            no additional data
00109     //     allocator:            Allocator
00110 
00111     struct case_SAN
00112     {
00113         typedef AP1 set_type_of_relation;
00114         typedef AP2 allocator;
00115     };
00116 
00117     // (5) manage_additional_parameters<DataToHook,not_specified,not_specified>
00118     //
00119     //     set_type_of_relation: based on the left key type
00120     //     hook_data:            DataToHook
00121     //     allocator:            default allocator
00122 
00123     struct case_HNN
00124     {
00125         typedef left_based set_type_of_relation;
00126         typedef std::allocator<void> allocator;
00127     };
00128 
00129     // (6) manage_additional_parameters<
00130     //         SetTypeOfRelation,DataToHook,not_specified>
00131     //
00132     //     set_type_of_relation: SetTypeOfRelation
00133     //     hook_data:            DataToHook
00134     //     allocator:            default allocator
00135 
00136     struct case_SHN
00137     {
00138         typedef AP1 set_type_of_relation;
00139         typedef std::allocator<void> allocator;
00140     };
00141 
00142     // (7) manage_additional_parameters<
00143     //         DataToHook,Allocator,not_specified>
00144     //
00145     //     set_type_of_relation: SetTypeOfRelation
00146     //     hook_data:            DataToHook
00147     //     allocator:            default allocator
00148 
00149     struct case_HAN
00150     {
00151         typedef left_based set_type_of_relation;
00152         typedef AP2 allocator;
00153     };
00154 
00155     // (8) manage_additional_parameters<
00156     //         SetTypeOfRelation,DataToHook,Allocator>
00157     //
00158     //     set_type_of_relation: SetTypeOfRelation
00159     //     hook_data:            DataToHook
00160     //     allocator:            Allocator
00161 
00162     struct case_SHA
00163     {
00164         typedef AP1 set_type_of_relation;
00165         typedef AP2 allocator;
00166     };
00167 
00168     // Some annidated mpl::if_ and we are done!
00169 
00170     typedef BOOST_DEDUCED_TYPENAME mpl::if_
00171     <
00172         ::boost::mpl::is_na<AP1>,
00173         case_NNN, // (1)
00174         BOOST_DEDUCED_TYPENAME mpl::if_
00175         <
00176             ::boost::mpl::is_na<AP2>,
00177             BOOST_DEDUCED_TYPENAME mpl::if_
00178             <
00179                 is_set_type_of_relation<AP1>,
00180                 case_SNN, // (3)
00181                 BOOST_DEDUCED_TYPENAME mpl::if_
00182                 <
00183                     is_data_hook<AP1>,
00184                     case_HNN, // (5)
00185                     case_ANN  // (2)
00186 
00187                 >::type
00188 
00189             >::type,
00190             BOOST_DEDUCED_TYPENAME mpl::if_
00191             <
00192                 ::boost::mpl::is_na<AP3>,
00193                 BOOST_DEDUCED_TYPENAME mpl::if_
00194                 <
00195                     is_data_hook<AP1>,
00196                     case_HAN, // (7)
00197                     BOOST_DEDUCED_TYPENAME mpl::if_
00198                     <
00199                         is_data_hook<AP2>,
00200                         case_SHN, // (6)
00201                         case_SAN  // (4)
00202 
00203                     >::type
00204 
00205                 >::type,
00206 
00207                 case_SHA // (8)
00208 
00209             >::type
00210 
00211         >::type
00212 
00213     >::type type;
00214 
00215 };
00216 
00217 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
00218 
00219 } // namespace detail
00220 } // namespace bimaps
00221 } // namespace boost
00222 
00223 
00224 #endif // BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
00225 
Copyright 2006 Matias Capeletto

PrevUpHomeNext