handler_base_from_member.hpp
Go to the documentation of this file.
00001 //
00002 // handler_base_from_member.hpp
00003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef ASIO_DETAIL_HANDLER_BASE_FROM_MEMBER_HPP
00012 #define ASIO_DETAIL_HANDLER_BASE_FROM_MEMBER_HPP
00013 
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017 
00018 #include "asio/detail/push_options.hpp"
00019 
00020 #include "asio/detail/handler_alloc_helpers.hpp"
00021 #include "asio/detail/handler_invoke_helpers.hpp"
00022 
00023 namespace asio {
00024 namespace detail {
00025 
00026 // Base class for classes that need a handler data member. Forwards the custom
00027 // allocation and invocation hooks to the contained handler.
00028 template <typename Handler>
00029 class handler_base_from_member
00030 {
00031 public:
00032   handler_base_from_member(Handler handler)
00033     : handler_(handler)
00034   {
00035   }
00036 
00037 //protected:
00038   Handler handler_;
00039 
00040 protected:
00041   // Protected destructor to prevent deletion through this type.
00042   ~handler_base_from_member()
00043   {
00044   }
00045 };
00046 
00047 template <typename Handler>
00048 inline void* asio_handler_allocate(std::size_t size,
00049     handler_base_from_member<Handler>* this_handler)
00050 {
00051   return asio_handler_alloc_helpers::allocate(
00052       size, &this_handler->handler_);
00053 }
00054 
00055 template <typename Handler>
00056 inline void asio_handler_deallocate(void* pointer, std::size_t size,
00057     handler_base_from_member<Handler>* this_handler)
00058 {
00059   asio_handler_alloc_helpers::deallocate(
00060       pointer, size, &this_handler->handler_);
00061 }
00062 
00063 template <typename Function, typename Handler>
00064 inline void asio_handler_invoke(const Function& function,
00065     handler_base_from_member<Handler>* this_handler)
00066 {
00067   asio_handler_invoke_helpers::invoke(
00068       function, &this_handler->handler_);
00069 }
00070 
00071 } // namespace detail
00072 } // namespace asio
00073 
00074 #include "asio/detail/pop_options.hpp"
00075 
00076 #endif // ASIO_DETAIL_HANDLER_BASE_FROM_MEMBER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Nov 8 2013 11:05:39