Skip to content

Commit a790bba

Browse files
committed
replaced plain pointers with smart pointers in various interfaces
1 parent 37e6fa3 commit a790bba

16 files changed

Lines changed: 60 additions & 70 deletions

‎Net/include/Poco/Net/HTTPRequestHandlerFactory.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPRequestHandlerFactory.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/HTTPRequestHandlerFactory.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/HTTPRequestHandlerFactory.h#4 $
55
//
66
// Library: Net
77
// Package: HTTPServer
@@ -41,6 +41,7 @@
4141

4242

4343
#include "Poco/Net/Net.h"
44+
#include "Poco/SharedPtr.h"
4445

4546

4647
namespace Poco {
@@ -58,6 +59,8 @@ class Net_API HTTPRequestHandlerFactory
5859
/// method.
5960
{
6061
public:
62+
typedef Poco::SharedPtr<HTTPRequestHandlerFactory> Ptr;
63+
6164
HTTPRequestHandlerFactory();
6265
/// Creates the HTTPRequestHandlerFactory.
6366

‎Net/include/Poco/Net/HTTPServer.h‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPServer.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServer.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/HTTPServer.h#3 $
55
//
66
// Library: Net
77
// Package: HTTPServer
@@ -42,16 +42,14 @@
4242

4343
#include "Poco/Net/Net.h"
4444
#include "Poco/Net/TCPServer.h"
45+
#include "Poco/Net/HTTPRequestHandlerFactory.h"
46+
#include "Poco/Net/HTTPServerParams.h"
4547

4648

4749
namespace Poco {
4850
namespace Net {
4951

5052

51-
class HTTPRequestHandlerFactory;
52-
class HTTPServerParams;
53-
54-
5553
class Net_API HTTPServer: public TCPServer
5654
/// A subclass of TCPServer that implements a
5755
/// full-featured multithreaded HTTP server.
@@ -75,7 +73,7 @@ class Net_API HTTPServer: public TCPServer
7573
/// information about the HTTP protocol.
7674
{
7775
public:
78-
HTTPServer(HTTPRequestHandlerFactory* pFactory, const ServerSocket& socket, HTTPServerParams* pParams);
76+
HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, const ServerSocket& socket, HTTPServerParams::Ptr pParams);
7977
/// Creates the HTTPServer, using the given ServerSocket.
8078
///
8179
/// The server takes ownership of the HTTPRequstHandlerFactory
@@ -85,7 +83,7 @@ class Net_API HTTPServer: public TCPServer
8583
///
8684
/// News threads are taken from the default thread pool.
8785

88-
HTTPServer(HTTPRequestHandlerFactory* pFactory, Poco::ThreadPool& threadPool, const ServerSocket& socket, HTTPServerParams* pParams);
86+
HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, Poco::ThreadPool& threadPool, const ServerSocket& socket, HTTPServerParams::Ptr pParams);
8987
/// Creates the HTTPServer, using the given ServerSocket.
9088
///
9189
/// The server takes ownership of the HTTPRequstHandlerFactory

‎Net/include/Poco/Net/HTTPServerConnection.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPServerConnection.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerConnection.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/HTTPServerConnection.h#4 $
55
//
66
// Library: Net
77
// Package: HTTPServer
@@ -43,14 +43,14 @@
4343
#include "Poco/Net/Net.h"
4444
#include "Poco/Net/TCPServerConnection.h"
4545
#include "Poco/Net/HTTPResponse.h"
46+
#include "Poco/Net/HTTPRequestHandlerFactory.h"
47+
#include "Poco/Net/HTTPServerParams.h"
4648

4749

4850
namespace Poco {
4951
namespace Net {
5052

5153

52-
class HTTPServerParams;
53-
class HTTPRequestHandlerFactory;
5454
class HTTPServerSession;
5555

5656

@@ -59,7 +59,7 @@ class Net_API HTTPServerConnection: public TCPServerConnection
5959
/// connections.
6060
{
6161
public:
62-
HTTPServerConnection(const StreamSocket& socket, HTTPServerParams* pParams, HTTPRequestHandlerFactory* pFactory);
62+
HTTPServerConnection(const StreamSocket& socket, HTTPServerParams::Ptr pParams, HTTPRequestHandlerFactory::Ptr pFactory);
6363
/// Creates the HTTPServerConnection.
6464

6565
virtual ~HTTPServerConnection();
@@ -72,8 +72,8 @@ class Net_API HTTPServerConnection: public TCPServerConnection
7272
void sendErrorResponse(HTTPServerSession& session, HTTPResponse::HTTPStatus status);
7373

7474
private:
75-
HTTPServerParams* _pParams;
76-
HTTPRequestHandlerFactory* _pFactory;
75+
HTTPServerParams::Ptr _pParams;
76+
HTTPRequestHandlerFactory::Ptr _pFactory;
7777
};
7878

7979

‎Net/include/Poco/Net/HTTPServerConnectionFactory.h‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPServerConnectionFactory.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerConnectionFactory.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/HTTPServerConnectionFactory.h#3 $
55
//
66
// Library: Net
77
// Package: HTTPServer
@@ -42,22 +42,20 @@
4242

4343
#include "Poco/Net/Net.h"
4444
#include "Poco/Net/TCPServerConnectionFactory.h"
45+
#include "Poco/Net/HTTPRequestHandlerFactory.h"
46+
#include "Poco/Net/HTTPServerParams.h"
4547

4648

4749
namespace Poco {
4850
namespace Net {
4951

5052

51-
class HTTPServerParams;
52-
class HTTPRequestHandlerFactory;
53-
54-
5553
class Net_API HTTPServerConnectionFactory: public TCPServerConnectionFactory
5654
/// This implementation of a TCPServerConnectionFactory
5755
/// is used by HTTPServer to create HTTPServerConnection objects.
5856
{
5957
public:
60-
HTTPServerConnectionFactory(HTTPServerParams* pParams, HTTPRequestHandlerFactory* pFactory);
58+
HTTPServerConnectionFactory(HTTPServerParams::Ptr pParams, HTTPRequestHandlerFactory::Ptr pFactory);
6159
/// Creates the HTTPServerConnectionFactory.
6260

6361
~HTTPServerConnectionFactory();
@@ -68,8 +66,8 @@ class Net_API HTTPServerConnectionFactory: public TCPServerConnectionFactory
6866
/// using the given StreamSocket.
6967

7068
private:
71-
HTTPServerParams* _pParams;
72-
HTTPRequestHandlerFactory* _pFactory;
69+
HTTPServerParams::Ptr _pParams;
70+
HTTPRequestHandlerFactory::Ptr _pFactory;
7371
};
7472

7573

‎Net/include/Poco/Net/HTTPServerParams.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTPServerParams.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerParams.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/HTTPServerParams.h#3 $
55
//
66
// Library: Net
77
// Package: HTTPServer
@@ -55,6 +55,8 @@ class Net_API HTTPServerParams: public TCPServerParams
5555
/// Subclasses may add new parameters to the class.
5656
{
5757
public:
58+
typedef Poco::AutoPtr<HTTPServerParams> Ptr;
59+
5860
HTTPServerParams();
5961
/// Creates the HTTPServerParams.
6062
///

‎Net/include/Poco/Net/NetworkInterface.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// NetworkInterface.h
33
//
4-
// $Id: //poco/1.3/Net/include/Poco/Net/NetworkInterface.h#7 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/NetworkInterface.h#5 $
55
//
66
// Library: Net
77
// Package: Sockets

‎Net/include/Poco/Net/TCPServer.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// TCPServer.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/TCPServer.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/TCPServer.h#4 $
55
//
66
// Library: Net
77
// Package: TCPServer
@@ -42,6 +42,8 @@
4242

4343
#include "Poco/Net/Net.h"
4444
#include "Poco/Net/ServerSocket.h"
45+
#include "Poco/Net/TCPServerConnectionFactory.h"
46+
#include "Poco/Net/TCPServerParams.h"
4547
#include "Poco/Runnable.h"
4648
#include "Poco/Thread.h"
4749
#include "Poco/ThreadPool.h"
@@ -51,9 +53,7 @@ namespace Poco {
5153
namespace Net {
5254

5355

54-
class TCPServerParams;
5556
class TCPServerDispatcher;
56-
class TCPServerConnectionFactory;
5757

5858

5959
class Net_API TCPServer: public Poco::Runnable
@@ -98,7 +98,7 @@ class Net_API TCPServer: public Poco::Runnable
9898
/// Already served connections, however, will continue being served.
9999
{
100100
public:
101-
TCPServer(TCPServerConnectionFactory* pFactory, const ServerSocket& socket, TCPServerParams* pParams = 0);
101+
TCPServer(TCPServerConnectionFactory::Ptr pFactory, const ServerSocket& socket, TCPServerParams::Ptr pParams = 0);
102102
/// Creates the TCPServer, using the given ServerSocket.
103103
///
104104
/// The server takes ownership of the TCPServerConnectionFactory
@@ -110,7 +110,7 @@ class Net_API TCPServer: public Poco::Runnable
110110
///
111111
/// News threads are taken from the default thread pool.
112112

113-
TCPServer(TCPServerConnectionFactory* pFactory, Poco::ThreadPool& threadPool, const ServerSocket& socket, TCPServerParams* pParams = 0);
113+
TCPServer(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, const ServerSocket& socket, TCPServerParams::Ptr pParams = 0);
114114
/// Creates the TCPServer, using the given ServerSocket.
115115
///
116116
/// The server takes ownership of the TCPServerConnectionFactory

‎Net/include/Poco/Net/TCPServerConnectionFactory.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// TCPServerConnectionFactory.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/TCPServerConnectionFactory.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/TCPServerConnectionFactory.h#3 $
55
//
66
// Library: Net
77
// Package: TCPServer
@@ -42,6 +42,7 @@
4242

4343
#include "Poco/Net/Net.h"
4444
#include "Poco/Net/TCPServerConnection.h"
45+
#include "Poco/SharedPtr.h"
4546

4647

4748
namespace Poco {
@@ -64,6 +65,8 @@ class Net_API TCPServerConnectionFactory
6465
/// of TCPServerConnection.
6566
{
6667
public:
68+
typedef Poco::SharedPtr<TCPServerConnectionFactory> Ptr;
69+
6770
virtual ~TCPServerConnectionFactory();
6871
/// Destroys the TCPServerConnectionFactory.
6972

‎Net/include/Poco/Net/TCPServerDispatcher.h‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// TCPServerDispatcher.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/TCPServerDispatcher.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/TCPServerDispatcher.h#3 $
55
//
66
// Library: Net
77
// Package: TCPServer
@@ -42,6 +42,8 @@
4242

4343
#include "Poco/Net/Net.h"
4444
#include "Poco/Net/StreamSocket.h"
45+
#include "Poco/Net/TCPServerConnectionFactory.h"
46+
#include "Poco/Net/TCPServerParams.h"
4547
#include "Poco/Runnable.h"
4648
#include "Poco/NotificationQueue.h"
4749
#include "Poco/ThreadPool.h"
@@ -52,16 +54,12 @@ namespace Poco {
5254
namespace Net {
5355

5456

55-
class TCPServerParams;
56-
class TCPServerConnectionFactory;
57-
58-
5957
class Net_API TCPServerDispatcher: public Poco::Runnable
6058
/// A helper class for TCPServer that dispatches
6159
/// connections to server connection threads.
6260
{
6361
public:
64-
TCPServerDispatcher(TCPServerConnectionFactory* pFactory, Poco::ThreadPool& threadPool, TCPServerParams* pParams);
62+
TCPServerDispatcher(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, TCPServerParams::Ptr pParams);
6563
/// Creates the TCPServerDispatcher.
6664
///
6765
/// The dispatcher takes ownership of the TCPServerParams object.
@@ -122,17 +120,17 @@ class Net_API TCPServerDispatcher: public Poco::Runnable
122120
TCPServerDispatcher& operator = (const TCPServerDispatcher&);
123121

124122
int _rc;
125-
TCPServerParams* _pParams;
123+
TCPServerParams::Ptr _pParams;
126124
int _currentThreads;
127125
int _totalConnections;
128126
int _currentConnections;
129127
int _maxConcurrentConnections;
130128
int _refusedConnections;
131129
bool _stopped;
132-
Poco::NotificationQueue _queue;
133-
TCPServerConnectionFactory* _pConnectionFactory;
134-
Poco::ThreadPool& _threadPool;
135-
mutable Poco::FastMutex _mutex;
130+
Poco::NotificationQueue _queue;
131+
TCPServerConnectionFactory::Ptr _pConnectionFactory;
132+
Poco::ThreadPool& _threadPool;
133+
mutable Poco::FastMutex _mutex;
136134
};
137135

138136

‎Net/include/Poco/Net/TCPServerParams.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// TCPServerParams.h
33
//
4-
// $Id: //poco/svn/Net/include/Poco/Net/TCPServerParams.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/TCPServerParams.h#4 $
55
//
66
// Library: Net
77
// Package: TCPServer
@@ -44,6 +44,7 @@
4444
#include "Poco/RefCountedObject.h"
4545
#include "Poco/Timespan.h"
4646
#include "Poco/Thread.h"
47+
#include "Poco/AutoPtr.h"
4748

4849

4950
namespace Poco {
@@ -57,6 +58,8 @@ class Net_API TCPServerParams: public Poco::RefCountedObject
5758
/// Subclasses may add new parameters to the class.
5859
{
5960
public:
61+
typedef Poco::AutoPtr<TCPServerParams> Ptr;
62+
6063
TCPServerParams();
6164
/// Creates the TCPServerParams.
6265
///

0 commit comments

Comments
 (0)