Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74010 - in sandbox/mmap/boost/mmap: . detail handles handles/posix handles/win32 mappble_objects/file mappble_objects/file/posix mappble_objects/file/win32
From: dsaritz_at_[hidden]
Date: 2011-08-22 17:54:53


Author: psiha
Date: 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
New Revision: 74010
URL: http://svn.boost.org/trac/boost/changeset/74010

Log:
Replaced explicit classic separate/prefixed class names for different implementations with tag-specialized class templates.
Added the handle_ref class template.
Added:
   sandbox/mmap/boost/mmap/handles/handle_ref.hpp
      - copied, changed from r74004, /sandbox/mmap/boost/mmap/handles/handle.hpp
   sandbox/mmap/boost/mmap/handles/mapping_handle.hpp
      - copied, changed from r74004, /sandbox/mmap/boost/mmap/handles/handle.hpp
   sandbox/mmap/boost/mmap/implementations.hpp (contents, props changed)
Text files modified:
   sandbox/mmap/boost/mmap/detail/impl_selection.hpp | 6 ++--
   sandbox/mmap/boost/mmap/handles/handle.hpp | 13 +++-------
   sandbox/mmap/boost/mmap/handles/handle_ref.hpp | 35 ++++++++++++++---------------
   sandbox/mmap/boost/mmap/handles/mapping_handle.hpp | 31 ++++++++++++-------------
   sandbox/mmap/boost/mmap/handles/posix/handle.hpp | 25 ++++++++++++++------
   sandbox/mmap/boost/mmap/handles/posix/handle.inl | 10 ++++----
   sandbox/mmap/boost/mmap/handles/win32/handle.hpp | 25 +++++++++++++++-----
   sandbox/mmap/boost/mmap/handles/win32/handle.inl | 8 +++---
   sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp | 20 ++++------------
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp | 17 ++++++++++---
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl | 8 +++---
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp | 9 +++++--
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl | 40 ++++++++++++++++----------------
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp | 13 +++++++---
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl | 8 +++---
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp | 9 +++++--
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl | 48 ++++++++++++++++++++++-----------------
   sandbox/mmap/boost/mmap/mapped_view.hpp | 35 +++++++++++++++--------------
   sandbox/mmap/boost/mmap/mapped_view.inl | 32 +++++++++++++-------------
   19 files changed, 211 insertions(+), 181 deletions(-)

Modified: sandbox/mmap/boost/mmap/detail/impl_selection.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/detail/impl_selection.hpp (original)
+++ sandbox/mmap/boost/mmap/detail/impl_selection.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -21,11 +21,11 @@
 #include "boost/preprocessor/stringize.hpp"
 //------------------------------------------------------------------------------
 #if defined( _WIN32 )
- #define BOOST_MMAP_IMPL /win32/
+ #define BOOST_MMAP_IMPL win32
 #elif defined( _WIN32_WINNT )
- #define BOOST_MMAP_IMPL /nt/
+ #define BOOST_MMAP_IMPL nt
 #elif defined( BOOST_HAS_UNISTD_H )
- #define BOOST_MMAP_IMPL /posix/
+ #define BOOST_MMAP_IMPL posix
 #endif
 
 #define BOOST_MMAP_IMPL_INCLUDE( prefix_path, include ) \

Modified: sandbox/mmap/boost/mmap/handles/handle.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/handles/handle.hpp (original)
+++ sandbox/mmap/boost/mmap/handles/handle.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -19,7 +19,7 @@
 //------------------------------------------------------------------------------
 #include "../detail/impl_selection.hpp"
 
-#include BOOST_MMAP_IMPL_INCLUDE( ., handle.hpp )
+#include BOOST_MMAP_IMPL_INCLUDE( ./, /handle.hpp )
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -28,14 +28,9 @@
 {
 //------------------------------------------------------------------------------
 
-#ifdef _WIN32
- typedef windows_handle native_handle;
- typedef win32_file_flags native_file_flags;
-#else
- typedef posix_handle native_handle;
- typedef posix_file_flags native_file_flags;
-#endif // _WIN32
-typedef native_handle::handle_t native_handle_t;
+template <typename Impl> class handle;
+
+typedef handle<BOOST_MMAP_IMPL> native_handle;
 
 //------------------------------------------------------------------------------
 } // namespace mmap

