xsi_shared_memory_file_wrapper.hpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2009-2012. 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. #ifndef BOOST_INTERPROCESS_XSI_SHARED_MEMORY_FILE_WRAPPER_HPP
  11. #define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_FILE_WRAPPER_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #
  16. #if defined(BOOST_HAS_PRAGMA_ONCE)
  17. # pragma once
  18. #endif
  19. #include <boost/interprocess/detail/config_begin.hpp>
  20. #include <boost/interprocess/detail/workaround.hpp>
  21. #include <boost/detail/workaround.hpp>
  22. #if !defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS)
  23. #error "This header can't be used in operating systems without XSI (System V) shared memory support"
  24. #endif
  25. #include <boost/interprocess/creation_tags.hpp>
  26. #include <boost/interprocess/exceptions.hpp>
  27. #include <boost/interprocess/detail/utilities.hpp>
  28. #include <boost/interprocess/detail/os_file_functions.hpp>
  29. #include <boost/interprocess/detail/shared_dir_helpers.hpp>
  30. #include <boost/interprocess/interprocess_fwd.hpp>
  31. #include <boost/interprocess/exceptions.hpp>
  32. #include <boost/interprocess/xsi_shared_memory.hpp>
  33. //!\file
  34. //!Describes a class representing a pseudo-file implemented on top of xsi shared memory.
  35. namespace boost {
  36. namespace interprocess {
  37. class xsi_shared_memory_file_wrapper
  38. : public xsi_shared_memory
  39. {
  40. #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  41. BOOST_MOVABLE_BUT_NOT_COPYABLE(xsi_shared_memory_file_wrapper)
  42. #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
  43. public:
  44. xsi_shared_memory_file_wrapper() : xsi_shared_memory() {}
  45. xsi_shared_memory_file_wrapper(create_only_t, const xsi_key &key, mode_t , std::size_t size, const permissions& perm = permissions())
  46. : xsi_shared_memory(create_only_t(), key, size, perm.get_permissions())
  47. {}
  48. xsi_shared_memory_file_wrapper(open_or_create_t, const xsi_key &key, mode_t , std::size_t size, const permissions& perm = permissions())
  49. : xsi_shared_memory(open_or_create_t(), key, size, perm.get_permissions())
  50. {}
  51. xsi_shared_memory_file_wrapper(open_only_t, const xsi_key &key, mode_t, const permissions& = permissions())
  52. : xsi_shared_memory(open_only_t(), key)
  53. {}
  54. xsi_shared_memory_file_wrapper(BOOST_RV_REF(xsi_shared_memory_file_wrapper) moved)
  55. { this->swap(moved); }
  56. xsi_shared_memory_file_wrapper &operator=(BOOST_RV_REF(xsi_shared_memory_file_wrapper) moved)
  57. {
  58. xsi_shared_memory_file_wrapper tmp(boost::move(moved));
  59. this->swap(tmp);
  60. return *this;
  61. }
  62. //!Swaps two xsi_shared_memory_file_wrapper. Does not throw
  63. void swap(xsi_shared_memory_file_wrapper &other)
  64. { this->xsi_shared_memory::swap(other); }
  65. };
  66. } //namespace interprocess {
  67. } //namespace boost {
  68. #include <boost/interprocess/detail/config_end.hpp>
  69. #endif //BOOST_INTERPROCESS_XSI_SHARED_MEMORY_FILE_WRAPPER_HPP