Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/interprocess for documentation. Chris@16: // Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: #ifndef BOOST_INTERPROCESS_FLAT_MAP_INDEX_HPP Chris@16: #define BOOST_INTERPROCESS_FLAT_MAP_INDEX_HPP Chris@16: Chris@101: #ifndef BOOST_CONFIG_HPP Chris@101: # include Chris@101: #endif Chris@101: # Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@101: # pragma once Chris@101: #endif Chris@101: Chris@16: #include Chris@16: #include Chris@16: Chris@101: // interprocess Chris@16: #include Chris@16: #include Chris@101: // intrusive/detail Chris@101: #include //std::pair Chris@101: #include //std::less Chris@101: Chris@16: Chris@16: //!\file Chris@16: //!Describes index adaptor of boost::map container, to use it Chris@16: //!as name/shared memory index Chris@16: Chris@16: //[flat_map_index Chris@16: namespace boost { namespace interprocess { Chris@16: Chris@101: #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@101: Chris@16: //!Helper class to define typedefs from IndexTraits Chris@16: template Chris@16: struct flat_map_index_aux Chris@16: { Chris@16: typedef typename MapConfig::key_type key_type; Chris@16: typedef typename MapConfig::mapped_type mapped_type; Chris@16: typedef typename MapConfig:: Chris@16: segment_manager_base segment_manager_base; Chris@16: typedef std::less key_less; Chris@16: typedef std::pair value_type; Chris@16: typedef allocator allocator_type; Chris@16: typedef flat_map index_t; Chris@16: }; Chris@16: Chris@101: #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@101: Chris@16: //!Index type based in flat_map. Just derives from flat_map and Chris@16: //!defines the interface needed by managed memory segments. Chris@16: template Chris@16: class flat_map_index Chris@16: //Derive class from flat_map specialization Chris@16: : public flat_map_index_aux::index_t Chris@16: { Chris@101: #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) Chris@16: typedef flat_map_index_aux index_aux; Chris@16: typedef typename index_aux::index_t base_type; Chris@16: typedef typename index_aux:: Chris@16: segment_manager_base segment_manager_base; Chris@101: #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@16: Chris@16: public: Chris@16: //!Constructor. Takes a pointer to the segment manager. Can throw Chris@16: flat_map_index(segment_manager_base *segment_mngr) Chris@16: : base_type(typename index_aux::key_less(), Chris@16: typename index_aux::allocator_type(segment_mngr)) Chris@16: {} Chris@16: Chris@16: //!This reserves memory to optimize the insertion of n elements in the index Chris@16: void reserve(typename segment_manager_base::size_type n) Chris@16: { base_type::reserve(n); } Chris@16: Chris@16: //!This frees all unnecessary memory Chris@16: void shrink_to_fit() Chris@16: { base_type::shrink_to_fit(); } Chris@16: }; Chris@16: Chris@16: }} //namespace boost { namespace interprocess Chris@16: //] Chris@16: #include Chris@16: Chris@16: #endif //#ifndef BOOST_INTERPROCESS_FLAT_MAP_INDEX_HPP