File indexing completed on 2026-05-10 08:23:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_MAP_INDEX_HPP
0012 #define BOOST_INTERPROCESS_MAP_INDEX_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 # pragma once
0021 #endif
0022
0023 #include <boost/interprocess/detail/config_begin.hpp>
0024 #include <boost/interprocess/detail/workaround.hpp>
0025
0026 #include <boost/intrusive/detail/minimal_pair_header.hpp>
0027 #include <boost/container/map.hpp>
0028 #include <boost/interprocess/allocators/private_adaptive_pool.hpp>
0029 #include <boost/intrusive/detail/minimal_pair_header.hpp> //std::pair
0030 #include <boost/intrusive/detail/minimal_less_equal_header.hpp> //std::less
0031
0032
0033
0034
0035
0036 namespace boost {
0037 namespace interprocess {
0038 namespace ipcdetail{
0039
0040
0041 template <class MapConfig>
0042 struct map_index_aux
0043 {
0044 typedef typename MapConfig::key_type key_type;
0045 typedef typename MapConfig::mapped_type mapped_type;
0046 typedef std::less<key_type> key_less;
0047 typedef std::pair<const key_type, mapped_type> value_type;
0048
0049 typedef private_adaptive_pool
0050 <value_type,
0051 typename MapConfig::
0052 segment_manager_base> allocator_type;
0053
0054 typedef boost::container::map
0055 <key_type, mapped_type,
0056 key_less, allocator_type> index_t;
0057 };
0058
0059 }
0060
0061
0062
0063 template <class MapConfig>
0064 class map_index
0065
0066 : private ipcdetail::map_index_aux<MapConfig>::index_t
0067 {
0068 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0069 typedef ipcdetail::map_index_aux<MapConfig> index_aux;
0070 typedef typename index_aux::index_t base_type;
0071 typedef typename MapConfig::
0072 segment_manager_base segment_manager_base;
0073 typedef typename base_type::key_type key_type;
0074 typedef typename base_type::mapped_type mapped_type;
0075
0076 #endif
0077
0078 public:
0079 using base_type::begin;
0080 using base_type::end;
0081 using base_type::size;
0082 using base_type::erase;
0083 typedef typename base_type::iterator iterator;
0084 typedef typename base_type::const_iterator const_iterator;
0085 typedef typename base_type::value_type value_type;
0086 typedef typename MapConfig::compare_key_type compare_key_type;
0087 typedef iterator insert_commit_data;
0088 typedef iterator index_data_t;
0089
0090
0091
0092 map_index(segment_manager_base *segment_mngr)
0093 : base_type(typename index_aux::key_less(),
0094 segment_mngr){}
0095
0096
0097
0098 void reserve(typename segment_manager_base::size_type)
0099 { }
0100
0101
0102
0103 void shrink_to_fit()
0104 { base_type::get_stored_allocator().deallocate_free_blocks(); }
0105
0106 std::pair<iterator, bool> insert_check
0107 (const compare_key_type& key, insert_commit_data& )
0108 {
0109 std::pair<iterator, bool> r;
0110 r.first = this->base_type::find(key_type(key.str(), key.len()));
0111 r.second = r.first == this->base_type::end();
0112 return r;
0113 }
0114
0115 iterator insert_commit
0116 (const compare_key_type &k, void *context, index_data_t &index_data, insert_commit_data& )
0117 {
0118
0119 iterator it = this->base_type::insert(value_type(key_type(k.str(), k.len()), mapped_type(context))).first;
0120 return (index_data = it);
0121 }
0122
0123 iterator find(const compare_key_type& k)
0124 { return this->base_type::find(key_type(k.str(), k.len())); }
0125 };
0126
0127 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0128
0129
0130
0131
0132 template<class MapConfig>
0133 struct is_node_index
0134 <boost::interprocess::map_index<MapConfig> >
0135 {
0136 static const bool value = true;
0137 };
0138 #endif
0139
0140 }}
0141
0142 #include <boost/interprocess/detail/config_end.hpp>
0143
0144 #endif