Boost logo

Boost-Commit :

From: chris_at_[hidden]
Date: 2008-09-02 07:34:20


Author: chris_kohlhoff
Date: 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
New Revision: 48535
URL: http://svn.boost.org/trac/boost/changeset/48535

Log:
Add const overloads of the lowest_layer member functions.

Text files modified:
   trunk/boost/asio/basic_serial_port.hpp | 14 ++++++++++++++
   trunk/boost/asio/basic_socket.hpp | 14 ++++++++++++++
   trunk/boost/asio/buffered_read_stream.hpp | 6 ++++++
   trunk/boost/asio/buffered_stream.hpp | 6 ++++++
   trunk/boost/asio/buffered_write_stream.hpp | 6 ++++++
   trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp | 4 ++--
   trunk/boost/asio/posix/basic_descriptor.hpp | 14 ++++++++++++++
   trunk/boost/asio/ssl/stream.hpp | 13 +++++++++++++
   trunk/boost/asio/windows/basic_handle.hpp | 14 ++++++++++++++
   trunk/libs/asio/test/ip/tcp.cpp | 5 +++++
   trunk/libs/asio/test/ip/udp.cpp | 5 +++++
   trunk/libs/asio/test/posix/stream_descriptor.cpp | 5 +++++
   trunk/libs/asio/test/serial_port.cpp | 4 ++++
   trunk/libs/asio/test/ssl/stream.cpp | 5 +++++
   trunk/libs/asio/test/windows/random_access_handle.cpp | 5 +++++
   trunk/libs/asio/test/windows/stream_handle.cpp | 5 +++++
   16 files changed, 123 insertions(+), 2 deletions(-)

Modified: trunk/boost/asio/basic_serial_port.hpp
==============================================================================
--- trunk/boost/asio/basic_serial_port.hpp (original)
+++ trunk/boost/asio/basic_serial_port.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -143,6 +143,20 @@
     return *this;
   }
 
