|
1 | 1 | // |
2 | 2 | // CertificateHandlerFactory.h |
3 | 3 | // |
4 | | -// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h#6 $ |
| 4 | +// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactory.h#7 $ |
5 | 5 | // |
6 | 6 | // Library: NetSSL_OpenSSL |
7 | 7 | // Package: SSLCore |
@@ -82,22 +82,32 @@ class NetSSL_API CertificateHandlerFactoryRegistrar |
82 | 82 | /// Destroys the CertificateHandlerFactoryRegistrar. |
83 | 83 | }; |
84 | 84 |
|
85 | | - |
86 | | -#define POCO_REGISTER_CHFACTORY(API, PKCLS) \ |
87 | | - class API PKCLS##Factory: public Poco::Net::CertificateHandlerFactory \ |
88 | | - { \ |
89 | | - public: \ |
90 | | - PKCLS##Factory(){} \ |
91 | | - ~PKCLS##Factory(){} \ |
92 | | - Poco::Net::InvalidCertificateHandler* create(bool server) const \ |
93 | | - { \ |
94 | | - return new PKCLS(server); \ |
95 | | - } \ |
96 | | - }; \ |
97 | | - static Poco::Net::CertificateHandlerFactoryRegistrar aRegistrar(std::string(#PKCLS), new PKCLS##Factory()); |
| 85 | +template <typename T> |
| 86 | +class CertificateHandlerFactoryImpl: public Poco::Net::CertificateHandlerFactory |
| 87 | +{ |
| 88 | +public: |
| 89 | + CertificateHandlerFactoryImpl() |
| 90 | + { |
| 91 | + } |
| 92 | + |
| 93 | + ~CertificateHandlerFactoryImpl() |
| 94 | + { |
| 95 | + } |
| 96 | + |
| 97 | + InvalidCertificateHandler* create(bool server) const |
| 98 | + { |
| 99 | + return new T(server); |
| 100 | + } |
| 101 | +}; |
98 | 102 |
|
99 | 103 |
|
100 | 104 | } } // namespace Poco::Net |
101 | 105 |
|
102 | 106 |
|
| 107 | +// DEPRECATED: register the factory directly at the FactoryMgr: |
| 108 | +// Poco::Net::SSLManager::instance().certificateHandlerFactoryMgr().setFactory(name, new Poco::Net::CertificateHandlerFactoryImpl<MyConsoleHandler>()); |
| 109 | +#define POCO_REGISTER_CHFACTORY(API, PKCLS) \ |
| 110 | + static Poco::Net::CertificateHandlerFactoryRegistrar aRegistrar(std::string(#PKCLS), new Poco::Net::CertificateHandlerFactoryImpl<PKCLS>()); |
| 111 | + |
| 112 | + |
103 | 113 | #endif // NetSSL_CertificateHandlerFactory_INCLUDED |
0 commit comments