Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:28

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 #ifndef BOOST_INTERPROCESS_FLAT_MAP_INDEX_HPP
0011 #define BOOST_INTERPROCESS_FLAT_MAP_INDEX_HPP
0012 
0013 #ifndef BOOST_CONFIG_HPP
0014 #  include <boost/config.hpp>
0015 #endif
0016 #
0017 #if defined(BOOST_HAS_PRAGMA_ONCE)
0018 #  pragma once
0019 #endif
0020 
0021 #include <boost/interprocess/detail/config_begin.hpp>
0022 #include <boost/interprocess/detail/workaround.hpp>
0023 
0024 // interprocess
0025 #include <boost/interprocess/containers/flat_map.hpp>
0026 #include <boost/interprocess/allocators/allocator.hpp>
0027 // intrusive/detail
0028 #include <boost/intrusive/detail/minimal_pair_header.hpp>         //std::pair
0029 #include <boost/intrusive/detail/minimal_less_equal_header.hpp>   //std::less
0030 
0031 
0032 //!\file
0033 //!Describes index adaptor of boost::map container, to use it
0034 //!as name/shared memory index
0035 
0036 //[flat_map_index
0037 namespace boost { namespace interprocess {
0038 
0039 #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0040 
0041 //!Helper class to define typedefs from IndexTraits
0042 template <class MapConfig>
0043 struct flat_map_index_aux
0044 {
0045    typedef typename MapConfig::key_type            key_type;
0046    typedef typename MapConfig::mapped_type         mapped_type;
0047    typedef typename MapConfig::
0048       segment_manager_base                   segment_manager_base;
0049    typedef std::less<key_type>                     key_less;
0050    typedef std::pair<key_type, mapped_type>        value_type;
0051    typedef allocator<value_type
0052                     ,segment_manager_base>   allocator_type;
0053    typedef flat_map<key_type,  mapped_type,
0054                     key_less, allocator_type>      index_t;
0055 };
0056 
0057 #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0058 
0059 //!Index type based in flat_map. Just derives from flat_map and
0060 //!defines the interface needed by managed memory segments.
0061 template <class MapConfig>
0062 class flat_map_index
0063    //Derive class from flat_map specialization
0064    : public flat_map_index_aux<MapConfig>::index_t
0065 {
0066    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0067    typedef flat_map_index_aux<MapConfig>  index_aux;
0068    typedef typename index_aux::index_t    base_type;
0069    typedef typename index_aux::
0070       segment_manager_base          segment_manager_base;
0071    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0072 
0073    public:
0074    //!Constructor. Takes a pointer to the segment manager. Can throw
0075    flat_map_index(segment_manager_base *segment_mngr)
0076       : base_type(typename index_aux::key_less(),
0077                   typename index_aux::allocator_type(segment_mngr))
0078    {}
0079 
0080    //!This reserves memory to optimize the insertion of n elements in the index
0081    void reserve(typename segment_manager_base::size_type n)
0082    {  base_type::reserve(n);  }
0083 
0084    //!This frees all unnecessary memory
0085    void shrink_to_fit()
0086    {  base_type::shrink_to_fit();   }
0087 };
0088 
0089 }}   //namespace boost { namespace interprocess
0090 //]
0091 #include <boost/interprocess/detail/config_end.hpp>
0092 
0093 #endif   //#ifndef BOOST_INTERPROCESS_FLAT_MAP_INDEX_HPP