+ /// Get a const reference to the lowest layer.
+ /**
+ * This function returns a const reference to the lowest layer in a stack of
+ * layers. Since a basic_serial_port cannot contain any further layers, it
+ * simply returns a reference to itself.
+ *
+ * @return A const reference to the lowest layer in the stack of layers.
+ * Ownership is not transferred to the caller.
+ */
+ const lowest_layer_type& lowest_layer() const
+ {
+ return *this;
+ }
+
   /// Open the serial port using the specified device name.
   /**
    * This function opens the serial port for the specified device name.

Modified: trunk/boost/asio/basic_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_socket.hpp (original)
+++ trunk/boost/asio/basic_socket.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -150,6 +150,20 @@
     return *this;
   }
 
+ /// Get a const reference to the lowest layer.
+ /**
+ * This function returns a const reference to the lowest layer in a stack of
+ * layers. Since a basic_socket cannot contain any further layers, it simply
+ * returns a reference to itself.
+ *
+ * @return A const reference to the lowest layer in the stack of layers.
+ * Ownership is not transferred to the caller.
+ */
+ const lowest_layer_type& lowest_layer() const
+ {
+ return *this;
+ }
+
   /// Open the socket using the specified protocol.
   /**
    * This function opens the socket so that it will use the specified protocol.

Modified: trunk/boost/asio/buffered_read_stream.hpp
==============================================================================
--- trunk/boost/asio/buffered_read_stream.hpp (original)
+++ trunk/boost/asio/buffered_read_stream.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -94,6 +94,12 @@
     return next_layer_.lowest_layer();
   }
 
+ /// Get a const reference to the lowest layer.
+ const lowest_layer_type& lowest_layer() const
+ {
+ return next_layer_.lowest_layer();
+ }
+
   /// (Deprecated: use get_io_service().) Get the io_service associated with
   /// the object.
   boost::asio::io_service& io_service()

Modified: trunk/boost/asio/buffered_stream.hpp
==============================================================================
--- trunk/boost/asio/buffered_stream.hpp (original)
+++ trunk/boost/asio/buffered_stream.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -84,6 +84,12 @@
     return stream_impl_.lowest_layer();
   }
 
+ /// Get a const reference to the lowest layer.
+ const lowest_layer_type& lowest_layer() const
+ {
+ return stream_impl_.lowest_layer();
+ }
+
   /// (Deprecated: use get_io_service().) Get the io_service associated with
   /// the object.
   boost::asio::io_service& io_service()

Modified: trunk/boost/asio/buffered_write_stream.hpp
==============================================================================
--- trunk/boost/asio/buffered_write_stream.hpp (original)
+++ trunk/boost/asio/buffered_write_stream.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -95,6 +95,12 @@
     return next_layer_.lowest_layer();
   }
 
+ /// Get a const reference to the lowest layer.
+ const lowest_layer_type& lowest_layer() const
+ {
+ return next_layer_.lowest_layer();
+ }
+
   /// (Deprecated: use get_io_service().) Get the io_service associated with
   /// the object.
   boost::asio::io_service& io_service()

Modified: trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -147,7 +147,7 @@
     overlapped_operation(const overlapped_operation&);
     void operator=(const overlapped_operation&);
     
- static void do_completion_impl(win_iocp_io_service::operation* op,
+ static void do_completion_impl(operation* op,
         DWORD last_error, size_t bytes_transferred)
     {
       // Take ownership of the operation object.
@@ -172,7 +172,7 @@
           bind_handler(handler, ec, bytes_transferred), &handler);
     }
 
- static void destroy_impl(win_iocp_io_service::operation* op)
+ static void destroy_impl(operation* op)
     {
       // Take ownership of the operation object.
       typedef overlapped_operation<Handler> op_type;

Modified: trunk/boost/asio/posix/basic_descriptor.hpp
==============================================================================
--- trunk/boost/asio/posix/basic_descriptor.hpp (original)
+++ trunk/boost/asio/posix/basic_descriptor.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -100,6 +100,20 @@
     return *this;
   }
 
+ /// Get a const reference to the lowest layer.
+ /**
+ * This function returns a const reference to the lowest layer in a stack of
+ * layers. Since a basic_descriptor cannot contain any further layers, it
+ * simply returns a reference to itself.
+ *
+ * @return A const reference to the lowest layer in the stack of layers.
+ * Ownership is not transferred to the caller.
+ */
+ const lowest_layer_type& lowest_layer() const
+ {
+ return *this;
+ }
+
   /// Assign an existing native descriptor to the descriptor.
   /*
    * This function opens the descriptor to hold an existing native descriptor.

Modified: trunk/boost/asio/ssl/stream.hpp
==============================================================================
--- trunk/boost/asio/ssl/stream.hpp (original)
+++ trunk/boost/asio/ssl/stream.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -150,6 +150,19 @@
     return next_layer_.lowest_layer();
   }
 
+ /// Get a const reference to the lowest layer.
+ /**
+ * This function returns a const reference to the lowest layer in a stack of
+ * stream layers.
+ *
+ * @return A const reference to the lowest layer in the stack of stream
+ * layers. Ownership is not transferred to the caller.
+ */
+ const lowest_layer_type& lowest_layer() const
+ {
+ return next_layer_.lowest_layer();
+ }
+
   /// Get the underlying implementation in the native type.
   /**
    * This function may be used to obtain the underlying implementation of the

Modified: trunk/boost/asio/windows/basic_handle.hpp
==============================================================================
--- trunk/boost/asio/windows/basic_handle.hpp (original)
+++ trunk/boost/asio/windows/basic_handle.hpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -95,6 +95,20 @@
     return *this;
   }
 
+ /// Get a const reference to the lowest layer.
+ /**
+ * This function returns a const reference to the lowest layer in a stack of
+ * layers. Since a basic_handle cannot contain any further layers, it simply
+ * returns a reference to itself.
+ *
+ * @return A const reference to the lowest layer in the stack of layers.
+ * Ownership is not transferred to the caller.
+ */
+ const lowest_layer_type& lowest_layer() const
+ {
+ return *this;
+ }
+
   /// Assign an existing native handle to the handle.
   /*
    * This function opens the handle to hold an existing native handle.

Modified: trunk/libs/asio/test/ip/tcp.cpp
==============================================================================
--- trunk/libs/asio/test/ip/tcp.cpp (original)
+++ trunk/libs/asio/test/ip/tcp.cpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -172,6 +172,11 @@
     ip::tcp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
     (void)lowest_layer;
 
+ const ip::tcp::socket& socket7 = socket1;
+ const ip::tcp::socket::lowest_layer_type& lowest_layer2
+ = socket7.lowest_layer();
+ (void)lowest_layer2;
+
     socket1.open(ip::tcp::v4());
     socket1.open(ip::tcp::v6());
     socket1.open(ip::tcp::v4(), ec);

Modified: trunk/libs/asio/test/ip/udp.cpp
==============================================================================
--- trunk/libs/asio/test/ip/udp.cpp (original)
+++ trunk/libs/asio/test/ip/udp.cpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -77,6 +77,11 @@
     ip::udp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
     (void)lowest_layer;
 
+ const ip::udp::socket& socket7 = socket1;
+ const ip::udp::socket::lowest_layer_type& lowest_layer2
+ = socket7.lowest_layer();
+ (void)lowest_layer2;
+
     socket1.open(ip::udp::v4());
     socket1.open(ip::udp::v6());
     socket1.open(ip::udp::v4(), ec);

Modified: trunk/libs/asio/test/posix/stream_descriptor.cpp
==============================================================================
--- trunk/libs/asio/test/posix/stream_descriptor.cpp (original)
+++ trunk/libs/asio/test/posix/stream_descriptor.cpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -68,6 +68,11 @@
       = descriptor1.lowest_layer();
     (void)lowest_layer;
 
+ const posix::stream_descriptor& descriptor3 = descriptor1;
+ const posix::stream_descriptor::lowest_layer_type& lowest_layer2
+ = descriptor3.lowest_layer();
+ (void)lowest_layer2;
+
     int native_descriptor2 = -1;
     descriptor1.assign(native_descriptor2);
 

Modified: trunk/libs/asio/test/serial_port.cpp
==============================================================================
--- trunk/libs/asio/test/serial_port.cpp (original)
+++ trunk/libs/asio/test/serial_port.cpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -67,6 +67,10 @@
     serial_port::lowest_layer_type& lowest_layer = port1.lowest_layer();
     (void)lowest_layer;
 
+ const serial_port& port4 = port1;
+ const serial_port::lowest_layer_type& lowest_layer2 = port4.lowest_layer();
+ (void)lowest_layer2;
+
     port1.open("null");
     port1.open("null", ec);
 

Modified: trunk/libs/asio/test/ssl/stream.cpp
==============================================================================
--- trunk/libs/asio/test/ssl/stream.cpp (original)
+++ trunk/libs/asio/test/ssl/stream.cpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -75,6 +75,11 @@
       = stream1.lowest_layer();
     (void)lowest_layer;
 
+ const ssl::stream<ip::tcp::socket>& stream3 = stream1;
+ const ssl::stream<ip::tcp::socket>::lowest_layer_type& lowest_layer2
+ = stream3.lowest_layer();
+ (void)lowest_layer2;
+
     stream1.handshake(ssl::stream_base::client);
     stream1.handshake(ssl::stream_base::server);
     stream1.handshake(ssl::stream_base::client, ec);

Modified: trunk/libs/asio/test/windows/random_access_handle.cpp
==============================================================================
--- trunk/libs/asio/test/windows/random_access_handle.cpp (original)
+++ trunk/libs/asio/test/windows/random_access_handle.cpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -68,6 +68,11 @@
       = handle1.lowest_layer();
     (void)lowest_layer;
 
+ const win::random_access_handle& handle3 = handle1;
+ const win::random_access_handle::lowest_layer_type& lowest_layer2
+ = handle3.lowest_layer();
+ (void)lowest_layer2;
+
     HANDLE native_handle2 = INVALID_HANDLE_VALUE;
     handle1.assign(native_handle2);
 

Modified: trunk/libs/asio/test/windows/stream_handle.cpp
==============================================================================
--- trunk/libs/asio/test/windows/stream_handle.cpp (original)
+++ trunk/libs/asio/test/windows/stream_handle.cpp 2008-09-02 07:34:18 EDT (Tue, 02 Sep 2008)
@@ -67,6 +67,11 @@
       = handle1.lowest_layer();
     (void)lowest_layer;
 
+ const win::stream_handle& handle3 = handle1;
+ const win::stream_handle::lowest_layer_type& lowest_layer2
+ = handle3.lowest_layer();
+ (void)lowest_layer2;
+
     HANDLE native_handle2 = INVALID_HANDLE_VALUE;
     handle1.assign(native_handle2);
 


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