From f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 21 Nov 2013 22:16:57 +0100 Subject: Boost/C++11 shared pointers. --- src/net/serviceFactory.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/net/serviceFactory.cpp') diff --git a/src/net/serviceFactory.cpp b/src/net/serviceFactory.cpp index c44cbadc..a16098ce 100644 --- a/src/net/serviceFactory.cpp +++ b/src/net/serviceFactory.cpp @@ -49,26 +49,26 @@ serviceFactory::~serviceFactory() } -serviceFactory* serviceFactory::getInstance() +shared_ptr serviceFactory::getInstance() { static serviceFactory instance; - return (&instance); + return shared_ptr (&instance, noop_shared_ptr_deleter ()); } -ref serviceFactory::create - (ref sess, const string& protocol, - ref auth) +shared_ptr serviceFactory::create + (shared_ptr sess, const string& protocol, + shared_ptr auth) { return (getServiceByProtocol(protocol)->create(sess, auth)); } -ref serviceFactory::create - (ref sess, const utility::url& u, - ref auth) +shared_ptr serviceFactory::create + (shared_ptr sess, const utility::url& u, + shared_ptr auth) { - ref serv = create(sess, u.getProtocol(), auth); + shared_ptr serv = create(sess, u.getProtocol(), auth); sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.address"] = u.getHost(); @@ -90,11 +90,11 @@ ref serviceFactory::create } -ref serviceFactory::getServiceByProtocol(const string& protocol) const +shared_ptr serviceFactory::getServiceByProtocol(const string& protocol) const { const string name(utility::stringUtils::toLower(protocol)); - for (std::vector >::const_iterator it = m_services.begin() ; + for (std::vector >::const_iterator it = m_services.begin() ; it != m_services.end() ; ++it) { if ((*it)->getName() == name) @@ -111,17 +111,17 @@ size_t serviceFactory::getServiceCount() const } -ref serviceFactory::getServiceAt(const size_t pos) const +shared_ptr serviceFactory::getServiceAt(const size_t pos) const { return (m_services[pos]); } -const std::vector > serviceFactory::getServiceList() const +const std::vector > serviceFactory::getServiceList() const { - std::vector > res; + std::vector > res; - for (std::vector >::const_iterator it = m_services.begin() ; + for (std::vector >::const_iterator it = m_services.begin() ; it != m_services.end() ; ++it) { res.push_back(*it); @@ -131,7 +131,7 @@ const std::vector > serviceFactor } -void serviceFactory::registerService(ref reg) +void serviceFactory::registerService(shared_ptr reg) { m_services.push_back(reg); } -- cgit v1.2.3