mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Tidy up beast_asio
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user