PageRenderTime 17ms CodeModel.GetById 9ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/interprocess/managed_external_buffer.hpp

http://hadesmem.googlecode.com/
C++ Header | 107 lines | 63 code | 18 blank | 26 comment | 5 complexity | bc95b4bb2cc4eb03227b8c867656ae49 MD5 | raw file
  1//////////////////////////////////////////////////////////////////////////////
  2//
  3// (C) Copyright Ion Gaztanaga 2005-2009. Distributed under the Boost
  4// Software License, Version 1.0. (See accompanying file
  5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6//
  7// See http://www.boost.org/libs/interprocess for documentation.
  8//
  9//////////////////////////////////////////////////////////////////////////////
 10
 11#ifndef BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
 12#define BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
 13
 14#if (defined _MSC_VER) && (_MSC_VER >= 1200)
 15#  pragma once
 16#endif
 17
 18#include <boost/interprocess/detail/config_begin.hpp>
 19#include <boost/interprocess/detail/workaround.hpp>
 20#include <boost/interprocess/creation_tags.hpp>
 21#include <boost/interprocess/detail/managed_memory_impl.hpp>
 22#include <boost/interprocess/detail/move.hpp>
 23#include <boost/assert.hpp>
 24
 25//!\file
 26//!Describes a named user memory allocation user class. 
 27
 28namespace boost {
 29namespace interprocess {
 30
 31//!A basic user memory named object creation class. Inherits all 
 32//!basic functionality from 
 33//!basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>*/
 34template
 35      <
 36         class CharType, 
 37         class AllocationAlgorithm, 
 38         template<class IndexConfig> class IndexType
 39      >
 40class basic_managed_external_buffer 
 41   : public detail::basic_managed_memory_impl <CharType, AllocationAlgorithm, IndexType>
 42{
 43   /// @cond
 44   typedef detail::basic_managed_memory_impl 
 45      <CharType, AllocationAlgorithm, IndexType>    base_t;
 46   BOOST_INTERPROCESS_MOVABLE_BUT_NOT_COPYABLE(basic_managed_external_buffer)
 47   /// @endcond
 48   
 49   public:
 50
 51   //!Default constructor. Does nothing.
 52   //!Useful in combination with move semantics
 53   basic_managed_external_buffer()
 54   {}
 55
 56   //!Creates and places the segment manager. This can throw
 57   basic_managed_external_buffer
 58      (create_only_t, void *addr, std::size_t size)
 59   {
 60      //Check if alignment is correct
 61      BOOST_ASSERT((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - std::size_t(1u)))));
 62      if(!base_t::create_impl(addr, size)){
 63         throw interprocess_exception("Could not initialize buffer in basic_managed_external_buffer constructor");
 64      }
 65   }
 66
 67   //!Creates and places the segment manager. This can throw
 68   basic_managed_external_buffer
 69      (open_only_t, void *addr, std::size_t size)
 70   {
 71      //Check if alignment is correct
 72      BOOST_ASSERT((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - std::size_t(1u)))));
 73      if(!base_t::open_impl(addr, size)){
 74         throw interprocess_exception("Could not initialize buffer in basic_managed_external_buffer constructor");
 75      }
 76   }
 77
 78   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
 79   basic_managed_external_buffer(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer) moved)
 80   {
 81      this->swap(moved);
 82   }
 83
 84   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
 85   basic_managed_external_buffer &operator=(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer) moved)
 86   {
 87      basic_managed_external_buffer tmp(boost::interprocess::move(moved));
 88      this->swap(tmp);
 89      return *this;
 90   }
 91
 92   void grow(std::size_t extra_bytes)
 93   {  base_t::grow(extra_bytes);   }
 94
 95   //!Swaps the ownership of the managed heap memories managed by *this and other.
 96   //!Never throws.
 97   void swap(basic_managed_external_buffer &other)
 98   {  base_t::swap(other); }
 99};
100
101}  //namespace interprocess {
102}  //namespace boost {
103
104#include <boost/interprocess/detail/config_end.hpp>
105
106#endif   //BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
107