Replaced most fc::shared_ptr with std::shared_ptr
This commit is contained in:
parent
ab9b4a234e
commit
58e16e543d
17 changed files with 43 additions and 53 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <fc/shared_ptr.hpp>
|
|
||||||
#include <fc/filesystem.hpp>
|
#include <fc/filesystem.hpp>
|
||||||
#include <fc/io/iostream.hpp>
|
#include <fc/io/iostream.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
class path;
|
class path;
|
||||||
|
|
@ -21,7 +21,7 @@ namespace fc {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class impl;
|
class impl;
|
||||||
fc::shared_ptr<impl> my;
|
std::shared_ptr<impl> my;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ifstream : virtual public istream {
|
class ifstream : virtual public istream {
|
||||||
|
|
@ -44,7 +44,7 @@ namespace fc {
|
||||||
bool eof()const;
|
bool eof()const;
|
||||||
private:
|
private:
|
||||||
class impl;
|
class impl;
|
||||||
fc::shared_ptr<impl> my;
|
std::shared_ptr<impl> my;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,11 @@
|
||||||
#include <fc/io/raw_variant.hpp>
|
#include <fc/io/raw_variant.hpp>
|
||||||
#include <fc/reflect/reflect.hpp>
|
#include <fc/reflect/reflect.hpp>
|
||||||
#include <fc/io/datastream.hpp>
|
#include <fc/io/datastream.hpp>
|
||||||
#include <fc/io/varint.hpp>
|
|
||||||
#include <fc/optional.hpp>
|
#include <fc/optional.hpp>
|
||||||
#include <fc/fwd.hpp>
|
#include <fc/fwd.hpp>
|
||||||
#include <fc/array.hpp>
|
|
||||||
#include <fc/time.hpp>
|
#include <fc/time.hpp>
|
||||||
#include <fc/filesystem.hpp>
|
#include <fc/filesystem.hpp>
|
||||||
#include <fc/exception/exception.hpp>
|
#include <fc/exception/exception.hpp>
|
||||||
#include <fc/safe.hpp>
|
|
||||||
#include <fc/io/raw_fwd.hpp>
|
#include <fc/io/raw_fwd.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <fc/array.hpp>
|
#include <fc/array.hpp>
|
||||||
#include <fc/safe.hpp>
|
#include <fc/safe.hpp>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
@ -132,14 +133,14 @@ namespace fc {
|
||||||
template<typename Stream, size_t N> inline void pack( Stream& s, const fc::array<unsigned char,N>& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
template<typename Stream, size_t N> inline void pack( Stream& s, const fc::array<unsigned char,N>& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
||||||
template<typename Stream, size_t N> inline void unpack( Stream& s, fc::array<unsigned char,N>& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH);
|
template<typename Stream, size_t N> inline void unpack( Stream& s, fc::array<unsigned char,N>& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH);
|
||||||
|
|
||||||
template<typename Stream, typename T> inline void pack( Stream& s, const shared_ptr<T>& v,
|
template<typename Stream, typename T> inline void pack( Stream& s, const std::shared_ptr<T>& v,
|
||||||
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
||||||
template<typename Stream, typename T> inline void unpack( Stream& s, shared_ptr<T>& v,
|
template<typename Stream, typename T> inline void unpack( Stream& s, std::shared_ptr<T>& v,
|
||||||
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
||||||
|
|
||||||
template<typename Stream, typename T> inline void pack( Stream& s, const shared_ptr<const T>& v,
|
template<typename Stream, typename T> inline void pack( Stream& s, const std::shared_ptr<const T>& v,
|
||||||
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
||||||
template<typename Stream, typename T> inline void unpack( Stream& s, shared_ptr<const T>& v,
|
template<typename Stream, typename T> inline void unpack( Stream& s, std::shared_ptr<const T>& v,
|
||||||
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
||||||
|
|
||||||
template<typename Stream> inline void pack( Stream& s, const bool& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
template<typename Stream> inline void pack( Stream& s, const bool& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH );
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <fc/shared_ptr.hpp>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
@ -7,31 +7,31 @@ namespace fc {
|
||||||
class log_message;
|
class log_message;
|
||||||
class variant;
|
class variant;
|
||||||
|
|
||||||
class appender_factory : public fc::retainable {
|
class appender_factory {
|
||||||
public:
|
public:
|
||||||
typedef fc::shared_ptr<appender_factory> ptr;
|
typedef std::shared_ptr<appender_factory> ptr;
|
||||||
|
|
||||||
virtual ~appender_factory(){};
|
virtual ~appender_factory(){};
|
||||||
virtual fc::shared_ptr<appender> create( const variant& args ) = 0;
|
virtual std::shared_ptr<appender> create( const variant& args ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class appender_factory_impl : public appender_factory {
|
class appender_factory_impl : public appender_factory {
|
||||||
public:
|
public:
|
||||||
virtual fc::shared_ptr<appender> create( const variant& args ) {
|
virtual std::shared_ptr<appender> create( const variant& args ) {
|
||||||
return fc::shared_ptr<appender>(new T(args));
|
return std::shared_ptr<appender>(new T(args));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class appender : public fc::retainable {
|
class appender {
|
||||||
public:
|
public:
|
||||||
typedef fc::shared_ptr<appender> ptr;
|
typedef std::shared_ptr<appender> ptr;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool register_appender(const std::string& type) {
|
static bool register_appender(const std::string& type) {
|
||||||
return register_appender( type, new detail::appender_factory_impl<T>() );
|
return register_appender( type, appender_factory::ptr( new detail::appender_factory_impl<T>() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static appender::ptr create( const std::string& name, const std::string& type, const variant& args );
|
static appender::ptr create( const std::string& name, const std::string& type, const variant& args );
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class file_appender : public appender {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class impl;
|
class impl;
|
||||||
fc::shared_ptr<impl> my;
|
std::unique_ptr<impl> my;
|
||||||
};
|
};
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace fc
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class impl;
|
class impl;
|
||||||
fc::shared_ptr<impl> my;
|
std::unique_ptr<impl> my;
|
||||||
};
|
};
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <fc/config.hpp>
|
#include <fc/config.hpp>
|
||||||
#include <fc/time.hpp>
|
#include <fc/time.hpp>
|
||||||
#include <fc/variant_object.hpp>
|
#include <fc/variant_object.hpp>
|
||||||
#include <fc/shared_ptr.hpp>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <fc/config.hpp>
|
#include <fc/config.hpp>
|
||||||
#include <fc/time.hpp>
|
#include <fc/time.hpp>
|
||||||
#include <fc/shared_ptr.hpp>
|
#include <fc/log/appender.hpp>
|
||||||
#include <fc/log/log_message.hpp>
|
#include <fc/log/log_message.hpp>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
class appender;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
@ -43,16 +41,16 @@ namespace fc
|
||||||
void set_name( const std::string& n );
|
void set_name( const std::string& n );
|
||||||
const std::string& name()const;
|
const std::string& name()const;
|
||||||
|
|
||||||
void add_appender( const fc::shared_ptr<appender>& a );
|
void add_appender( const appender::ptr& a );
|
||||||
std::vector<fc::shared_ptr<appender> > get_appenders()const;
|
std::vector<appender::ptr> get_appenders()const;
|
||||||
void remove_appender( const fc::shared_ptr<appender>& a );
|
void remove_appender( const appender::ptr& a );
|
||||||
|
|
||||||
bool is_enabled( log_level e )const;
|
bool is_enabled( log_level e )const;
|
||||||
void log( log_message m );
|
void log( log_message m );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class impl;
|
class impl;
|
||||||
fc::shared_ptr<impl> my;
|
std::shared_ptr<impl> my;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <fc/network/http/connection.hpp>
|
#include <fc/network/http/connection.hpp>
|
||||||
#include <fc/shared_ptr.hpp>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
@ -28,7 +27,7 @@ namespace fc { namespace http {
|
||||||
class impl;
|
class impl;
|
||||||
|
|
||||||
response();
|
response();
|
||||||
response( const fc::shared_ptr<impl>& my);
|
response( const std::shared_ptr<impl>& my);
|
||||||
response( const response& r);
|
response( const response& r);
|
||||||
response( response&& r );
|
response( response&& r );
|
||||||
~response();
|
~response();
|
||||||
|
|
@ -42,7 +41,7 @@ namespace fc { namespace http {
|
||||||
void write( const char* data, uint64_t len )const;
|
void write( const char* data, uint64_t len )const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fc::shared_ptr<impl> my;
|
std::shared_ptr<impl> my;
|
||||||
};
|
};
|
||||||
|
|
||||||
void listen( const fc::ip::endpoint& p );
|
void listen( const fc::ip::endpoint& p );
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <fc/shared_ptr.hpp>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
@ -35,8 +34,8 @@ namespace fc {
|
||||||
fc::ip::endpoint local_endpoint()const;
|
fc::ip::endpoint local_endpoint()const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class impl;
|
class impl;
|
||||||
fc::shared_ptr<impl> my;
|
std::shared_ptr<impl> my;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <fc/variant.hpp>
|
#include <fc/variant.hpp>
|
||||||
#include <fc/shared_ptr.hpp>
|
#include <memory>
|
||||||
|
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
class ofstream::impl : public fc::retainable {
|
class ofstream::impl {
|
||||||
public:
|
public:
|
||||||
boost::filesystem::ofstream ofs;
|
boost::filesystem::ofstream ofs;
|
||||||
};
|
};
|
||||||
class ifstream::impl : public fc::retainable {
|
class ifstream::impl {
|
||||||
public:
|
public:
|
||||||
boost::filesystem::ifstream ifs;
|
boost::filesystem::ifstream ifs;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
||||||
class file_appender::impl : public fc::retainable
|
class file_appender::impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
config cfg;
|
config cfg;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
class gelf_appender::impl : public retainable
|
class gelf_appender::impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
config cfg;
|
config cfg;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
||||||
class logger::impl : public fc::retainable {
|
class logger::impl {
|
||||||
public:
|
public:
|
||||||
impl()
|
impl()
|
||||||
:_parent(nullptr),_enabled(true),_additivity(false),_level(log_level::warn){}
|
:_parent(nullptr),_enabled(true),_additivity(false),_level(log_level::warn){}
|
||||||
|
|
@ -54,8 +54,8 @@ namespace fc {
|
||||||
std::swap(my,l.my);
|
std::swap(my,l.my);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
bool operator==( const logger& l, std::nullptr_t ) { return !l.my; }
|
bool operator==( const logger& l, std::nullptr_t ) { return !(bool)l.my; }
|
||||||
bool operator!=( const logger& l, std::nullptr_t ) { return l.my; }
|
bool operator!=( const logger& l, std::nullptr_t ) { return (bool)l.my; }
|
||||||
|
|
||||||
bool logger::is_enabled( log_level e )const {
|
bool logger::is_enabled( log_level e )const {
|
||||||
return e >= my->_level;
|
return e >= my->_level;
|
||||||
|
|
@ -96,13 +96,10 @@ namespace fc {
|
||||||
log_level logger::get_log_level()const { return my->_level; }
|
log_level logger::get_log_level()const { return my->_level; }
|
||||||
logger& logger::set_log_level(log_level ll) { my->_level = ll; return *this; }
|
logger& logger::set_log_level(log_level ll) { my->_level = ll; return *this; }
|
||||||
|
|
||||||
void logger::add_appender( const fc::shared_ptr<appender>& a )
|
void logger::add_appender( const appender::ptr& a )
|
||||||
{ my->_appenders.push_back(a); }
|
{ my->_appenders.push_back(a); }
|
||||||
|
|
||||||
// void logger::remove_appender( const fc::shared_ptr<appender>& a )
|
std::vector<appender::ptr> logger::get_appenders()const
|
||||||
// { my->_appenders.erase(a); }
|
|
||||||
|
|
||||||
std::vector<fc::shared_ptr<appender> > logger::get_appenders()const
|
|
||||||
{
|
{
|
||||||
return my->_appenders;
|
return my->_appenders;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace fc { namespace http {
|
namespace fc { namespace http {
|
||||||
|
|
||||||
class server::response::impl : public fc::retainable
|
class server::response::impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
impl( const fc::http::connection_ptr& c, const std::function<void()>& cont = std::function<void()>() )
|
impl( const fc::http::connection_ptr& c, const std::function<void()>& cont = std::function<void()>() )
|
||||||
|
|
@ -112,7 +112,7 @@ namespace fc { namespace http {
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
http::server::response rep( fc::shared_ptr<response::impl>( new response::impl(c) ) );
|
http::server::response rep( std::shared_ptr<response::impl>( new response::impl(c) ) );
|
||||||
request req = c->read_request();
|
request req = c->read_request();
|
||||||
if( do_on_req )
|
if( do_on_req )
|
||||||
do_on_req( req, rep );
|
do_on_req( req, rep );
|
||||||
|
|
@ -155,7 +155,7 @@ namespace fc { namespace http {
|
||||||
server::response::response(){}
|
server::response::response(){}
|
||||||
server::response::response( const server::response& s ):my(s.my){}
|
server::response::response( const server::response& s ):my(s.my){}
|
||||||
server::response::response( server::response&& s ):my(std::move(s.my)){}
|
server::response::response( server::response&& s ):my(std::move(s.my)){}
|
||||||
server::response::response( const fc::shared_ptr<server::response::impl>& m ):my(m){}
|
server::response::response( const std::shared_ptr<server::response::impl>& m ):my(m){}
|
||||||
|
|
||||||
server::response& server::response::operator=(const server::response& s) { my = s.my; return *this; }
|
server::response& server::response::operator=(const server::response& s) { my = s.my; return *this; }
|
||||||
server::response& server::response::operator=(server::response&& s) { std::swap(my,s.my); return *this; }
|
server::response& server::response::operator=(server::response&& s) { std::swap(my,s.my); return *this; }
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
||||||
class udp_socket::impl : public fc::retainable {
|
class udp_socket::impl {
|
||||||
public:
|
public:
|
||||||
impl():_sock( fc::asio::default_io_service() ){}
|
impl():_sock( fc::asio::default_io_service() ){}
|
||||||
~impl(){
|
~impl(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue