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_MANAGED_EXTERNAL_BUFFER_HPP Chris@16: #define BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_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@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@101: #include Chris@16: #include Chris@16: //These includes needed to fulfill default template parameters of Chris@16: //predeclarations in interprocess_fwd.hpp Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: //!\file Chris@16: //!Describes a named user memory allocation user class. Chris@16: Chris@16: namespace boost { Chris@16: namespace interprocess { Chris@16: Chris@16: //!A basic user memory named object creation class. Inherits all Chris@16: //!basic functionality from Chris@16: //!basic_managed_memory_impl*/ Chris@16: template Chris@16: < Chris@16: class CharType, Chris@16: class AllocationAlgorithm, Chris@16: template class IndexType Chris@16: > Chris@16: class basic_managed_external_buffer Chris@16: : public ipcdetail::basic_managed_memory_impl Chris@16: { Chris@101: #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) Chris@16: typedef ipcdetail::basic_managed_memory_impl Chris@16: base_t; Chris@16: BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_managed_external_buffer) Chris@101: #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@16: Chris@16: public: Chris@16: typedef typename base_t::size_type size_type; Chris@16: Chris@16: //!Default constructor. Does nothing. Chris@16: //!Useful in combination with move semantics Chris@16: basic_managed_external_buffer() Chris@16: {} Chris@16: Chris@16: //!Creates and places the segment manager. This can throw Chris@16: basic_managed_external_buffer Chris@16: (create_only_t, void *addr, size_type size) Chris@16: { Chris@16: //Check if alignment is correct Chris@16: BOOST_ASSERT((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - size_type(1u))))); Chris@16: if(!base_t::create_impl(addr, size)){ Chris@16: throw interprocess_exception("Could not initialize buffer in basic_managed_external_buffer constructor"); Chris@16: } Chris@16: } Chris@16: Chris@16: //!Creates and places the segment manager. This can throw Chris@16: basic_managed_external_buffer Chris@16: (open_only_t, void *addr, size_type size) Chris@16: { Chris@16: //Check if alignment is correct Chris@16: BOOST_ASSERT((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - size_type(1u))))); Chris@16: if(!base_t::open_impl(addr, size)){ Chris@16: throw interprocess_exception("Could not initialize buffer in basic_managed_external_buffer constructor"); Chris@16: } Chris@16: } Chris@16: Chris@16: //!Moves the ownership of "moved"'s managed memory to *this. Does not throw Chris@16: basic_managed_external_buffer(BOOST_RV_REF(basic_managed_external_buffer) moved) Chris@16: { Chris@16: this->swap(moved); Chris@16: } Chris@16: Chris@16: //!Moves the ownership of "moved"'s managed memory to *this. Does not throw Chris@16: basic_managed_external_buffer &operator=(BOOST_RV_REF(basic_managed_external_buffer) moved) Chris@16: { Chris@16: basic_managed_external_buffer tmp(boost::move(moved)); Chris@16: this->swap(tmp); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: void grow(size_type extra_bytes) Chris@16: { base_t::grow(extra_bytes); } Chris@16: Chris@16: //!Swaps the ownership of the managed heap memories managed by *this and other. Chris@16: //!Never throws. Chris@16: void swap(basic_managed_external_buffer &other) Chris@16: { base_t::swap(other); } Chris@16: }; Chris@16: Chris@101: #ifdef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@101: Chris@101: //!Typedef for a default basic_managed_external_buffer Chris@101: //!of narrow characters Chris@101: typedef basic_managed_external_buffer Chris@101: Chris@101: ,iset_index> Chris@101: managed_external_buffer; Chris@101: Chris@101: //!Typedef for a default basic_managed_external_buffer Chris@101: //!of wide characters Chris@101: typedef basic_managed_external_buffer Chris@101: Chris@101: ,iset_index> Chris@101: wmanaged_external_buffer; Chris@101: Chris@101: #endif //#ifdef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@101: Chris@16: } //namespace interprocess { Chris@16: } //namespace boost { Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP Chris@16: