Tidy up beast_asio

This commit is contained in:
Vinnie Falco
2013-08-06 23:02:48 -07:00
parent 74156b6b89
commit 155a6a09b6
6 changed files with 79 additions and 65 deletions

View File

@@ -70,7 +70,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\modules\beast_asio\beast_asio.h" />
<ClInclude Include="..\..\modules\beast_asio\boost\beast_BoostIncludes.h" />
<ClInclude Include="..\..\modules\beast_asio\sockets\beast_Socket.h" />
<ClInclude Include="..\..\modules\beast_asio\sockets\beast_SharedSocket.h" />
<ClInclude Include="..\..\modules\beast_asio\sockets\beast_SocketBase.h" />

View File

@@ -146,9 +146,6 @@
<Filter Include="beast_asio\sockets">
<UniqueIdentifier>{af535ad5-a06c-462f-8ac0-8207a708e032}</UniqueIdentifier>
</Filter>
<Filter Include="beast_asio\boost">
<UniqueIdentifier>{4a91e76d-d6ab-4ce9-a451-0c2685cd3064}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\modules\beast_core\beast_core.h">
@@ -752,9 +749,6 @@
<ClInclude Include="..\..\modules\beast_asio\sockets\beast_SocketBase.h">
<Filter>beast_asio\sockets</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\boost\beast_BoostIncludes.h">
<Filter>beast_asio\boost</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\sockets\beast_SocketWrapperBase.h">
<Filter>beast_asio\sockets</Filter>
</ClInclude>

View File

@@ -40,8 +40,42 @@
// Must come before boost includes to fix the bost placeholders.
#include "../beast_core/beast_core.h"
//------------------------------------------------------------------------------
/* This module requires boost and possibly OpenSSL */
#include "boost/beast_BoostIncludes.h"
// Make sure we take care of fixing boost::bind oddities first.
#if !defined(BEAST_CORE_H_INCLUDED)
#error beast_core.h must be included before including this file
#endif
#if BEAST_WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0600
# endif
# ifndef _VARIADIC_MAX
# define _VARIADIC_MAX 10
# endif
#endif
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/foreach.hpp>
#include <boost/type_traits.hpp>
//#include <boost/mpl/at.hpp>
//#include <boost/asio/io_service.hpp>
//#include <boost/array.hpp>
//#include <boost/bind.hpp>
//#include <boost/unordered_map.hpp>
//#include <boost/mpl/vector.hpp>
// VFALCO TODO check for version availability
#ifndef BOOST_ASIO_INITFN_RESULT_TYPE
#define BOOST_ASIO_INITFN_RESULT_TYPE(expr,val) void
#endif
//------------------------------------------------------------------------------
namespace beast
{

View File

@@ -1,55 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef BEAST_BOOSTINCLUDES_H_INCLUDED
#define BEAST_BOOSTINCLUDES_H_INCLUDED
// Make sure we take care of fixing boost::bind oddities first.
#if !defined(BEAST_CORE_H_INCLUDED)
#error beast_core.h must be included before including this file
#endif
#if BEAST_WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0600
# endif
# ifndef _VARIADIC_MAX
# define _VARIADIC_MAX 10
# endif
#endif
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/foreach.hpp>
#include <boost/type_traits.hpp>
//#include <boost/mpl/at.hpp>
//#include <boost/asio/io_service.hpp>
//#include <boost/array.hpp>
//#include <boost/bind.hpp>
//#include <boost/unordered_map.hpp>
//#include <boost/mpl/vector.hpp>
// VFALCO TODO check for version availability
#ifndef BOOST_ASIO_INITFN_RESULT_TYPE
#define BOOST_ASIO_INITFN_RESULT_TYPE(expr,val) void
#endif
#endif

View File

@@ -20,7 +20,14 @@
#ifndef BEAST_SHAREDSOCKET_H_INCLUDED
#define BEAST_SHAREDSOCKET_H_INCLUDED
/** A Socket interface with reference counting. */
/** A Socket interface with reference counting.
You can keep a pointer to the base class so that you don't have
to see the template or underlying object implementation.
@see SharedSocketTYpe, SharedObjectPtr
*/
/** @{ */
class SharedSocket
: public SharedObject
, public virtual Socket
@@ -30,7 +37,28 @@ public:
typedef SharedObjectPtr <SharedSocket> Ptr;
};
/** A RAII container for wrapping an object as a Socket. */
//------------------------------------------------------------------------------
/** A RAII container for wrapping an object as a Socket.
To use this, construct the class with an instance of your object
created with operator new. The constructor will take ownership,
and delete it when the last reference is removed. For example:
@code
boost::asio::io_service ios;
boost::asio::ssl:context ctx;
SharedSocket::Ptr mySocket (
new (boost::asio::ssl::stream (ios, ctx)));
mySocket->handshake ();
@endcode
@see SharedSocket
*/
template <class Object>
class SharedSocketType
: public SharedSocket
@@ -50,5 +78,6 @@ public:
private:
ScopedPointer <Object> m_object;
};
/** @} */
#endif

View File

@@ -74,6 +74,8 @@ struct SocketWrapperBase
typedef value type;
};
#if 1
// Less elegant, but works.
// Determines if Object supports the specified Interface
template <typename Object, typename Interface, class Enable = void>
struct HasInterface : boost::false_type { };
@@ -83,6 +85,17 @@ struct SocketWrapperBase
typename boost::enable_if <boost::is_base_of <
Interface, typename InterfacesOf <Object>::type> >::type >
: boost::true_type { };
#else
// This should work, but doesn't.
// K-ballo from #boost suggested it.
//
// Determines if Object supports the specified Interface
template <typename Object, typename Interface>
struct HasInterface : boost::is_base_of <Interface, typename InterfacesOf <Object> >
{
};
#endif
};
#endif