Copied: sandbox/mmap/boost/mmap/handles/handle_ref.hpp (from r74004, /sandbox/mmap/boost/mmap/handles/handle.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/handles/handle.hpp (original)
+++ sandbox/mmap/boost/mmap/handles/handle_ref.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -1,9 +1,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file handle.hpp
-/// ----------------
+/// \file handle_ref.hpp
+/// --------------------
 ///
-/// Copyright (c) Domagoj Saric 2011.
+/// Copyright (c) 2011 Domagoj Saric
 ///
 /// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
 /// (See accompanying file LICENSE_1_0.txt or copy at
@@ -13,14 +13,10 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef handle_hpp__67A36E06_53FF_4361_9786_9E04A3917CD3
-#define handle_hpp__67A36E06_53FF_4361_9786_9E04A3917CD3
+#ifndef handle_ref_hpp__19A59763_A268_458C_932F_4E42DEA27751
+#define handle_ref_hpp__19A59763_A268_458C_932F_4E42DEA27751
 #pragma once
 //------------------------------------------------------------------------------
-#include "../detail/impl_selection.hpp"
-
-#include BOOST_MMAP_IMPL_INCLUDE( ., handle.hpp )
-//------------------------------------------------------------------------------
 namespace boost
 {
 //------------------------------------------------------------------------------
@@ -28,18 +24,21 @@
 {
 //------------------------------------------------------------------------------
 
-#ifdef _WIN32
- typedef windows_handle native_handle;
- typedef win32_file_flags native_file_flags;
-#else
- typedef posix_handle native_handle;
- typedef posix_file_flags native_file_flags;
-#endif // _WIN32
-typedef native_handle::handle_t native_handle_t;
+template <typename Handle>
+struct handle_ref
+{
+ typedef typename Handle::native_handle_t native_handle_t;
+
+ handle_ref( native_handle_t const value_param ) : value( value_param ) {}
+
+ operator native_handle_t const & () const { return value; }
+
+ native_handle_t const value;
+};
 
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // handle_hpp
+#endif // handle_ref_hpp

Copied: sandbox/mmap/boost/mmap/handles/mapping_handle.hpp (from r74004, /sandbox/mmap/boost/mmap/handles/handle.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/handles/handle.hpp (original)
+++ sandbox/mmap/boost/mmap/handles/mapping_handle.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -1,9 +1,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file handle.hpp
-/// ----------------
+/// \file mapping_handle.hpp
+/// ------------------------
 ///
-/// Copyright (c) Domagoj Saric 2011.
+/// Copyright (c) 2011 Domagoj Saric
 ///
 /// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
 /// (See accompanying file LICENSE_1_0.txt or copy at
@@ -13,13 +13,11 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef handle_hpp__67A36E06_53FF_4361_9786_9E04A3917CD3
-#define handle_hpp__67A36E06_53FF_4361_9786_9E04A3917CD3
+#ifndef mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
+#define mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
 #pragma once
 //------------------------------------------------------------------------------
-#include "../detail/impl_selection.hpp"
-
-#include BOOST_MMAP_IMPL_INCLUDE( ., handle.hpp )
+#include "handle.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -28,14 +26,15 @@
 {
 //------------------------------------------------------------------------------
 
-#ifdef _WIN32
- typedef windows_handle native_handle;
- typedef win32_file_flags native_file_flags;
-#else
- typedef posix_handle native_handle;
- typedef posix_file_flags native_file_flags;
-#endif // _WIN32
-typedef native_handle::handle_t native_handle_t;
+template <typename Impl> class handle;
+
+template <typename Impl>
+class mapping_handle : handle<Impl>
+{
+public:
+ mapping_handle( typename handle<Impl>::handle_t const native_handle )
+ : handle<Impl>( native_handle ) {}
+};
 
 //------------------------------------------------------------------------------
 } // namespace mmap

Modified: sandbox/mmap/boost/mmap/handles/posix/handle.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/handles/posix/handle.hpp (original)
+++ sandbox/mmap/boost/mmap/handles/posix/handle.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -17,8 +17,10 @@
 #define handle_hpp__63113526_C3F1_46DC_850E_D8D8C62031DB
 #pragma once
 //------------------------------------------------------------------------------
-#include "boost/config.hpp"
+#include "../handle_ref.hpp"
+#include "../../implementations.hpp"
 
+#include "boost/config.hpp"
 #include "boost/noncopyable.hpp"
 //------------------------------------------------------------------------------
 namespace boost
@@ -28,25 +30,32 @@
 {
 //------------------------------------------------------------------------------
 
-class posix_handle
+template <typename Impl> class handle;
+
+template <>
+class handle<posix>
 #ifdef BOOST_MSVC
     : noncopyable
 #endif // BOOST_MSVC
 {
 public:
- typedef int handle_t;
+ typedef int native_handle_t;
+ typedef handle_ref< handle<posix> > reference;
 
- explicit posix_handle( handle_t );
+ explicit handle<posix>( native_handle_t );
     #ifndef BOOST_MSVC
- posix_handle( posix_handle const & );
+ handle<posix>( handle<posix> const & );
     #endif // BOOST_MSVC
 
- ~posix_handle();
+ ~handle<posix>();
+
+ native_handle_t const & get() const { return handle_; }
 
- handle_t const & handle() const { return handle_; }
+ bool operator! () const { return !handle_; }
+ operator reference () const { return reference( handle_ ); }
 
 private:
- handle_t const handle_;
+ native_handle_t const handle_;
 };
 
 //------------------------------------------------------------------------------

Modified: sandbox/mmap/boost/mmap/handles/posix/handle.inl
==============================================================================
--- sandbox/mmap/boost/mmap/handles/posix/handle.inl (original)
+++ sandbox/mmap/boost/mmap/handles/posix/handle.inl 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -39,20 +39,20 @@
 //------------------------------------------------------------------------------
 
 BOOST_IMPL_INLINE
-posix_handle::posix_handle( handle_t const handle )
+handle<posix>::handle( native_handle_t const handle )
     :
     handle_( handle )
 {}
 
 BOOST_IMPL_INLINE
-posix_handle::~posix_handle()
+handle<posix>::~handle()
 {
     BOOST_VERIFY
     (
- ( ::close( handle() ) == 0 ) ||
+ ( ::close( handle_ ) == 0 ) ||
         (
- ( handle() == -1 ) &&
- ( errno == EBADF )
+ ( handle_ == -1 ) &&
+ ( errno == EBADF )
         )
     );
 }

Modified: sandbox/mmap/boost/mmap/handles/win32/handle.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/handles/win32/handle.hpp (original)
+++ sandbox/mmap/boost/mmap/handles/win32/handle.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -21,6 +21,9 @@
     #include "../posix/handle.hpp"
 #endif
 
+#include "../handle_ref.hpp"
+#include "../../implementations.hpp"
+
 #include "boost/noncopyable.hpp"
 //------------------------------------------------------------------------------
 namespace boost
@@ -30,22 +33,30 @@
 {
 //------------------------------------------------------------------------------
 
-class windows_handle : noncopyable
+template <typename Impl> class handle;
+
+template <>
+class handle<win32> : noncopyable
 {
 public:
- typedef void * handle_t;
+ typedef void * native_handle_t;
+ typedef handle_ref< handle<win32> > reference;
+ typedef void * native_handle_t;
+
+ explicit handle<win32>( native_handle_t );
+ ~handle<win32>();
 
- explicit windows_handle( handle_t );
- ~windows_handle();
+ native_handle_t const & get() const { return handle_; }
 
- handle_t const & handle() const { return handle_; }
+ bool operator! () const { return !handle_; }
+ operator reference () const { return reference( handle_ ); }
 
 private:
- handle_t const handle_;
+ native_handle_t const handle_;
 };
 
 #ifdef BOOST_MSVC
- posix_handle make_posix_handle( windows_handle::handle_t, int const flags );
+ handle<posix> make_posix_handle( handle<win32>::reference, int const flags );
 #endif // BOOST_MSVC
 
 //------------------------------------------------------------------------------

Modified: sandbox/mmap/boost/mmap/handles/win32/handle.inl
==============================================================================
--- sandbox/mmap/boost/mmap/handles/win32/handle.inl (original)
+++ sandbox/mmap/boost/mmap/handles/win32/handle.inl 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -36,13 +36,13 @@
 //------------------------------------------------------------------------------
 
 BOOST_IMPL_INLINE
-windows_handle::windows_handle( handle_t const handle )
+handle<win32>::handle( native_handle_t const handle )
     :
     handle_( handle )
 {}
 
 BOOST_IMPL_INLINE
-windows_handle::~windows_handle()
+handle<win32>::~handle()
 {
     BOOST_VERIFY
     (
@@ -54,9 +54,9 @@
 
 #ifdef BOOST_MSVC
     BOOST_IMPL_INLINE
- posix_handle make_posix_handle( windows_handle::handle_t const native_handle, int const flags )
+ handle<posix> make_posix_handle( handle<win32>::native_handle_t const native_handle, int const flags )
     {
- return posix_handle( ::_open_osfhandle( reinterpret_cast<intptr_t>( native_handle ), flags ) );
+ return handle<posix>( ::_open_osfhandle( reinterpret_cast<intptr_t>( native_handle ), flags ) );
     }
 #endif // BOOST_MSVC
 

Added: sandbox/mmap/boost/mmap/implementations.hpp
==============================================================================
--- (empty file)
+++ sandbox/mmap/boost/mmap/implementations.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \file implementations.hpp
+/// -------------------------
+///
+/// Copyright (c) 2011 Domagoj Saric
+///
+/// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
+/// (See accompanying file LICENSE_1_0.txt or copy at
+/// http://www.boost.org/LICENSE_1_0.txt)
+///
+/// For more information, see http://www.boost.org
+///
+////////////////////////////////////////////////////////////////////////////////
+//------------------------------------------------------------------------------
+#ifndef implementations_hpp__CD36EF12_73E1_4058_A57E_6168F337954A
+#define implementations_hpp__CD36EF12_73E1_4058_A57E_6168F337954A
+#pragma once
+//------------------------------------------------------------------------------
+namespace boost
+{
+//------------------------------------------------------------------------------
+namespace mmap
+{
+//------------------------------------------------------------------------------
+
+struct nt;
+struct posix;
+struct win32;
+struct xsi;
+
+//------------------------------------------------------------------------------
+} // namespace mmap
+//------------------------------------------------------------------------------
+} // namespace boost
+//------------------------------------------------------------------------------
+#endif // implementations_hpp

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -17,13 +17,10 @@
 #define file_hpp__D3705ED0_EC0D_4747_A789_1EE17252B6E2
 #pragma once
 //------------------------------------------------------------------------------
-#ifdef _WIN32
- #include "win32/file.hpp"
- #include "win32/flags.hpp"
-#else
- #include "posix/file.hpp"
- #include "posix/flags.hpp"
-#endif
+#include "../../detail/impl_selection.hpp"
+
+#include BOOST_MMAP_IMPL_INCLUDE( ./, /file.hpp )
+#include BOOST_MMAP_IMPL_INCLUDE( ./, /flags.hpp )
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -32,14 +29,7 @@
 {
 //------------------------------------------------------------------------------
 
-#ifdef _WIN32
- typedef windows_handle native_handle;
- typedef win32_file_flags native_file_flags;
-#else
- typedef posix_handle native_handle;
- typedef posix_file_flags native_file_flags;
-#endif // _WIN32
-typedef native_handle::handle_t native_handle_t;
+typedef file_flags<BOOST_MMAP_IMPL> native_file_flags;
 
 //------------------------------------------------------------------------------
 } // namespace mmap

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -28,14 +28,23 @@
 {
 //------------------------------------------------------------------------------
 
-struct posix_file_flags;
+template <typename Impl > struct file_flags;
+template <class Handle> struct is_resizable;
+
+#ifdef BOOST_HAS_UNISTD_H
+ template <> struct is_resizable< handle<posix> > : mpl::true_ {};
+#else
+ template <> struct is_resizable< handle<posix> > : mpl::false_ {};
+#endif // BOOST_HAS_UNISTD_H
+
+
+handle<posix> create_file( char const * file_name, file_flags<posix> const & );
 
-posix_handle create_file( char const * file_name, posix_file_flags const & );
 
 #ifdef BOOST_HAS_UNISTD_H
-bool set_file_size( posix_handle::handle_t, std::size_t desired_size );
+bool set_size( handle_ref< handle<posix> >, std::size_t desired_size );
 #endif // BOOST_HAS_UNISTD_H
-std::size_t get_file_size( posix_handle::handle_t );
+std::size_t get_size( handle_ref< handle<posix> > );
 
 //------------------------------------------------------------------------------
 } // namespace mmap

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -40,7 +40,7 @@
 //------------------------------------------------------------------------------
 
 BOOST_IMPL_INLINE
-posix_handle create_file( char const * const file_name, posix_file_flags const & flags )
+handle<posix> create_file( char const * const file_name, file_flags<posix> const & flags )
 {
     BOOST_ASSERT( file_name );
 
@@ -49,13 +49,13 @@
     //...zzz...investigate posix_fadvise, posix_madvise, fcntl for the system hints...
     BOOST_VERIFY( ::umask( current_mask ) == 0 );
 
- return posix_handle( file_handle );
+ return handle<posix>( file_handle );
 }
 
 
 #ifdef BOOST_HAS_UNISTD_H
 BOOST_IMPL_INLINE
-bool set_file_size( posix_handle::handle_t const file_handle, std::size_t const desired_size )
+bool set_size( handle_ref< handle<posix> > const file_handle, std::size_t const desired_size )
 {
     return ::ftruncate( file_handle, desired_size ) != -1;
 }
@@ -63,7 +63,7 @@
 
 
 BOOST_IMPL_INLINE
-std::size_t get_file_size( posix_handle::handle_t const file_handle )
+std::size_t get_size( handle_ref< handle<posix> > const file_handle )
 {
     struct stat file_info;
     BOOST_VERIFY( ::fstat( file_handle, &file_info ) == 0 );

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -29,6 +29,8 @@
 {
 //------------------------------------------------------------------------------
 
+template <typename Impl> struct file_flags;
+
 // Implementation note:
 // Using structs with public members and factory functions to enable (almost)
 // zero-overhead 'link-time' conversion to native flag formats and to allow the
@@ -37,7 +39,8 @@
 // interface, can also be covered.
 // (10.10.2010.) (Domagoj Saric)
 
-struct posix_file_flags
+template <>
+struct file_flags<posix>
 {
     struct handle_access_rights
     {
@@ -83,7 +86,7 @@
         static unsigned int const execute;
     };
 
- static posix_file_flags create
+ static file_flags<posix> create
     (
         unsigned int handle_access_flags ,
         unsigned int share_mode ,
@@ -92,7 +95,7 @@
         unsigned int on_construction_rights
     );
 
- static posix_file_flags create_for_opening_existing_files
+ static file_flags<posix> create_for_opening_existing_files
     (
         unsigned int handle_access_flags,
         unsigned int share_mode ,

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -49,28 +49,28 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const posix_file_flags::handle_access_rights::read = O_RDONLY;
-unsigned int const posix_file_flags::handle_access_rights::write = O_WRONLY;
-unsigned int const posix_file_flags::handle_access_rights::execute = O_RDONLY;
-
-unsigned int const posix_file_flags::share_mode::none = 0;
-unsigned int const posix_file_flags::share_mode::read = 0;
-unsigned int const posix_file_flags::share_mode::write = 0;
-unsigned int const posix_file_flags::share_mode::remove = 0;
+unsigned int const file_flags<posix>::handle_access_rights::read = O_RDONLY;
+unsigned int const file_flags<posix>::handle_access_rights::write = O_WRONLY;
+unsigned int const file_flags<posix>::handle_access_rights::execute = O_RDONLY;
+
+unsigned int const file_flags<posix>::share_mode::none = 0;
+unsigned int const file_flags<posix>::share_mode::read = 0;
+unsigned int const file_flags<posix>::share_mode::write = 0;
+unsigned int const file_flags<posix>::share_mode::remove = 0;
 
-unsigned int const posix_file_flags::system_hints::random_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_RANDOM , 0 );
-unsigned int const posix_file_flags::system_hints::sequential_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_SEQUENTIAL , 0 );
+unsigned int const file_flags<posix>::system_hints::random_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_RANDOM , 0 );
+unsigned int const file_flags<posix>::system_hints::sequential_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_SEQUENTIAL , 0 );
 // http://stackoverflow.com/questions/2299402/how-does-one-do-raw-io-on-mac-os-x-ie-equivalent-to-linuxs-o-direct-flag
-unsigned int const posix_file_flags::system_hints::non_cached = BOOST_AUX_IO_WIN32_OR_POSIX( 0 , BOOST_AUX_MMAP_POSIX_OR_OSX( O_DIRECT, 0 ) );
-unsigned int const posix_file_flags::system_hints::delete_on_close = BOOST_AUX_IO_WIN32_OR_POSIX( O_TEMPORARY , 0 );
-unsigned int const posix_file_flags::system_hints::temporary = BOOST_AUX_IO_WIN32_OR_POSIX( _O_SHORT_LIVED, 0 );
-
-unsigned int const posix_file_flags::on_construction_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IREAD , S_IRUSR );
-unsigned int const posix_file_flags::on_construction_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IWRITE, S_IWUSR );
-unsigned int const posix_file_flags::on_construction_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IEXEC , S_IXUSR );
+unsigned int const file_flags<posix>::system_hints::non_cached = BOOST_AUX_IO_WIN32_OR_POSIX( 0 , BOOST_AUX_MMAP_POSIX_OR_OSX( O_DIRECT, 0 ) );
+unsigned int const file_flags<posix>::system_hints::delete_on_close = BOOST_AUX_IO_WIN32_OR_POSIX( O_TEMPORARY , 0 );
+unsigned int const file_flags<posix>::system_hints::temporary = BOOST_AUX_IO_WIN32_OR_POSIX( _O_SHORT_LIVED, 0 );
+
+unsigned int const file_flags<posix>::on_construction_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IREAD , S_IRUSR );
+unsigned int const file_flags<posix>::on_construction_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IWRITE, S_IWUSR );
+unsigned int const file_flags<posix>::on_construction_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IEXEC , S_IXUSR );
 
 BOOST_IMPL_INLINE
-posix_file_flags posix_file_flags::create
+file_flags<posix> file_flags<posix>::create
 (
     unsigned int const handle_access_flags ,
     unsigned int const /*share_mode*/ ,
@@ -79,7 +79,7 @@
     unsigned int const on_construction_rights
 )
 {
- posix_file_flags const flags =
+ file_flags<posix> const flags =
     {
         ( ( handle_access_flags == ( O_RDONLY | O_WRONLY ) ) ? O_RDWR : handle_access_flags )
             |
@@ -94,7 +94,7 @@
 
 
 BOOST_IMPL_INLINE
-posix_file_flags posix_file_flags::create_for_opening_existing_files( unsigned int const handle_access_flags, unsigned int const share_mode , bool const truncate, unsigned int const system_hints )
+file_flags<posix> file_flags<posix>::create_for_opening_existing_files( unsigned int const handle_access_flags, unsigned int const share_mode , bool const truncate, unsigned int const system_hints )
 {
     return create
     (

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -28,12 +28,17 @@
 {
 //------------------------------------------------------------------------------
 
-struct win32_file_flags;
+template <typename Impl > struct file_flags;
+template <class Handle> struct is_resizable;
 
-windows_handle create_file( char const * file_name, win32_file_flags const & );
+template <> struct is_resizable< handle<win32> > : mpl::true_ {};
+
+
+handle<win32> create_file( char const * file_name, file_flags<win32> const & );
+
+bool set_size( handle<win32>::reference, std::size_t desired_size );
+std::size_t get_size( handle<win32>::reference );
 
-bool set_file_size( windows_handle::handle_t, std::size_t desired_size );
-std::size_t get_file_size( windows_handle::handle_t );
 
 //------------------------------------------------------------------------------
 } // namespace mmap

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -33,7 +33,7 @@
 //------------------------------------------------------------------------------
 
 BOOST_IMPL_INLINE
-windows_handle create_file( char const * const file_name, win32_file_flags const & flags )
+handle<win32> create_file( char const * const file_name, file_flags<win32> const & flags )
 {
     BOOST_ASSERT( file_name );
 
@@ -46,12 +46,12 @@
     );
     BOOST_ASSERT( ( file_handle == INVALID_HANDLE_VALUE ) || ( ::GetLastError() == NO_ERROR ) || ( ::GetLastError() == ERROR_ALREADY_EXISTS ) );
 
- return windows_handle( file_handle );
+ return handle<win32>( file_handle );
 }
 
 
 BOOST_IMPL_INLINE
-bool set_file_size( windows_handle::handle_t const file_handle, std::size_t const desired_size )
+bool set_size( handle<win32>::reference const file_handle, std::size_t const desired_size )
 {
     // It is 'OK' to send null/invalid handles to Windows functions (they will
     // simply fail), this simplifies error handling (it is enough to go through
@@ -69,7 +69,7 @@
 
 
 BOOST_IMPL_INLINE
-std::size_t get_file_size( windows_handle::handle_t const file_handle )
+std::size_t get_size( handle<win32>::reference const file_handle )
 {
     DWORD const file_size( ::GetFileSize( file_handle, 0 ) );
     BOOST_ASSERT( ( file_size != INVALID_FILE_SIZE ) || ( file_handle == INVALID_HANDLE_VALUE ) || ( ::GetLastError() == NO_ERROR ) );

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -27,6 +27,8 @@
 {
 //------------------------------------------------------------------------------
 
+template <typename Impl> struct file_flags;
+
 // Implementation note:
 // Using structs with public members and factory functions to enable (almost)
 // zero-overhead 'link-time' conversion to native flag formats and to allow the
@@ -35,7 +37,8 @@
 // interface, can also be covered.
 // (10.10.2010.) (Domagoj Saric)
 
-struct win32_file_flags
+template <>
+struct file_flags<win32>
 {
     struct handle_access_rights
     {
@@ -81,7 +84,7 @@
         static unsigned int const execute;
     };
 
- static win32_file_flags create
+ static file_flags<win32> create
     (
         unsigned int handle_access_flags ,
         unsigned int share_mode ,
@@ -90,7 +93,7 @@
         unsigned int on_construction_rights
     );
 
- static win32_file_flags create_for_opening_existing_files
+ static file_flags<win32> create_for_opening_existing_files
     (
         unsigned int handle_access_flags,
         unsigned int share_mode ,

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -31,27 +31,27 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const win32_file_flags::handle_access_rights::read = GENERIC_READ ;
-unsigned int const win32_file_flags::handle_access_rights::write = GENERIC_WRITE ;
-unsigned int const win32_file_flags::handle_access_rights::execute = GENERIC_EXECUTE;
-
-unsigned int const win32_file_flags::share_mode::none = 0 ;
-unsigned int const win32_file_flags::share_mode::read = FILE_SHARE_READ ;
-unsigned int const win32_file_flags::share_mode::write = FILE_SHARE_WRITE ;
-unsigned int const win32_file_flags::share_mode::remove = FILE_SHARE_DELETE;
-
-unsigned int const win32_file_flags::system_hints::random_access = FILE_FLAG_RANDOM_ACCESS ;
-unsigned int const win32_file_flags::system_hints::sequential_access = FILE_FLAG_SEQUENTIAL_SCAN ;
-unsigned int const win32_file_flags::system_hints::non_cached = FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
-unsigned int const win32_file_flags::system_hints::delete_on_close = FILE_FLAG_DELETE_ON_CLOSE ;
-unsigned int const win32_file_flags::system_hints::temporary = FILE_ATTRIBUTE_TEMPORARY ;
-
-unsigned int const win32_file_flags::on_construction_rights::read = FILE_ATTRIBUTE_READONLY;
-unsigned int const win32_file_flags::on_construction_rights::write = FILE_ATTRIBUTE_NORMAL ;
-unsigned int const win32_file_flags::on_construction_rights::execute = FILE_ATTRIBUTE_NORMAL ;
+unsigned int const file_flags<win32>::handle_access_rights::read = GENERIC_READ ;
+unsigned int const file_flags<win32>::handle_access_rights::write = GENERIC_WRITE ;
+unsigned int const file_flags<win32>::handle_access_rights::execute = GENERIC_EXECUTE;
+
+unsigned int const file_flags<win32>::share_mode::none = 0 ;
+unsigned int const file_flags<win32>::share_mode::read = FILE_SHARE_READ ;
+unsigned int const file_flags<win32>::share_mode::write = FILE_SHARE_WRITE ;
+unsigned int const file_flags<win32>::share_mode::remove = FILE_SHARE_DELETE;
+
+unsigned int const file_flags<win32>::system_hints::random_access = FILE_FLAG_RANDOM_ACCESS ;
+unsigned int const file_flags<win32>::system_hints::sequential_access = FILE_FLAG_SEQUENTIAL_SCAN ;
+unsigned int const file_flags<win32>::system_hints::non_cached = FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
+unsigned int const file_flags<win32>::system_hints::delete_on_close = FILE_FLAG_DELETE_ON_CLOSE ;
+unsigned int const file_flags<win32>::system_hints::temporary = FILE_ATTRIBUTE_TEMPORARY ;
+
+unsigned int const file_flags<win32>::on_construction_rights::read = FILE_ATTRIBUTE_READONLY;
+unsigned int const file_flags<win32>::on_construction_rights::write = FILE_ATTRIBUTE_NORMAL ;
+unsigned int const file_flags<win32>::on_construction_rights::execute = FILE_ATTRIBUTE_NORMAL ;
 
 BOOST_IMPL_INLINE
-win32_file_flags win32_file_flags::create
+file_flags<win32> file_flags<win32>::create
 (
     unsigned int const handle_access_flags ,
     unsigned int const share_mode ,
@@ -60,7 +60,7 @@
     unsigned int const on_construction_rights
 )
 {
- win32_file_flags const flags =
+ file_flags<win32> const flags =
     {
         handle_access_flags, // desired_access
         share_mode, // share_mode
@@ -79,7 +79,13 @@
 
 
 BOOST_IMPL_INLINE
-win32_file_flags win32_file_flags::create_for_opening_existing_files( unsigned int const handle_access_flags, unsigned int const share_mode , bool const truncate, unsigned int const system_hints )
+file_flags<win32> file_flags<win32>::create_for_opening_existing_files
+(
+ unsigned int const handle_access_flags,
+ unsigned int const share_mode,
+ bool const truncate,
+ unsigned int const system_hints
+)
 {
     return create
     (

Modified: sandbox/mmap/boost/mmap/mapped_view.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mapped_view.hpp (original)
+++ sandbox/mmap/boost/mmap/mapped_view.hpp 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -17,6 +17,7 @@
 #define mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
 #pragma once
 //------------------------------------------------------------------------------
+#include "handles/handle.hpp"
 //...zzz...
 #include "mappble_objects/file/file.hpp"
 #include "mappble_objects/file/posix/file.hpp"
@@ -165,7 +166,7 @@
 public: // Factory methods.
     static mapped_view_reference map
     (
- native_handle_t,
+ native_handle::reference,
         mapping_flags const &,
         std::size_t desired_size = 0,
         std::size_t offset = 0
@@ -194,10 +195,10 @@
 public: // Factory methods.
     static mapped_view_reference map
     (
- native_handle_t object_handle,
- std::size_t desired_size = 0,
- std::size_t offset = 0,
- bool map_for_code_execution = false
+ native_handle::reference object_handle,
+ std::size_t desired_size = 0,
+ std::size_t offset = 0,
+ bool map_for_code_execution = false
     );
 
 private:
@@ -263,21 +264,21 @@
 template <typename Handle>
 struct is_mappable : mpl::false_ {};
 
-template <> struct is_mappable<char *> : mpl::true_ {};
-template <> struct is_mappable<char const *> : mpl::true_ {};
-template <> struct is_mappable<FILE *> : mpl::true_ {};
-template <> struct is_mappable<posix_handle::handle_t > : mpl::true_ {};
+template <> struct is_mappable<char *> : mpl::true_ {};
+template <> struct is_mappable<char const *> : mpl::true_ {};
+template <> struct is_mappable<FILE *> : mpl::true_ {};
+template <> struct is_mappable<handle<posix>::native_handle_t > : mpl::true_ {};
 #ifdef _WIN32
-template <> struct is_mappable<wchar_t *> : mpl::true_ {};
-template <> struct is_mappable<wchar_t const *> : mpl::true_ {};
-template <> struct is_mappable<windows_handle::handle_t > : mpl::true_ {};
+template <> struct is_mappable<wchar_t *> : mpl::true_ {};
+template <> struct is_mappable<wchar_t const *> : mpl::true_ {};
+template <> struct is_mappable<handle<win32>::native_handle_t > : mpl::true_ {};
 #endif // _WIN32
 
 
 template <>
 mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
 (
- native_handle_t,
+ native_handle::reference,
     mapping_flags const &,
     std::size_t desired_size,
     std::size_t offset
@@ -286,10 +287,10 @@
 template <>
 mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
 (
- native_handle_t object_handle,
- std::size_t desired_size,
- std::size_t offset,
- bool map_for_code_execution
+ native_handle::reference object_handle,
+ std::size_t desired_size,
+ std::size_t offset,
+ bool map_for_code_execution
 );
 
 

Modified: sandbox/mmap/boost/mmap/mapped_view.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mapped_view.inl (original)
+++ sandbox/mmap/boost/mmap/mapped_view.inl 2011-08-22 17:54:51 EDT (Mon, 22 Aug 2011)
@@ -107,10 +107,10 @@
 template <> BOOST_IMPL_INLINE
 mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
 (
- native_handle_t const object_handle,
- mapping_flags const & flags,
- std::size_t const desired_size,
- std::size_t const offset
+ native_handle::reference const object_handle,
+ mapping_flags const & flags,
+ std::size_t const desired_size,
+ std::size_t const offset
 )
 {
     typedef mapped_view_reference<unsigned char>::iterator iterator_t;
@@ -128,17 +128,17 @@
     // CreateFileMapping accepts INVALID_HANDLE_VALUE as valid input but only if
     // the size parameter is not null.
     large_integer.QuadPart = desired_size;
- windows_handle const mapping
+ handle<win32> const mapping
     (
         ::CreateFileMapping( object_handle, 0, flags.create_mapping_flags, large_integer.HighPart, large_integer.LowPart, 0 )
     );
     BOOST_ASSERT
     (
- !mapping.handle() || ( object_handle == INVALID_HANDLE_VALUE ) || ( desired_size != 0 )
+ !mapping || ( object_handle == INVALID_HANDLE_VALUE ) || ( desired_size != 0 )
     );
 
     large_integer.QuadPart = offset;
- iterator_t const view_start( static_cast<iterator_t>( ::MapViewOfFile( mapping.handle(), flags.map_view_flags, large_integer.HighPart, large_integer.LowPart, desired_size ) ) );
+ iterator_t const view_start( static_cast<iterator_t>( ::MapViewOfFile( mapping.get(), flags.map_view_flags, large_integer.HighPart, large_integer.LowPart, desired_size ) ) );
     return mapped_view_reference<unsigned char>
     (
         view_start,
@@ -176,10 +176,10 @@
 template <> BOOST_IMPL_INLINE
 mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
 (
- native_handle_t const object_handle,
- std::size_t const desired_size,
- std::size_t const offset,
- bool const map_for_code_execution
+ native_handle::reference const object_handle,
+ std::size_t const desired_size,
+ std::size_t const offset,
+ bool const map_for_code_execution
 )
 {
     return mapped_view_reference<unsigned char>::map
@@ -218,13 +218,13 @@
     );
 
     if ( desired_size )
- set_file_size( file_handle.handle(), desired_size );
+ set_size( file_handle.get(), desired_size );
     else
- desired_size = get_file_size( file_handle.handle() );
+ desired_size = get_size( file_handle.get() );
 
     return basic_mapped_view_ref::map
     (
- file_handle.handle(),
+ file_handle.get(),
         mapping_flags::create
         (
             mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
@@ -258,13 +258,13 @@
 
     return basic_mapped_read_only_view_ref::map
     (
- file_handle.handle(),
+ file_handle.get(),
         // Implementation note:
         // Windows APIs interpret zero as 'whole file' but we still need to
         // query the file size in order to be able to properly set the end
         // pointer.
         // (13.07.2011.) (Domagoj Saric)
- get_file_size( file_handle.handle() )
+ get_size( file_handle.get() )
     );
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk