diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-03-16 09:08:19 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-03-16 09:08:19 +0000 |
commit | a338d3c93426108a75a1e4277bf04d42dfeea5e8 (patch) | |
tree | 0ea4a8b15afb2da16bc8a2a83700cb5fdaa3ed95 | |
parent | Add use group pages and update links on package page (diff) | |
download | gentoobrowse-a338d3c93426108a75a1e4277bf04d42dfeea5e8.tar.bz2 gentoobrowse-a338d3c93426108a75a1e4277bf04d42dfeea5e8.tar.xz gentoobrowse-a338d3c93426108a75a1e4277bf04d42dfeea5e8.zip |
Serializers should be members to avoid memory leakgentoobrowse-2.0.0_beta7
-rw-r--r-- | gentoobrowse/src/packages.cpp | 28 | ||||
-rw-r--r-- | gentoobrowse/src/search.cpp | 6 | ||||
-rw-r--r-- | gentoobrowse/src/user.cpp | 28 |
3 files changed, 43 insertions, 19 deletions
diff --git a/gentoobrowse/src/packages.cpp b/gentoobrowse/src/packages.cpp index c3e6d6c..ce07a11 100644 --- a/gentoobrowse/src/packages.cpp +++ b/gentoobrowse/src/packages.cpp @@ -35,10 +35,12 @@ namespace GentooBrowse { common(core), prx0(core->getProxy<Gentoo::Portage>()), prx1(core->getProxy<Gentoo::Users>()), - _pd_syncs(3) + _pd_syncs(3), + _serializer_text_html("xslt/home.xslt"), + _serializer_application_atom_xml("xslt/home-atom.xslt") { - addRouteSerializer({ "application", "atom+xml" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/home-atom.xslt")); - addRouteSerializer({ "text", "html" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/home.xslt")); + addRouteSerializer({ "application", "atom+xml" }, &_serializer_application_atom_xml); + addRouteSerializer({ "text", "html" }, &_serializer_text_html ); } ~index() @@ -81,6 +83,8 @@ namespace GentooBrowse { const Gentoo::PortagePrx prx0; const Gentoo::UsersPrx prx1; const ::Ice::Int _pd_syncs; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_application_atom_xml; }; // Route name: category @@ -92,9 +96,10 @@ namespace GentooBrowse { IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/packages/{category}"), common(core), prx0(core->getProxy<Gentoo::Portage>()), - _pi_category(1) + _pi_category(1), + _serializer_text_html("xslt/category.xslt") { - addRouteSerializer({ "text", "html" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/category.xslt")); + addRouteSerializer({ "text", "html" }, &_serializer_text_html); } ~category() @@ -117,6 +122,7 @@ namespace GentooBrowse { private: const Gentoo::PortagePrx prx0; const ::Ice::Int _pi_category; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; }; // Route name: package @@ -130,9 +136,10 @@ namespace GentooBrowse { prx0(core->getProxy<Gentoo::Portage>()), prx1(core->getProxy<Gentoo::Users>()), _pi_category(1), - _pi_package(2) + _pi_package(2), + _serializer_text_html("xslt/package.xslt") { - addRouteSerializer({ "text", "html" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/package.xslt")); + addRouteSerializer({ "text", "html" }, &_serializer_text_html); } ~package() @@ -199,6 +206,7 @@ namespace GentooBrowse { const Gentoo::UsersPrx prx1; const ::Ice::Int _pi_category; const ::Ice::Int _pi_package; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; }; @@ -278,9 +286,10 @@ namespace GentooBrowse { common(core), prx0(core->getProxy<Gentoo::Portage>()), prx1(core->getProxy<Gentoo::Users>()), - _pi_username(1) + _pi_username(1), + _serializer_application_atom_xml("xslt/user-atom.xslt") { - addRouteSerializer({ "application", "atom+xml" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/user-atom.xslt")); + addRouteSerializer({ "application", "atom+xml" }, &_serializer_application_atom_xml); removeRouteSerializer({ "application", "xml" }); removeRouteSerializer({ "application", "json" }); } @@ -310,6 +319,7 @@ namespace GentooBrowse { const Gentoo::PortagePrx prx0; const Gentoo::UsersPrx prx1; const ::Ice::Int _pi_username; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_application_atom_xml; }; diff --git a/gentoobrowse/src/search.cpp b/gentoobrowse/src/search.cpp index c435df1..64234ca 100644 --- a/gentoobrowse/src/search.cpp +++ b/gentoobrowse/src/search.cpp @@ -26,9 +26,10 @@ namespace GentooBrowse { public: sitemap(const IceSpider::Core * core) : IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/sitemap.xml"), - prx0(core->getProxy<Gentoo::Portage>()) + prx0(core->getProxy<Gentoo::Portage>()), + _serializer_text_html("xslt/sitemap.xslt") { - addRouteSerializer({ "application", "xml" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/sitemap.xslt")); + addRouteSerializer({ "application", "xml" }, &_serializer_text_html); } ~sitemap() @@ -58,6 +59,7 @@ namespace GentooBrowse { private: const Gentoo::PortagePrx prx0; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; }; } // namespace GentooBrowse diff --git a/gentoobrowse/src/user.cpp b/gentoobrowse/src/user.cpp index 1bd5b88..27d49d4 100644 --- a/gentoobrowse/src/user.cpp +++ b/gentoobrowse/src/user.cpp @@ -47,9 +47,10 @@ namespace GentooBrowse { class signup : public IceSpider::IRouteHandler { public: signup(const IceSpider::Core *) : - IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/user/signup") + IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/user/signup"), + _serializer_text_html("xslt/user-signup.xslt") { - addRouteSerializer({ "text", "html" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/user-signup.xslt")); + addRouteSerializer({ "text", "html" }, &_serializer_text_html); } void execute(IceSpider::IHttpRequest * request) const @@ -57,6 +58,9 @@ namespace GentooBrowse { PageBasePtr p = new PageBase(); request->response(this, p); } + + private: + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; }; // Route name: signup post @@ -85,9 +89,10 @@ namespace GentooBrowse { class verification : public IceSpider::IRouteHandler { public: verification(const IceSpider::Core *) : - IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/user/verification") + IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/user/verification"), + _serializer_text_html("xslt/user-verification.xslt") { - addRouteSerializer({ "text", "html" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/user-verification.xslt")); + addRouteSerializer({ "text", "html" }, &_serializer_text_html); } void execute(IceSpider::IHttpRequest * request) const @@ -95,6 +100,9 @@ namespace GentooBrowse { PageBasePtr p = new PageBase(); request->response(this, p); } + + private: + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; }; // Route name: verification post @@ -141,9 +149,10 @@ namespace GentooBrowse { IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/user/home"), common(core), prx0(core->getProxy<IceSpider::SessionManager>()), - prx1(core->getProxy<Gentoo::Users>()) + prx1(core->getProxy<Gentoo::Users>()), + _serializer_text_html("xslt/user-home.xslt") { - addRouteSerializer({ "text", "html" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/user-home.xslt")); + addRouteSerializer({ "text", "html" }, &_serializer_text_html ); } ~home() @@ -161,6 +170,7 @@ namespace GentooBrowse { private: const IceSpider::SessionManagerPrx prx0; const Gentoo::UsersPrx prx1; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; }; // Route name: tracked @@ -173,9 +183,10 @@ namespace GentooBrowse { common(core), prx0(core->getProxy<IceSpider::SessionManager>()), prx1(core->getProxy<Gentoo::Users>()), - prx2(core->getProxy<Gentoo::Portage>()) + prx2(core->getProxy<Gentoo::Portage>()), + _serializer_text_html("xslt/user-tracked.xslt") { - addRouteSerializer({ "text", "html" }, new IceSpider::XsltStreamSerializer::IceSpiderFactory("xslt/user-tracked.xslt")); + addRouteSerializer({ "text", "html" }, &_serializer_text_html); } ~tracked() @@ -198,6 +209,7 @@ namespace GentooBrowse { const IceSpider::SessionManagerPrx prx0; const Gentoo::UsersPrx prx1; const Gentoo::PortagePrx prx2; + IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html; }; // Route name: logout |