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: Chris@16: #ifndef BOOST_INTERPROCESS_MAP_INDEX_HPP Chris@16: #define BOOST_INTERPROCESS_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: #include Chris@16: #include Chris@16: #include Chris@101: #include //std::pair Chris@101: #include //std::less 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: namespace boost { Chris@16: namespace interprocess { Chris@16: namespace ipcdetail{ Chris@16: Chris@16: //!Helper class to define typedefs from IndexTraits Chris@16: template Chris@16: struct 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 std::less key_less; Chris@16: typedef std::pair value_type; Chris@16: Chris@16: typedef private_adaptive_pool Chris@16: allocator_type; Chris@16: Chris@16: typedef boost::interprocess::map Chris@16: index_t; Chris@16: }; Chris@16: Chris@16: } //namespace ipcdetail { Chris@16: Chris@16: //!Index type based in boost::interprocess::map. Just derives from boost::interprocess::map Chris@16: //!and defines the interface needed by managed memory segments Chris@16: template Chris@16: class map_index Chris@16: //Derive class from map specialization Chris@16: : public ipcdetail::map_index_aux::index_t Chris@16: { Chris@101: #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) Chris@16: typedef ipcdetail::map_index_aux index_aux; Chris@16: typedef typename index_aux::index_t base_type; Chris@16: typedef typename MapConfig:: 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 Chris@16: //!segment manager. Can throw Chris@16: map_index(segment_manager_base *segment_mngr) Chris@16: : base_type(typename index_aux::key_less(), Chris@16: segment_mngr){} Chris@16: Chris@16: //!This reserves memory to optimize the insertion of n Chris@16: //!elements in the index Chris@16: void reserve(typename segment_manager_base::size_type) Chris@16: { /*Does nothing, map has not reserve or rehash*/ } Chris@16: Chris@16: //!This tries to free previously allocate Chris@16: //!unused memory. Chris@16: void shrink_to_fit() Chris@16: { base_type::get_stored_allocator().deallocate_free_blocks(); } Chris@16: }; Chris@16: Chris@101: #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) Chris@16: Chris@16: //!Trait class to detect if an index is a node Chris@16: //!index. This allows more efficient operations Chris@16: //!when deallocating named objects. Chris@16: template Chris@16: struct is_node_index Chris@16: > Chris@16: { Chris@16: static const bool value = true; Chris@16: }; Chris@101: #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@16: Chris@16: }} //namespace boost { namespace interprocess { Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //#ifndef BOOST_INTERPROCESS_MAP_INDEX_HPP