mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-07 11:17:46 +00:00
More boost removed from common
This commit is contained in:
parent
87f04c2e30
commit
55c42035f3
13 changed files with 56 additions and 67 deletions
|
@ -45,7 +45,7 @@ endif()
|
|||
target_include_directories( common
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../deps/asio/asio/include/"
|
||||
PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/libraries/external/"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../deps/asio/asio/include/")
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/libraries/external/")
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "Hive.h"
|
||||
#include "Acceptor.h"
|
||||
#include "Connection.h"
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace Core {
|
||||
namespace Network {
|
||||
|
@ -48,10 +47,10 @@ void Acceptor::StartError( const asio::error_code& error )
|
|||
void Acceptor::DispatchAccept( ConnectionPtr connection )
|
||||
{
|
||||
m_acceptor.async_accept( connection->GetSocket(),
|
||||
connection->GetStrand().wrap( boost::bind( &Acceptor::HandleAccept,
|
||||
shared_from_this(),
|
||||
_1,
|
||||
connection ) ) );
|
||||
connection->GetStrand().wrap( std::bind( &Acceptor::HandleAccept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
connection ) ) );
|
||||
}
|
||||
|
||||
void Acceptor::HandleAccept( const asio::error_code& error, ConnectionPtr connection )
|
||||
|
@ -87,7 +86,7 @@ void Acceptor::Stop()
|
|||
|
||||
void Acceptor::Accept( ConnectionPtr connection )
|
||||
{
|
||||
m_io_strand.post( boost::bind( &Acceptor::DispatchAccept, shared_from_this(), connection ) );
|
||||
m_io_strand.post( std::bind( &Acceptor::DispatchAccept, shared_from_this(), connection ) );
|
||||
}
|
||||
|
||||
void Acceptor::Listen( const std::string& host, const uint16_t& port )
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
#define ACCEPTOR_H_
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <atomic>
|
||||
#include "Forwards.h"
|
||||
#include <system_error>
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
|
@ -20,7 +18,7 @@ namespace Network {
|
|||
|
||||
class Connection;
|
||||
|
||||
class Acceptor : public boost::enable_shared_from_this< Acceptor >
|
||||
class Acceptor : public std::enable_shared_from_this< Acceptor >
|
||||
{
|
||||
friend class Hive;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include "CommonGen.h"
|
||||
|
||||
// +---------------------------------------------------------------------------
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
#include "Connection.h"
|
||||
#include "Hive.h"
|
||||
#include <boost/interprocess/detail/atomic.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <functional>
|
||||
|
||||
namespace Core {
|
||||
namespace Network {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Connection::Connection( HivePtr hive )
|
||||
:
|
||||
Connection::Connection( HivePtr hive ) :
|
||||
m_hive( hive ),
|
||||
m_socket( hive->GetService() ),
|
||||
m_io_strand( hive->GetService() ),
|
||||
|
@ -34,11 +32,11 @@ void Connection::StartSend()
|
|||
if( !m_pending_sends.empty() )
|
||||
{
|
||||
asio::async_write( m_socket,
|
||||
asio::buffer( m_pending_sends.front() ),
|
||||
m_io_strand.wrap( boost::bind( &Connection::HandleSend,
|
||||
shared_from_this(),
|
||||
asio::placeholders::error,
|
||||
m_pending_sends.begin() ) ) );
|
||||
asio::buffer( m_pending_sends.front() ),
|
||||
m_io_strand.wrap( std::bind( &Connection::HandleSend,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
m_pending_sends.begin() ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,20 +46,20 @@ void Connection::StartRecv( int32_t total_bytes )
|
|||
{
|
||||
m_recv_buffer.resize( total_bytes );
|
||||
asio::async_read( m_socket,
|
||||
asio::buffer( m_recv_buffer ),
|
||||
m_io_strand.wrap( boost::bind( &Connection::HandleRecv,
|
||||
shared_from_this(),
|
||||
_1,
|
||||
_2 ) ) );
|
||||
asio::buffer( m_recv_buffer ),
|
||||
m_io_strand.wrap( std::bind( &Connection::HandleRecv,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_recv_buffer.resize( m_receive_buffer_size );
|
||||
m_socket.async_read_some( asio::buffer( m_recv_buffer ),
|
||||
m_io_strand.wrap( boost::bind( &Connection::HandleRecv,
|
||||
shared_from_this(),
|
||||
_1,
|
||||
_2 ) ) );
|
||||
m_io_strand.wrap( std::bind( &Connection::HandleRecv,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +157,7 @@ void Connection::Connect( const std::string& host, uint16_t port )
|
|||
asio::ip::tcp::resolver::query query( host, std::to_string( port ) );
|
||||
asio::ip::tcp::resolver::iterator iterator = resolver.resolve( query );
|
||||
m_socket.async_connect( *iterator,
|
||||
m_io_strand.wrap( boost::bind( &Connection::HandleConnect, shared_from_this(), _1 ) ) );
|
||||
m_io_strand.wrap( std::bind( &Connection::HandleConnect, shared_from_this(), std::placeholders::_1 ) ) );
|
||||
|
||||
}
|
||||
|
||||
|
@ -171,12 +169,12 @@ void Connection::Disconnect()
|
|||
|
||||
void Connection::Recv( int32_t total_bytes )
|
||||
{
|
||||
m_io_strand.post( boost::bind( &Connection::DispatchRecv, shared_from_this(), total_bytes ) );
|
||||
m_io_strand.post( std::bind( &Connection::DispatchRecv, shared_from_this(), total_bytes ) );
|
||||
}
|
||||
|
||||
void Connection::Send( const std::vector< uint8_t >& buffer )
|
||||
{
|
||||
m_io_strand.post( boost::bind( &Connection::DispatchSend, shared_from_this(), buffer ) );
|
||||
m_io_strand.post( std::bind( &Connection::DispatchSend, shared_from_this(), buffer ) );
|
||||
}
|
||||
|
||||
asio::ip::tcp::socket& Connection::GetSocket()
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <atomic>
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "Acceptor.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Core {
|
||||
namespace Network {
|
||||
|
@ -26,7 +24,7 @@ class Connection;
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class Connection : public boost::enable_shared_from_this< Connection >
|
||||
class Connection : public std::enable_shared_from_this< Connection >
|
||||
{
|
||||
friend class Acceptor;
|
||||
|
||||
|
@ -147,13 +145,13 @@ public:
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
template< class T >
|
||||
boost::shared_ptr< T > addServerToHive( const std::string& listenIp, uint32_t port, HivePtr pHive )
|
||||
std::shared_ptr< T > addServerToHive( const std::string& listenIp, uint32_t port, HivePtr pHive )
|
||||
{
|
||||
try
|
||||
{
|
||||
AcceptorPtr acceptor( new Acceptor( pHive ) );
|
||||
acceptor->Listen( listenIp, port );
|
||||
boost::shared_ptr< T > connection( new T( pHive, acceptor ) );
|
||||
std::shared_ptr< T > connection( new T( pHive, acceptor ) );
|
||||
acceptor->Accept( connection );
|
||||
return connection;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <sstream>
|
||||
#include <time.h>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <string.h>
|
||||
#include <memory>
|
||||
#include <Util/Util.h>
|
||||
|
@ -36,27 +35,27 @@ using LobbyChannelPacket = FFXIVIpcPacket< T, ServerLobbyIpcType >;
|
|||
|
||||
|
||||
template< class T, typename... Args >
|
||||
boost::shared_ptr< ZoneChannelPacket< T > > makeZonePacket( Args... args )
|
||||
std::shared_ptr< ZoneChannelPacket< T > > makeZonePacket( Args... args )
|
||||
{
|
||||
return boost::make_shared< ZoneChannelPacket< T > >( args... );
|
||||
return std::make_shared< ZoneChannelPacket< T > >( args... );
|
||||
}
|
||||
|
||||
template< class T, typename... Args >
|
||||
boost::shared_ptr< T > makeWrappedPacket( Args... args )
|
||||
std::shared_ptr< T > makeWrappedPacket( Args... args )
|
||||
{
|
||||
return boost::make_shared< T >( args... );
|
||||
return std::make_shared< T >( args... );
|
||||
}
|
||||
|
||||
template< class T, typename... Args >
|
||||
boost::shared_ptr< ChatChannelPacket< T > > makeChatPacket( Args... args )
|
||||
std::shared_ptr< ChatChannelPacket< T > > makeChatPacket( Args... args )
|
||||
{
|
||||
return boost::make_shared< ChatChannelPacket< T > >( args... );
|
||||
return std::make_shared< ChatChannelPacket< T > >( args... );
|
||||
}
|
||||
|
||||
template< class T, typename... Args >
|
||||
boost::shared_ptr< LobbyChannelPacket< T > > makeLobbyPacket( Args... args )
|
||||
std::shared_ptr< LobbyChannelPacket< T > > makeLobbyPacket( Args... args )
|
||||
{
|
||||
return boost::make_shared< LobbyChannelPacket< T > >( args... );
|
||||
return std::make_shared< LobbyChannelPacket< T > >( args... );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <boost/bind.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include "Hive.h"
|
||||
|
||||
namespace Core {
|
||||
|
|
|
@ -2,18 +2,17 @@
|
|||
#define HIVE_H_
|
||||
|
||||
#include <asio.hpp>
|
||||
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
namespace Core {
|
||||
namespace Network {
|
||||
|
||||
class Hive : public boost::enable_shared_from_this< Hive >
|
||||
class Hive : public std::enable_shared_from_this< Hive >
|
||||
{
|
||||
private:
|
||||
asio::io_service m_io_service;
|
||||
boost::shared_ptr< asio::io_service::work > m_work_ptr;
|
||||
std::shared_ptr< asio::io_service::work > m_work_ptr;
|
||||
std::atomic< uint32_t > m_shutdown;
|
||||
|
||||
private:
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#include "Common.h"
|
||||
#include "Forwards.h"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <string.h>
|
||||
#include <memory>
|
||||
|
@ -78,7 +76,8 @@ std::string Core::Network::Packets::PacketContainer::toString()
|
|||
std::string str = "\n";
|
||||
for( uint32_t i = 0; i < m_ipcHdr.size; i++ )
|
||||
{
|
||||
str += boost::str( boost::format( "%|02X|" ) % static_cast< int32_t >( tmpBuffer[ i ] & 0xFF ) ) + " ";
|
||||
// TODO: use std::hex
|
||||
// str += boost::str( boost::format( "%|02X|" ) % static_cast< int32_t >( tmpBuffer[ i ] & 0xFF ) ) + " ";
|
||||
|
||||
if( ( i + 1 ) % 16 == 0 )
|
||||
str += "\n";
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <boost/utility.hpp>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
@ -95,7 +96,7 @@ void LockedQueue< T >::push_swap( T& object )
|
|||
//this is a special swap that will do a legit naive swap normally,
|
||||
// except if there exists a function called T::swap(), which is
|
||||
// specialized and possibly faster.
|
||||
boost::swap( object, default_ctored_object );
|
||||
std::swap( object, default_ctored_object );
|
||||
|
||||
|
||||
|
||||
|
@ -124,4 +125,4 @@ void LockedQueue< T >::push_reset( T& object )
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#ifndef _FORWARDS_H
|
||||
#define _FORWARDS_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#define TYPE_FORWARD( x ) \
|
||||
class x; \
|
||||
typedef boost::shared_ptr< x > x ## Ptr; \
|
||||
typedef std::shared_ptr< x > x ## Ptr; \
|
||||
template< typename...Args > \
|
||||
x ## Ptr make_ ## x( Args &&...args ) { \
|
||||
return boost::make_shared< x >( std::forward< Args >( args ) ... ); }\
|
||||
return std::make_shared< x >( std::forward< Args >( args ) ... ); }\
|
||||
typedef std::vector< x > x ## PtrList;
|
||||
|
||||
namespace Core {
|
||||
|
@ -36,4 +35,4 @@ TYPE_FORWARD( FFXIVPacketBase );
|
|||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Core {
|
|||
namespace Network {
|
||||
namespace Packets {
|
||||
|
||||
typedef boost::shared_ptr< FFXIVPacketBase > FFXIVPacketBasePtr;
|
||||
typedef std::shared_ptr< FFXIVPacketBase > FFXIVPacketBasePtr;
|
||||
|
||||
class LobbyPacketContainer
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue