diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-12 20:20:14 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-12 20:20:14 +0100 |
commit | 9c7362153945275bb8f592e59319fcde7dbcb703 (patch) | |
tree | 1d2d8f5b05c789b584c557a18cb1038bb273837d | |
parent | Whitespace only lines between package masks (diff) | |
download | gentoobrowse-api-9c7362153945275bb8f592e59319fcde7dbcb703.tar.bz2 gentoobrowse-api-9c7362153945275bb8f592e59319fcde7dbcb703.tar.xz gentoobrowse-api-9c7362153945275bb8f592e59319fcde7dbcb703.zip |
C++17 and Ice 3.7
Updates all code to work with C++17 and Ice 3.7 and related updates in
used libraries.
34 files changed, 188 insertions, 190 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 23e2bf7..d3bb409 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -7,12 +7,14 @@ variant coverage : debug ; project : requirements - <variant>release:<cxxflags>"-std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -flto=2" - <variant>release:<linkflags>"-Wl,-z,defs,--warn-once,--gc-sections -flto=2" - <variant>debug:<cxxflags>"-W -Wall -Wextra -Werror -Wwrite-strings -std=c++1y -fvisibility=hidden" - <variant>debug:<linkflags>"-Wl,-z,defs,--warn-once" - <variant>coverage:<cxxflags>"-W -Wall -Werror -Wwrite-strings -std=c++1y --coverage -fvisibility=hidden" - <variant>coverage:<linkflags>"-Wl,-z,defs,--warn-once --coverage" + <define>ICE_CPP11_MAPPING + <cxxflags>"-std=c++17 -fvisibility=hidden -fvisibility-inlines-hidden" + <linkflags>"-Wl,-z,defs,--warn-once,--gc-sections" + <variant>release:<cxxflags>"-flto=2" + <variant>release:<linkflags>"-flto=2" + <variant>debug:<cxxflags>"-W -Wall -Wextra -Werror -Wwrite-strings" + <variant>coverage:<cxxflags>"--coverage" + <variant>coverage:<linkflags>"--coverage" ; build-project gentoobrowse-api ; diff --git a/gentoobrowse-api/Jamfile.jam b/gentoobrowse-api/Jamfile.jam index 5c407b2..2a35394 100644 --- a/gentoobrowse-api/Jamfile.jam +++ b/gentoobrowse-api/Jamfile.jam @@ -4,10 +4,9 @@ import package ; lib adhocutil : : : : <include>/usr/include/adhocutil ; lib slicer : : : : <include>/usr/include/slicer ; lib slicer-db : : : : <include>/usr/include/slicer ; -lib Ice ; -lib IceUtil ; +lib Ice : : <name>Ice++11 ; lib pthread ; -lib IceBox ; +lib IceBox : : <name>IceBox++11 ; lib boost_filesystem ; lib boost_system ; lib boost_thread ; diff --git a/gentoobrowse-api/client/helpers.h b/gentoobrowse-api/client/helpers.h index 859be3f..76f8148 100644 --- a/gentoobrowse-api/client/helpers.h +++ b/gentoobrowse-api/client/helpers.h @@ -7,21 +7,20 @@ template<typename Key, typename Target, typename Collection, typename Proxy> std::map<Key, Target> -asyncMapRelated(const Collection & collection, Proxy p, +asyncMapRelated(const Collection & collection, const Proxy & p, Key Collection::value_type::element_type::* member, - Ice::AsyncResultPtr (Proxy::element_type::*b)(Key), - Target (Proxy::element_type::*e)(const Ice::AsyncResultPtr &)) + std::future<Target> (Proxy::element_type::*b)(Key, const ::Ice::Context &)) { std::map<Key, Target> rtn; - std::map<Key, Ice::AsyncResultPtr> jobs; + std::map<Key, std::future<Target>> jobs; for (const auto & item : collection) { Key v = item.get()->*member; if (jobs.find(v) == jobs.end()) { - jobs.insert({ v, (p.get()->*b)(v) }); + jobs.insert({ v, (p.get()->*b)(v, Ice::noExplicitContext) }); } } - for (const auto & j : jobs) { - rtn.insert({ j.first, (p.get()->*e)(j.second) }); + for (auto & j : jobs) { + rtn.insert({ j.first, j.second.get() }); } return rtn; } diff --git a/gentoobrowse-api/client/main.cpp b/gentoobrowse-api/client/main.cpp index d2f70bb..d542188 100644 --- a/gentoobrowse-api/client/main.cpp +++ b/gentoobrowse-api/client/main.cpp @@ -33,7 +33,7 @@ main(int c, char ** v) } auto ic = Ice::initialize(c, v); - auto p = Gentoo::PortagePrx::checkedCast(ic->stringToProxy("portage:" + endpoint)); + auto p = Ice::checkedCast<Gentoo::PortagePrx>(ic->stringToProxy("portage:" + endpoint)); p->ice_ping(); AdHoc::PluginManager::getDefault()->get<Module>(module)->implementation()->run(p, args); diff --git a/gentoobrowse-api/client/main.h b/gentoobrowse-api/client/main.h index 9c7c9f7..1f88081 100644 --- a/gentoobrowse-api/client/main.h +++ b/gentoobrowse-api/client/main.h @@ -8,7 +8,7 @@ class Module : public AdHoc::AbstractPluginImplementation { public: - virtual void run(Gentoo::PortagePrx, const std::vector<std::string> &) const = 0; + virtual void run(const Gentoo::PortagePrxPtr &, const std::vector<std::string> &) const = 0; }; #endif diff --git a/gentoobrowse-api/client/search.cpp b/gentoobrowse-api/client/search.cpp index 29d16e2..448643b 100644 --- a/gentoobrowse-api/client/search.cpp +++ b/gentoobrowse-api/client/search.cpp @@ -6,12 +6,11 @@ class search : public Module { public: - void run(Gentoo::PortagePrx p, const std::vector<std::string> & a) const override + void run(const Gentoo::PortagePrxPtr & p, const std::vector<std::string> & a) const override { auto pkgs = p->getPackagesSearch(boost::algorithm::join(a, " ")); auto cats = asyncMapRelated(pkgs, p, &Gentoo::Package::categoryid, - &IceProxy::Gentoo::Portage::begin_getCategory, - &IceProxy::Gentoo::Portage::end_getCategory); + (std::future<Gentoo::CategoryPtr> (Gentoo::PortagePrx::*)(Ice::Int, const ::Ice::Context &))&Gentoo::PortagePrx::getCategoryAsync); fprintbf(stdout, "Found %d packages:\n", pkgs.size()); for (const auto & pkg : pkgs) { fprintbf(stdout, "%s / %s\n\t%s\n", cats[pkg->categoryid]->name, pkg->name, pkg->description); diff --git a/gentoobrowse-api/domain/Jamfile.jam b/gentoobrowse-api/domain/Jamfile.jam index 3fc393b..92718b9 100644 --- a/gentoobrowse-api/domain/Jamfile.jam +++ b/gentoobrowse-api/domain/Jamfile.jam @@ -5,7 +5,6 @@ lib gentoobrowse-domain : : <slicer>yes <library>..//Ice - <library>..//IceUtil <library>..//pthread <library>..//slicer <library>..//adhocutil @@ -13,7 +12,6 @@ lib gentoobrowse-domain : <include>. : : <library>..//Ice - <library>..//IceUtil <library>..//pthread <library>..//slicer <library>..//adhocutil diff --git a/gentoobrowse-api/service/depend.cpp b/gentoobrowse-api/service/depend.cpp index 86f9646..11244d9 100644 --- a/gentoobrowse-api/service/depend.cpp +++ b/gentoobrowse-api/service/depend.cpp @@ -20,15 +20,15 @@ const std::string InOr("InOr"); namespace Portage { namespace Utils { - template<typename T, typename Y> IceUtil::Optional<T> iuo(const boost::optional<Y> & x) + template<typename T, typename Y> Ice::optional<T> iuo(const std::optional<Y> & x) { if (x) { - return *x; + return Ice::optional<T>(*x); } - return IceUtil::Optional<T>(); + return Ice::optional<T>(); } - template<typename T, typename Y> std::vector<T> split(const boost::optional<Y> & x) + template<typename T, typename Y> std::vector<T> split(const std::optional<Y> & x) { std::vector<T> rtn; if (x) { @@ -51,20 +51,20 @@ namespace Portage { when.pop_back(); } }, // || ( - { { InitialState, InWhen, InOr }, Or_Begin, [this](auto es) { + { { InitialState, InWhen, InOr }, Or_Begin, [](auto es) { es->pushState(InOr); } }, // ( - { { InitialState, InWhen, InOr }, Or_Group, [this](auto es) { + { { InitialState, InWhen, InOr }, Or_Group, [](auto es) { es->pushState(InOr); } }, // ) - { { InOr }, Or_End, [this](auto es) { + { { InOr }, Or_End, [](auto es) { es->popState(); } }, // [op]some-cat/package[-version][:slot][uses] { { InitialState, InWhen, InOr }, AtomSpec, [this](auto es) { - ds.push_back(new Gentoo::Dependency( + ds.push_back(std::make_shared<Gentoo::Dependency>( when, iuo<std::string>(es->pattern()->match(1)), // op *es->pattern()->match(2), // category diff --git a/gentoobrowse-api/service/mailserverimpl.cpp b/gentoobrowse-api/service/mailserverimpl.cpp index ccc7180..8965c47 100644 --- a/gentoobrowse-api/service/mailserverimpl.cpp +++ b/gentoobrowse-api/service/mailserverimpl.cpp @@ -9,7 +9,7 @@ namespace Gentoo { typedef std::pair<Parts::iterator, Parts::const_iterator> PartsProgress; void - MailServer::sendEmail(const Gentoo::EmailPtr & msg, const Ice::Current & c) + MailServer::sendEmail(Gentoo::EmailPtr msg, const Ice::Current & c) { auto props = c.adapter->getCommunicator()->getProperties(); smtp_session_t session = smtp_create_session(); diff --git a/gentoobrowse-api/service/mailserverimpl.h b/gentoobrowse-api/service/mailserverimpl.h index 23b17c2..d44d601 100644 --- a/gentoobrowse-api/service/mailserverimpl.h +++ b/gentoobrowse-api/service/mailserverimpl.h @@ -8,7 +8,7 @@ namespace Gentoo { namespace Service { class DLL_PUBLIC MailServer : public Gentoo::MailServer { public: - void sendEmail(const Gentoo::EmailPtr & msg, const Ice::Current &) override; + void sendEmail(Gentoo::EmailPtr msg, const Ice::Current &) override; private: static const char * writeBody(void ** buf, int * len, void * arg); diff --git a/gentoobrowse-api/service/main.cpp b/gentoobrowse-api/service/main.cpp index 3221e4c..e14c2a0 100644 --- a/gentoobrowse-api/service/main.cpp +++ b/gentoobrowse-api/service/main.cpp @@ -1,4 +1,4 @@ -#include <Ice/Communicator.h> +#include <Ice/Initialize.h> #include <Ice/ObjectAdapter.h> #include <icetrayService.h> #include "portageimpl.h" @@ -32,11 +32,11 @@ class Api : public IceTray::Service { void addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adp) override { auto db = getConnectionPool(ic, "postgresql", "GentooBrowseAPI"); - adp->add(new Portage(db), ic->stringToIdentity("portage")); - adp->add(new Maintenance(db, ic, ic->getProperties()), ic->stringToIdentity("maintenance")); - adp->add(new Users(db), ic->stringToIdentity("users")); - adp->add(new Notifications(), ic->stringToIdentity("notifications")); - adp->add(new MailServer(), ic->stringToIdentity("mailserver")); + adp->add(std::make_shared<Portage>(db), Ice::stringToIdentity("portage")); + adp->add(std::make_shared<Maintenance>(db, ic, ic->getProperties()), Ice::stringToIdentity("maintenance")); + adp->add(std::make_shared<Users>(db), Ice::stringToIdentity("users")); + adp->add(std::make_shared<Notifications>(), Ice::stringToIdentity("notifications")); + adp->add(std::make_shared<MailServer>(), Ice::stringToIdentity("mailserver")); } }; diff --git a/gentoobrowse-api/service/maintenance/abstractFileProcessor.h b/gentoobrowse-api/service/maintenance/abstractFileProcessor.h index 4b9db3b..91e66ce 100644 --- a/gentoobrowse-api/service/maintenance/abstractFileProcessor.h +++ b/gentoobrowse-api/service/maintenance/abstractFileProcessor.h @@ -28,7 +28,7 @@ namespace Gentoo { virtual void modified(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn, const boost::filesystem::path & path) = 0; virtual void deleted(DB::Connection * dbc, int64_t repoid, const Gentoo::StringList & fn) = 0; }; - typedef boost::shared_ptr<AbstractFileProcessor> FileProcessorPtr; + typedef std::shared_ptr<AbstractFileProcessor> FileProcessorPtr; typedef AdHoc::Factory<AbstractFileProcessor> FileProcessorFactory; } } diff --git a/gentoobrowse-api/service/maintenanceBugs.cpp b/gentoobrowse-api/service/maintenanceBugs.cpp index 28c2f20..0b8e51a 100644 --- a/gentoobrowse-api/service/maintenanceBugs.cpp +++ b/gentoobrowse-api/service/maintenanceBugs.cpp @@ -79,7 +79,7 @@ namespace Gentoo { UpdatingBugs::write(std::cerr, root); auto dbc = db->get(); - DB::TransactionScope tx(dbc.get()); + DB::TransactionScope tx(*dbc.get()); DB::TablePatch tp; tp.pk = { "bugId" }; tp.cols = { "bugId", "severity", "status", "summary" }; diff --git a/gentoobrowse-api/service/maintenanceCommon.cpp b/gentoobrowse-api/service/maintenanceCommon.cpp index ab8317f..3fa81a1 100644 --- a/gentoobrowse-api/service/maintenanceCommon.cpp +++ b/gentoobrowse-api/service/maintenanceCommon.cpp @@ -17,8 +17,9 @@ namespace Gentoo { protected: template<typename Proxy> - Proxy getProxy(const std::string & n) const { - auto p = Proxy::checkedCast(ic->stringToProxy(n)); + auto + getProxy(const std::string & n) const { + auto p = Ice::checkedCast<Proxy>(ic->stringToProxy(n)); p->ice_ping(); return p; } @@ -33,11 +34,11 @@ namespace Gentoo { void runTimerTask() override { auto m = getProxy<MaintenancePrx>("maintenance"); - auto rb = m->begin_refreshBugs(); + auto rb = m->refreshBugsAsync(); m->updateRepositories(); m->refreshPackageTree(); m->sendNotifications(); - m->end_refreshBugs(rb); + rb.get(); } }; @@ -51,14 +52,14 @@ namespace Gentoo { } }; - Maintenance::Maintenance(IceTray::DatabasePoolPtr d, Ice::CommunicatorPtr ic, Ice::PropertiesPtr p) : + Maintenance::Maintenance(const DB::ConnectionPoolPtr & d, const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p) : Maintenance::Maintenance(d) { addTask<AutoUpdatePackages>(ic, p, "SyncTime"); addTask<UserMaintenance>(ic, p, "UserMaintenanceTime"); } - Maintenance::Maintenance(IceTray::DatabasePoolPtr d) : + Maintenance::Maintenance(const DB::ConnectionPoolPtr & d) : IceTray::AbstractDatabaseClient(d) { } @@ -78,7 +79,7 @@ namespace Gentoo { if (!taskRunner) { taskRunner = new IceUtil::Timer(); } - taskRunner->scheduleRepeated(new Task(ic), IceUtil::Time::seconds(sync)); + taskRunner->scheduleRepeated(std::make_shared<Task>(ic), IceUtil::Time::seconds(sync)); } } @@ -91,7 +92,7 @@ namespace Gentoo { Gentoo::UserNews Maintenance::getUserNews(const Ice::Current & current) { - auto portage = PortagePrx::checkedCast(current.adapter->getCommunicator()->stringToProxy("portage")); + auto portage = Ice::checkedCast<PortagePrx>(current.adapter->getCommunicator()->stringToProxy("portage")); portage->ice_ping(); auto categories = portage->getAllCategories(); @@ -103,10 +104,10 @@ namespace Gentoo { return AdHoc::containerContains(t.categoryids, c->categoryid); }); for (auto pid : t.packageids) { - auto par = portage->begin_getPackage(pid); - auto vsar = portage->begin_getPackageVersions(pid); - nc.packages.push_back(portage->end_getPackage(par)); - auto vs = portage->end_getPackageVersions(vsar); + auto par = portage->getPackageAsync(pid); + auto vsar = portage->getPackageVersionsAsync(pid); + nc.packages.push_back(par.get()); + auto vs = vsar.get(); std::copy_if(vs.begin(), vs.end(), std::back_inserter(nc.ebuilds), [&t](const Gentoo::EbuildPtr & v) { return AdHoc::containerContains(t.ebuildids, v->ebuildid); }); @@ -119,11 +120,11 @@ namespace Gentoo { void Maintenance::sendNotifications(const Ice::Current & current) { - auto notifications = NotificationsPrx::checkedCast(current.adapter->getCommunicator()->stringToProxy("notifications")); + auto notifications = Ice::checkedCast<NotificationsPrx>(current.adapter->getCommunicator()->stringToProxy("notifications")); notifications->ice_ping(); - auto mailServer = MailServerPrx::checkedCast(current.adapter->getCommunicator()->stringToProxy("mailserver")); + auto mailServer = Ice::checkedCast<MailServerPrx>(current.adapter->getCommunicator()->stringToProxy("mailserver")); mailServer->ice_ping(); - auto users = UsersPrx::checkedCast(current.adapter->getCommunicator()->stringToProxy("users")); + auto users = Ice::checkedCast<UsersPrx>(current.adapter->getCommunicator()->stringToProxy("users")); users->ice_ping(); for (const auto & trigger : getUserNews(current)) { diff --git a/gentoobrowse-api/service/maintenanceGitOperations.cpp b/gentoobrowse-api/service/maintenanceGitOperations.cpp index fd2df39..c68abd1 100644 --- a/gentoobrowse-api/service/maintenanceGitOperations.cpp +++ b/gentoobrowse-api/service/maintenanceGitOperations.cpp @@ -178,7 +178,7 @@ namespace Gentoo { auto properties = c.adapter->getCommunicator()->getProperties(); auto repoRoot = boost::filesystem::path(properties->getPropertyWithDefault("GentooBrowseAPI.RepoRoot", "/")); auto dbc = db->get(); - DB::TransactionScope tx(dbc.get()); + DB::TransactionScope tx(*dbc.get()); for (auto & repo : fetch<Gentoo::Repositories>(dbc.get(), sql::maintenance::reposToGitRefresh)) { auto changes = refreshRepository(dbc.get(), properties, repo); this->applyFileChanges(dbc.get(), repoRoot, repo, changes); diff --git a/gentoobrowse-api/service/maintenanceimpl.h b/gentoobrowse-api/service/maintenanceimpl.h index d28b1e6..bb76106 100644 --- a/gentoobrowse-api/service/maintenanceimpl.h +++ b/gentoobrowse-api/service/maintenanceimpl.h @@ -16,7 +16,7 @@ namespace Gentoo { namespace Service { class DLL_PUBLIC Maintenance : public Gentoo::Maintenance, public IceTray::AbstractDatabaseClient { public: - Maintenance(IceTray::DatabasePoolPtr d, Ice::CommunicatorPtr ic, Ice::PropertiesPtr p); + Maintenance(const DB::ConnectionPoolPtr & d, const Ice::CommunicatorPtr & ic, const Ice::PropertiesPtr & p); virtual ~Maintenance(); void refreshPackageTree(const Ice::Current &) override; @@ -26,7 +26,7 @@ namespace Gentoo { void sendNotifications(const Ice::Current &) override; protected: - Maintenance(IceTray::DatabasePoolPtr d); + Maintenance(const DB::ConnectionPoolPtr & d); void applyFileChanges(DB::Connection *, const boost::filesystem::path &, const Repository &, ChangeSet &) const; private: diff --git a/gentoobrowse-api/service/mask.h b/gentoobrowse-api/service/mask.h index f37b152..a739fe5 100644 --- a/gentoobrowse-api/service/mask.h +++ b/gentoobrowse-api/service/mask.h @@ -4,7 +4,7 @@ #include <lexer.h> #include <list> #include <glibmm/ustring.h> -#include <boost/optional.hpp> +#include <optional> namespace Portage { namespace Utils { @@ -15,7 +15,7 @@ namespace Portage { virtual void consume() const = 0; Glib::ustring date; - boost::optional<Glib::ustring> person, email; + std::optional<Glib::ustring> person, email; std::set<std::string> atoms; std::list<std::string> message; int n; diff --git a/gentoobrowse-api/service/news.cpp b/gentoobrowse-api/service/news.cpp index 34b811a..be4d53e 100644 --- a/gentoobrowse-api/service/news.cpp +++ b/gentoobrowse-api/service/news.cpp @@ -15,15 +15,15 @@ const std::string Body("Body"); namespace Portage { namespace Utils { - template<typename T, typename Y> IceUtil::Optional<T> iuo(const boost::optional<Y> & x) + template<typename T, typename Y> Ice::optional<T> iuo(const std::optional<Y> & x) { if (x) { - return *x; + return Ice::optional<T>(*x); } - return IceUtil::Optional<T>(); + return Ice::optional<T>(); } - template<typename T, typename Y> std::vector<T> split(const boost::optional<Y> & x) + template<typename T, typename Y> std::vector<T> split(const std::optional<Y> & x) { std::vector<T> rtn; if (x) { @@ -49,11 +49,11 @@ namespace Portage { } }, // author: name <email> { { InitialState }, Author, [this](auto es) { - news->authorname = *es->pattern()->match(1); - news->authoremail = *es->pattern()->match(2); + news->authorname = es->pattern()->match(1)->raw(); + news->authoremail = es->pattern()->match(2)->raw(); } }, // other headers - { { InitialState }, IgnoredHeader, [this](auto) { + { { InitialState }, IgnoredHeader, [](auto) { } }, // blank { { InitialState }, BlankLine, [this](auto es) { @@ -76,7 +76,7 @@ namespace Portage { news->body.back().append(*es->pattern()->match(1)); } } }), - news(new Gentoo::NewsItem()) + news(std::make_shared<Gentoo::NewsItem>()) { } diff --git a/gentoobrowse-api/service/notificationsimpl.cpp b/gentoobrowse-api/service/notificationsimpl.cpp index 270e264..64756bf 100644 --- a/gentoobrowse-api/service/notificationsimpl.cpp +++ b/gentoobrowse-api/service/notificationsimpl.cpp @@ -30,14 +30,14 @@ namespace Gentoo { xsltSetLoaderFunc(NULL); } - Gentoo::EmailPtr Notifications::getSignup(const Gentoo::NewUserPtr & u, const Ice::Current &) + Gentoo::EmailPtr Notifications::getSignup(Gentoo::NewUserPtr u, const Ice::Current &) { auto e = basicMail("Welcome", u); Slicer::SerializeAny<XsltStreamSerializer>(u, e, signup.get()); return e; } - Gentoo::EmailPtr Notifications::getNews(const Gentoo::UserPtr & u, const Gentoo::NewsContent & c, const Ice::Current &) + Gentoo::EmailPtr Notifications::getNews(Gentoo::UserPtr u, Gentoo::NewsContent c, const Ice::Current &) { auto e = basicMail("Latest updates", u); Slicer::SerializeAny<XsltStreamSerializer>(c, e, news.get()); @@ -46,7 +46,7 @@ namespace Gentoo { Gentoo::EmailPtr Notifications::basicMail(const std::string & subject, Gentoo::UserPtr u) { - Gentoo::EmailPtr e = new Gentoo::Email(); + Gentoo::EmailPtr e = std::make_shared<Gentoo::Email>(); e->subject = "Gentoo Browse: " + subject; e->from.name = "Gentoo Browse"; e->from.address = "noreply@gentoobrowse.randomdan.homeip.net"; diff --git a/gentoobrowse-api/service/notificationsimpl.h b/gentoobrowse-api/service/notificationsimpl.h index 1d3b1fc..762aa4a 100644 --- a/gentoobrowse-api/service/notificationsimpl.h +++ b/gentoobrowse-api/service/notificationsimpl.h @@ -12,8 +12,8 @@ namespace Gentoo { public: Notifications(); - Gentoo::EmailPtr getSignup(const Gentoo::NewUserPtr &, const Ice::Current &) override; - Gentoo::EmailPtr getNews(const Gentoo::UserPtr &, const Gentoo::NewsContent &, const Ice::Current &) override; + Gentoo::EmailPtr getSignup(Gentoo::NewUserPtr, const Ice::Current &) override; + Gentoo::EmailPtr getNews(Gentoo::UserPtr, Gentoo::NewsContent, const Ice::Current &) override; private: Gentoo::EmailPtr basicMail(const std::string &, Gentoo::UserPtr u); diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp index 1885952..f779649 100644 --- a/gentoobrowse-api/service/portageimpl.cpp +++ b/gentoobrowse-api/service/portageimpl.cpp @@ -44,7 +44,7 @@ namespace Gentoo { namespace Service { -Portage::Portage(boost::shared_ptr<AdHoc::ResourcePool<DB::Connection>> d) : +Portage::Portage(const DB::ConnectionPoolPtr & d) : IceTray::AbstractCachingDatabaseClient(d) { } @@ -56,7 +56,7 @@ Portage::getCategory(Ice::Int id, const Ice::Current &) } Gentoo::CategoryPtr -Portage::findCategory(const std::string & name, const Ice::Current &) +Portage::findCategory(const std::string name, const Ice::Current &) { return fetchCache<Gentoo::CategoryPtr>(sql::portage::findCategory, 30, name); } @@ -68,7 +68,7 @@ Portage::getAllCategories(const Ice::Current &) } Gentoo::Categories -Portage::getCategoriesInSuper(const std::string & super, const Ice::Current &) +Portage::getCategoriesInSuper(const std::string super, const Ice::Current &) { return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesInSuper, 30, super); } @@ -86,7 +86,7 @@ Portage::getAllOverviewCategories(const Ice::Current &) } Gentoo::OverviewCategories -Portage::getOverviewCategoriesInSuper(const std::string & super, const Ice::Current &) +Portage::getOverviewCategoriesInSuper(const std::string super, const Ice::Current &) { return fetchCache<Gentoo::OverviewCategories>(sql::portage::getOverviewCategoriesInSuper, 30, super); } @@ -98,7 +98,7 @@ Portage::getPackage(Ice::Int id, const Ice::Current &) } Gentoo::PackagePtr -Portage::findPackage(const std::string & cat, const std::string & pkg, const Ice::Current &) +Portage::findPackage(const std::string cat, const std::string pkg, const Ice::Current &) { return fetchCache<Gentoo::PackagePtr>(sql::portage::findPackage, 30, cat, pkg); } @@ -116,7 +116,7 @@ Portage::getPackagesInCategory(Ice::Int id, const Ice::Current &) } Gentoo::SearchResultPackages -Portage::getPackagesSearch(const std::string & query, const Ice::Current &) +Portage::getPackagesSearch(const std::string query, const Ice::Current &) { return fetchCache<Gentoo::SearchResultPackages>(sql::portage::getPackagesSearch, 30, query, query); } @@ -176,7 +176,7 @@ Portage::getPackageUrls(Ice::Int id, const Ice::Current &) } Gentoo::Ebuilds -Portage::getEbuildsByFilter(const std::string & filter, const Ice::Current &) +Portage::getEbuildsByFilter(const std::string filter, const Ice::Current &) { return fetchCache<Gentoo::Ebuilds>(sql::portage::getEbuildsByFilter, 30, filter); } @@ -218,7 +218,7 @@ Portage::getPackageUses(Ice::Int id, const Ice::Current &) } Gentoo::UsePtr -Portage::getUse(const std::string & use, const Ice::Current &) +Portage::getUse(const std::string use, const Ice::Current &) { return fetchCache<Gentoo::UsePtr>(sql::portage::getUse, 30, use, use); } @@ -230,7 +230,7 @@ Portage::getGlobalUses(const Ice::Current &) } Gentoo::Uses -Portage::getGroupUses(const std::string & group, const Ice::Current &) +Portage::getGroupUses(const std::string group, const Ice::Current &) { return fetchCache<Gentoo::Uses>(sql::portage::getGroupUses, 30, group); } @@ -242,19 +242,19 @@ Portage::getUseGroups(const Ice::Current &) } Gentoo::Uses -Portage::getUseUsage(const std::string & use, const Ice::Current &) +Portage::getUseUsage(const std::string use, const Ice::Current &) { return fetchCache<Gentoo::Uses>(sql::portage::getUseUsage, 30, use, use, use, use); } Gentoo::Packages -Portage::getUsePackages(const std::string & use, const Ice::Current &) +Portage::getUsePackages(const std::string use, const Ice::Current &) { return fetchCache<Gentoo::Packages>(sql::portage::getUsePackages, 30, use, use); } Gentoo::Uses -Portage::getUsesSearch(const std::string & query, const Ice::Current &) +Portage::getUsesSearch(const std::string query, const Ice::Current &) { return fetchCache<Gentoo::Uses>(sql::portage::getUsesSearch, 30, query); } @@ -272,19 +272,19 @@ Portage::getPackageBugs(Ice::Int packageId, const Ice::Current &) } Gentoo::SearchResultBugs -Portage::getBugsSearch(const std::string & query, const Ice::Current &) +Portage::getBugsSearch(const std::string query, const Ice::Current &) { return fetchCache<Gentoo::SearchResultBugs>(sql::portage::getBugsSearch, 30, query, query); } Gentoo::NewsItemPtr -Portage::getNewsItem(const std::string & id, const Ice::Current &) +Portage::getNewsItem(const std::string id, const Ice::Current &) { return fetchCache<Gentoo::NewsItemPtr>(sql::portage::getNewsItem, 30, id); } Gentoo::News -Portage::getNewsSearch(const std::string & query, const Ice::Current &) +Portage::getNewsSearch(const std::string query, const Ice::Current &) { return fetchCache<Gentoo::News>(sql::portage::getNewsSearch, 30, query); } diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h index 42459c2..06721e8 100644 --- a/gentoobrowse-api/service/portageimpl.h +++ b/gentoobrowse-api/service/portageimpl.h @@ -9,20 +9,20 @@ namespace Gentoo { namespace Service { class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatabaseClient { public: - Portage(boost::shared_ptr<AdHoc::ResourcePool<DB::Connection>> d); + Portage(const DB::ConnectionPoolPtr & d); Gentoo::CategoryPtr getCategory(Ice::Int id, const Ice::Current &) override; - Gentoo::CategoryPtr findCategory(const std::string & name, const Ice::Current &) override; + Gentoo::CategoryPtr findCategory(const std::string name, const Ice::Current &) override; Gentoo::Categories getAllCategories(const Ice::Current &) override; - Gentoo::Categories getCategoriesInSuper(const std::string &, const Ice::Current &) override; + Gentoo::Categories getCategoriesInSuper(const std::string, const Ice::Current &) override; Gentoo::OverviewCategoriesBySuper getAllOverviewCategories(const Ice::Current &) override; - Gentoo::OverviewCategories getOverviewCategoriesInSuper(const std::string &, const Ice::Current &) override; + Gentoo::OverviewCategories getOverviewCategoriesInSuper(const std::string, const Ice::Current &) override; Gentoo::PackagePtr getPackage(Ice::Int id, const Ice::Current &) override; - Gentoo::PackagePtr findPackage(const std::string &, const std::string &, const Ice::Current &) override; + Gentoo::PackagePtr findPackage(const std::string, const std::string, const Ice::Current &) override; Gentoo::Packages getPackagesInCategory(Ice::Int id, const Ice::Current &) override; Gentoo::Packages getAllPackages(const Ice::Current &) override; - Gentoo::SearchResultPackages getPackagesSearch(const std::string & query, const Ice::Current &) override; + Gentoo::SearchResultPackages getPackagesSearch(const std::string query, const Ice::Current &) override; Gentoo::Ebuilds getPackageVersions(Ice::Int id, const Ice::Current &) override; Gentoo::EbuildDetails getPackageVersionDetails(Ice::Int id, const Ice::Current &) override; Gentoo::ChangeLog getPackageChangeLog(Ice::Int id, const Ice::Current &) override; @@ -38,22 +38,22 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab Gentoo::Packages getUserTrackedPackages(Ice::Int userid, const Ice::Current &) override; Gentoo::Ebuilds getUserTrackedRecentVersions(Ice::Int userid, Ice::Int limit, const Ice::Current &) override; Gentoo::StringList getPackageUrls(Ice::Int id, const Ice::Current &) override; - Gentoo::Ebuilds getEbuildsByFilter(const std::string &, const Ice::Current &) override; + Gentoo::Ebuilds getEbuildsByFilter(const std::string, const Ice::Current &) override; - Gentoo::UsePtr getUse(const std::string &, const Ice::Current &) override; + Gentoo::UsePtr getUse(const std::string, const Ice::Current &) override; Gentoo::Uses getGlobalUses(const Ice::Current &) override; - Gentoo::Uses getGroupUses(const std::string &, const Ice::Current &) override; + Gentoo::Uses getGroupUses(const std::string, const Ice::Current &) override; Gentoo::StringList getUseGroups(const Ice::Current &) override; - Gentoo::Uses getUseUsage(const std::string &, const Ice::Current &) override; - Gentoo::Packages getUsePackages(const std::string &, const Ice::Current &) override; - Gentoo::Uses getUsesSearch(const std::string &, const Ice::Current &) override; + Gentoo::Uses getUseUsage(const std::string, const Ice::Current &) override; + Gentoo::Packages getUsePackages(const std::string, const Ice::Current &) override; + Gentoo::Uses getUsesSearch(const std::string, const Ice::Current &) override; Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override; Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override; - Gentoo::SearchResultBugs getBugsSearch(const std::string & query, const Ice::Current &) override; + Gentoo::SearchResultBugs getBugsSearch(const std::string query, const Ice::Current &) override; - Gentoo::NewsItemPtr getNewsItem(const std::string &, const Ice::Current &) override; - Gentoo::News getNewsSearch(const std::string &, const Ice::Current &) override; + Gentoo::NewsItemPtr getNewsItem(const std::string, const Ice::Current &) override; + Gentoo::News getNewsSearch(const std::string, const Ice::Current &) override; Gentoo::News getNewsRecent(Ice::Int, const Ice::Current &) override; Gentoo::Repository getRepository(Ice::Int, const Ice::Current &) override; diff --git a/gentoobrowse-api/service/usersimpl.cpp b/gentoobrowse-api/service/usersimpl.cpp index 13b5112..446d61c 100644 --- a/gentoobrowse-api/service/usersimpl.cpp +++ b/gentoobrowse-api/service/usersimpl.cpp @@ -18,19 +18,19 @@ namespace Gentoo { namespace Service { -Users::Users(boost::shared_ptr<AdHoc::ResourcePool<DB::Connection>> d) : +Users::Users(const DB::ConnectionPoolPtr & d) : IceTray::AbstractCachingDatabaseClient(d) { } Gentoo::UserPtr -Users::authenticate(const std::string & username, const std::string & password, const Ice::Current &) +Users::authenticate(const std::string username, const std::string password, const Ice::Current &) { return fetchCache<Gentoo::UserPtr>(sql::users::authenticate, 30, username, password); } Gentoo::UserPtr -Users::verify(const std::string & username, const std::string & verifyguid, const Ice::Current &) +Users::verify(const std::string username, const std::string verifyguid, const Ice::Current &) { return fetch<Gentoo::UserPtr>(sql::users::verify, username, verifyguid); } @@ -42,13 +42,13 @@ Users::get(Ice::Int id, const Ice::Current &) } Gentoo::NewUserPtr -Users::getNew(const std::string & username, const std::string & password, const Ice::Current &) +Users::getNew(const std::string username, const std::string password, const Ice::Current &) { return fetch<Gentoo::NewUserPtr>(sql::users::getNew, username, password); } Gentoo::UserPtr -Users::find(const std::string & username, const Ice::Current &) +Users::find(const std::string username, const Ice::Current &) { return fetch<Gentoo::UserPtr>(sql::users::find, username); } @@ -64,17 +64,17 @@ Users::authOrCreate(const std::string & username, const std::string & password, } Gentoo::NewUserPtr -Users::create(const std::string & username, const std::string & password, const std::string & realname, const std::string & email, const Ice::Current & current) +Users::create(const std::string username, const std::string password, const std::string realname, const std::string email, const Ice::Current & current) { - auto notifications = NotificationsPrx::checkedCast(current.adapter->getCommunicator()->stringToProxy("notifications")); + auto notifications = Ice::checkedCast<NotificationsPrx>(current.adapter->getCommunicator()->stringToProxy("notifications")); BOOST_ASSERT(notifications); BOOST_ASSERT((notifications->ice_ping(), true)); - auto mailServer = MailServerPrx::checkedCast(current.adapter->getCommunicator()->stringToProxy("mailserver")); + auto mailServer = Ice::checkedCast<MailServerPrx>(current.adapter->getCommunicator()->stringToProxy("mailserver")); BOOST_ASSERT(mailServer); BOOST_ASSERT((mailServer->ice_ping(), true)); auto dbc = db->get(); - DB::TransactionScope tx(dbc.get()); + DB::TransactionScope tx(*dbc.get()); auto newUser = authOrCreate(username, password, realname, email); auto mail = notifications->getSignup(newUser); @@ -93,7 +93,7 @@ Users::mailshotsent(Ice::Int id, const Ice::Current &) } void -Users::remove(Ice::Int id, const std::string & password, const Ice::Current &) +Users::remove(Ice::Int id, const std::string password, const Ice::Current &) { auto dbc = db->get(); auto del = sql::users::safeDelete.modify(dbc.get()); diff --git a/gentoobrowse-api/service/usersimpl.h b/gentoobrowse-api/service/usersimpl.h index 57e0d79..5baec3b 100644 --- a/gentoobrowse-api/service/usersimpl.h +++ b/gentoobrowse-api/service/usersimpl.h @@ -9,17 +9,17 @@ namespace Gentoo { namespace Service { class DLL_PUBLIC Users : public Gentoo::Users, IceTray::AbstractCachingDatabaseClient { public: - Users(boost::shared_ptr<AdHoc::ResourcePool<DB::Connection>> d); + Users(const DB::ConnectionPoolPtr & d); - Gentoo::UserPtr authenticate(const std::string &, const std::string &, const Ice::Current &) override; - Gentoo::UserPtr verify(const std::string &, const std::string &, const Ice::Current &) override; + Gentoo::UserPtr authenticate(const std::string, const std::string, const Ice::Current &) override; + Gentoo::UserPtr verify(const std::string, const std::string, const Ice::Current &) override; Gentoo::UserPtr get(Ice::Int id, const Ice::Current &) override; - Gentoo::NewUserPtr getNew(const std::string &, const std::string &, const Ice::Current &) override; - Gentoo::UserPtr find(const std::string & username, const Ice::Current &) override; - Gentoo::NewUserPtr create(const std::string &, const std::string &, const std::string &, const std::string &, const Ice::Current &) override; + Gentoo::NewUserPtr getNew(const std::string, const std::string, const Ice::Current &) override; + Gentoo::UserPtr find(const std::string username, const Ice::Current &) override; + Gentoo::NewUserPtr create(const std::string, const std::string, const std::string, const std::string, const Ice::Current &) override; void mailshotsent(Ice::Int id, const Ice::Current &) override; - void remove(Ice::Int id, const std::string &, const Ice::Current &) override; + void remove(Ice::Int id, const std::string, const Ice::Current &) override; void prune(const Ice::Current &) override; void track(Ice::Int, Ice::Int, const Ice::Current &) override; diff --git a/gentoobrowse-api/service/xsltStreamSerializer.cpp b/gentoobrowse-api/service/xsltStreamSerializer.cpp index 5a71b35..ff73c2e 100644 --- a/gentoobrowse-api/service/xsltStreamSerializer.cpp +++ b/gentoobrowse-api/service/xsltStreamSerializer.cpp @@ -49,7 +49,7 @@ namespace Gentoo { xmlOutputBufferPtr buf = xmlOutputBufferCreateIO(xmlstrmwritecallback, xmlstrmclosecallback, &strm, NULL); htmlDocContentDumpFormatOutput(buf, result, "utf-8", 0); xmlOutputBufferClose(buf); - mail->body.push_back(new Gentoo::MimePart("text/html", strm.str())); + mail->body.push_back(std::make_shared<Gentoo::MimePart>("text/html", strm.str())); } void XsltStreamSerializer::appendText(xmlDoc * result) const @@ -76,7 +76,7 @@ namespace Gentoo { if (status != 0) { throw std::runtime_error("Lynx failed"); } - mail->body.push_back(new Gentoo::MimePart("text/plain", strm.str())); + mail->body.push_back(std::make_shared<Gentoo::MimePart>("text/plain", strm.str())); } } diff --git a/gentoobrowse-api/unittests/Jamfile.jam b/gentoobrowse-api/unittests/Jamfile.jam index ead573a..575d54a 100644 --- a/gentoobrowse-api/unittests/Jamfile.jam +++ b/gentoobrowse-api/unittests/Jamfile.jam @@ -26,7 +26,6 @@ lib testCommon : <library>..//boost_system <library>..//boost_filesystem <library>..//Ice - <library>..//IceUtil <library>..//IceBox <library>dryice <library>../service//gentoobrowse-service @@ -40,7 +39,6 @@ lib testCommon : <library>dryice <library>../service//gentoobrowse-service <implicit-dependency>../service//gentoobrowse-service - <library>..//IceUtil <library>..//Ice <library>..//boost_system <library>..//boost_filesystem diff --git a/gentoobrowse-api/unittests/mockDefs.cpp b/gentoobrowse-api/unittests/mockDefs.cpp index a865c39..c06b81a 100644 --- a/gentoobrowse-api/unittests/mockDefs.cpp +++ b/gentoobrowse-api/unittests/mockDefs.cpp @@ -3,7 +3,7 @@ #include <notifications.h> void -MockMailServerImpl::sendEmail(const Gentoo::EmailPtr & e, const Ice::Current &) +MockMailServerImpl::sendEmail(const Gentoo::EmailPtr e, const Ice::Current &) { sentEmails.push_back(e); } @@ -15,11 +15,11 @@ MockMailServerImpl::getSentEmails(const Ice::Current &) } Service::Service() : - PQ::Mock("user=postgres dbname=postgres", "GentooBrowseAPI", { + DB::PluginMock<PQ::Mock>("user=postgres dbname=postgres", "GentooBrowseAPI", { rootDir.parent_path() / "db" / "schema.sql", rootDir / "data.sql" }) { - replace("mailserver", new MockMailServerImpl()); + replace("mailserver", std::make_shared<MockMailServerImpl>()); } Maintenance::Maintenance() : @@ -28,10 +28,10 @@ Maintenance::Maintenance() : "--GentooBrowseAPI.RepoRoot=" + (rootDir / "fixtures" / "gitrepo").string(), "--GentooBrowseAPI.BugRoot=file://" + (rootDir / "fixtures" / "bugs").string() }), - PQ::Mock("user=postgres dbname=postgres", "GentooBrowseAPI", { + DB::PluginMock<PQ::Mock>("user=postgres dbname=postgres", "GentooBrowseAPI", { rootDir.parent_path() / "db" / "schema.sql" }) { - replace("mailserver", new MockMailServerImpl()); + replace("mailserver", std::make_shared<MockMailServerImpl>()); } Mail::Mail() : diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h index d69d3e1..7ea3535 100644 --- a/gentoobrowse-api/unittests/mockDefs.h +++ b/gentoobrowse-api/unittests/mockDefs.h @@ -14,19 +14,19 @@ class MockMailServerImpl : public Gentoo::MockMailServer { public: - void sendEmail(const Gentoo::EmailPtr & msg, const Ice::Current &) override; + void sendEmail(const Gentoo::EmailPtr msg, const Ice::Current &) override; Gentoo::Emails getSentEmails(const Ice::Current &) override; private: Gentoo::Emails sentEmails; }; -class DLL_PUBLIC Service : public IceTray::DryIce, PQ::Mock { +class DLL_PUBLIC Service : public IceTray::DryIce, DB::PluginMock<PQ::Mock> { public: Service(); }; -class DLL_PUBLIC Maintenance : public IceTray::DryIce, PQ::Mock { +class DLL_PUBLIC Maintenance : public IceTray::DryIce, DB::PluginMock<PQ::Mock> { public: Maintenance(); }; @@ -40,11 +40,11 @@ class DLL_PUBLIC TestClient : public IceTray::DryIceClient { public: TestClient(); - Gentoo::MaintenancePrx m; - Gentoo::PortagePrx p; - Gentoo::NotificationsPrx n; - Gentoo::MailServerPrx ms; - Gentoo::UsersPrx u; + Gentoo::MaintenancePrxPtr m; + Gentoo::PortagePrxPtr p; + Gentoo::NotificationsPrxPtr n; + Gentoo::MailServerPrxPtr ms; + Gentoo::UsersPrxPtr u; }; #define SQL_REQUIRE_EQUAL(sql, type, expected) BOOST_TEST_CONTEXT(sql) { sqlRequireEqual<type>(db, sql, expected); } diff --git a/gentoobrowse-api/unittests/testDepend.cpp b/gentoobrowse-api/unittests/testDepend.cpp index 942dbaf..e7c232d 100644 --- a/gentoobrowse-api/unittests/testDepend.cpp +++ b/gentoobrowse-api/unittests/testDepend.cpp @@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE( versionSlot ) BOOST_REQUIRE(ds[0]->version); BOOST_REQUIRE_EQUAL(*ds[0]->version, "2.0.0"); BOOST_REQUIRE(ds[0]->slot); - BOOST_REQUIRE_EQUAL(ds[0]->slot, "foo"); + BOOST_REQUIRE_EQUAL(*ds[0]->slot, "foo"); BOOST_REQUIRE(ds[0]->use.empty()); } @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE( slot ) auto ds = Portage::Utils::Depend::parse(" >x11-libs/Gtk+:foo"); BOOST_REQUIRE(!ds[0]->version); BOOST_REQUIRE(ds[0]->slot); - BOOST_REQUIRE_EQUAL(ds[0]->slot, "foo"); + BOOST_REQUIRE_EQUAL(*ds[0]->slot, "foo"); BOOST_REQUIRE(ds[0]->use.empty()); } @@ -204,7 +204,7 @@ BOOST_AUTO_TEST_CASE( versionSlotSubSlot ) BOOST_REQUIRE(ds[0]->version); BOOST_REQUIRE_EQUAL(*ds[0]->version, "2.0.0"); BOOST_REQUIRE(ds[0]->slot); - BOOST_REQUIRE_EQUAL(ds[0]->slot, "foo/bar"); + BOOST_REQUIRE_EQUAL(*ds[0]->slot, "foo/bar"); BOOST_REQUIRE(ds[0]->use.empty()); } @@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE( slotUse ) auto ds = Portage::Utils::Depend::parse(" >x11-libs/Gtk+:foo[bar,baz]"); BOOST_REQUIRE(!ds[0]->version); BOOST_REQUIRE(ds[0]->slot); - BOOST_REQUIRE_EQUAL(ds[0]->slot, "foo"); + BOOST_REQUIRE_EQUAL(*ds[0]->slot, "foo"); BOOST_REQUIRE_EQUAL(ds[0]->use.size(), 2); BOOST_REQUIRE_EQUAL(ds[0]->use[0], "bar"); BOOST_REQUIRE_EQUAL(ds[0]->use[1], "baz"); diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp index b2f88cc..a23444a 100644 --- a/gentoobrowse-api/unittests/testMaintenance.cpp +++ b/gentoobrowse-api/unittests/testMaintenance.cpp @@ -9,6 +9,7 @@ #include <fstream> #include <maintenanceimpl.h> #include <portageimpl.h> +#include <mockPool.h> class MaintenanceClientCombined : public Maintenance, public TestClient { }; @@ -70,7 +71,7 @@ class M2 : public Gentoo::Service::Maintenance { public: typedef std::map<boost::filesystem::path, size_t> FileMap; - M2(IceTray::DatabasePoolPtr d) : + M2(const DB::ConnectionPoolPtr & d) : Gentoo::Service::Maintenance(d) { } @@ -80,7 +81,7 @@ class M2 : public Gentoo::Service::Maintenance { auto dbc = db->get(); auto fromFiles = fileSet(from); auto toFiles = fileSet(to); - DB::TransactionScope tx(dbc.get()); + DB::TransactionScope tx(*dbc.get()); Gentoo::Service::ChangeSet changes; newFiles(changes, fromFiles, toFiles); removedFiles(changes, fromFiles, toFiles); @@ -139,15 +140,6 @@ class M2 : public Gentoo::Service::Maintenance { } }; -class MockPool : public IceTray::DatabasePool { - public: - MockPool() : IceTray::DatabasePool(10, 2) {} - DB::Connection * createResource() const override - { - return DB::MockDatabase::openConnectionTo("GentooBrowseAPI"); - } -}; - #define BOOST_TEST_CONTEXT_VAR(VAR, EXPR) \ BOOST_TEST_CONTEXT(#EXPR) \ for (auto VAR = EXPR, * __context__run = &VAR; __context__run; __context__run = NULL) @@ -165,7 +157,7 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree ) boost::filesystem::remove_all(binDir / "empty"); boost::filesystem::create_directory(binDir / "empty"); - auto p = IceTray::DatabasePoolPtr(new MockPool()); + auto p = std::make_shared<IceTray::MockPool>("GentooBrowseAPI", 1, 1); M2 m2(p); BOOST_TEST_CONTEXT("4156eb45cf3b0ce1d7125b84efd8688c2d6e831d") { @@ -173,7 +165,7 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree ) doRefreshPackageTree(db, 5, 1, 482, 981, 3626, 4593, 501, 393, 238, 50, 1573, 2008, 1543, 81, 152, 7); - Gentoo::PortagePtr portage = new Gentoo::Service::Portage(p); + Gentoo::PortagePtr portage = std::make_shared<Gentoo::Service::Portage>(p); BOOST_TEST_CONTEXT_VAR(acjtr, portage->findPackage("app-crypt", "johntheripper", Ice::Current())) { BOOST_TEST_CONTEXT_VAR(acjtrUses, portage->getPackageUses(acjtr->packageid, Ice::Current())) { BOOST_REQUIRE_EQUAL(9, acjtrUses.size()); diff --git a/gentoobrowse-api/unittests/testMasks.cpp b/gentoobrowse-api/unittests/testMasks.cpp index e80fe1c..ac29b97 100644 --- a/gentoobrowse-api/unittests/testMasks.cpp +++ b/gentoobrowse-api/unittests/testMasks.cpp @@ -13,12 +13,12 @@ class MaskTester : public Portage::Utils::Masks { void consume() const override { if (email && person) { - masks.push_back(new Gentoo::Mask(n, *person, *email, date, + masks.push_back(std::make_shared<Gentoo::Mask>(n, person->raw(), email->raw(), date, boost::algorithm::join(message, " "), Gentoo::StringList(atoms.begin(), atoms.end()))); } } - + public: mutable Gentoo::Masks masks; }; diff --git a/gentoobrowse-api/unittests/testNotifications.cpp b/gentoobrowse-api/unittests/testNotifications.cpp index 9d8c806..700b3a6 100644 --- a/gentoobrowse-api/unittests/testNotifications.cpp +++ b/gentoobrowse-api/unittests/testNotifications.cpp @@ -6,6 +6,8 @@ #include <fstream> #include <tidy.h> +using namespace std::string_literals; + BOOST_GLOBAL_FIXTURE( Mail ); BOOST_FIXTURE_TEST_SUITE(tp, TestClient); @@ -48,7 +50,7 @@ commonAssert(Gentoo::EmailPtr e) BOOST_AUTO_TEST_CASE( testSend ) { - Gentoo::NewUserPtr u = new Gentoo::NewUser(1, "testuser", "Test User", "noone@randomdan.homeip.net", "2017-10-01T12:34:56", IceUtil::None, "some-guid"); + Gentoo::NewUserPtr u = std::make_shared<Gentoo::NewUser>(1, "testuser", "Test User", "noone@randomdan.homeip.net", "2017-10-01T12:34:56", IceUtil::None, "some-guid"); auto e = n->getSignup(u); BOOST_REQUIRE(e); ms->sendEmail(e); @@ -56,7 +58,7 @@ BOOST_AUTO_TEST_CASE( testSend ) BOOST_AUTO_TEST_CASE( testSignup ) { - Gentoo::NewUserPtr u = new Gentoo::NewUser(1, "testuser", "Test User", "test@user.com", "2017-10-01T12:34:56", IceUtil::None, "some-guid"); + Gentoo::NewUserPtr u = std::make_shared<Gentoo::NewUser>(1, "testuser", "Test User", "test@user.com", "2017-10-01T12:34:56", IceUtil::None, "some-guid"); auto e = n->getSignup(u); BOOST_REQUIRE(e); BOOST_REQUIRE_EQUAL(e->subject, "Gentoo Browse: Welcome"); @@ -75,27 +77,27 @@ BOOST_AUTO_TEST_CASE( testSignup ) BOOST_AUTO_TEST_CASE( testNews ) { - Gentoo::UserPtr u = new Gentoo::User(1, "testuser", "Test User", "test@user.com", "2017-10-01T12:34:56", IceUtil::None); + Gentoo::UserPtr u = std::make_shared<Gentoo::User>(1, "testuser", "Test User", "test@user.com", "2017-10-01T12:34:56", IceUtil::None); Gentoo::NewsContent nc { { - new Gentoo::Category(1, "app-test", "Test cat1"), - new Gentoo::Category(2, "sys-test", "Test cat2"), - new Gentoo::Category(3, "no-show", "Unused cat") + std::make_shared<Gentoo::Category>(1, "app-test", "Test cat1"s), + std::make_shared<Gentoo::Category>(2, "sys-test", "Test cat2"s), + std::make_shared<Gentoo::Category>(3, "no-show", "Unused cat"s) }, { - new Gentoo::Package(1, 1, "app1", "first-seen", "Test app desc one", "Test summary 1", IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None), - new Gentoo::Package(2, 1, "app2", "first-seen", "Test app desc two", "Test summary 1", IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None), - new Gentoo::Package(3, 2, "app3", "first-seen", "Test app desc three", "Test summary 1", IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None), - new Gentoo::Package(4, 2, "app4", "first-seen", "Test app no-show", "Test summary 1", IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None) + std::make_shared<Gentoo::Package>(1, 1, "app1", "first-seen", "Test app desc one", "Test summary 1"s, IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None), + std::make_shared<Gentoo::Package>(2, 1, "app2", "first-seen", "Test app desc two", "Test summary 1"s, IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None), + std::make_shared<Gentoo::Package>(3, 2, "app3", "first-seen", "Test app desc three", "Test summary 1"s, IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None), + std::make_shared<Gentoo::Package>(4, 2, "app4", "first-seen", "Test app no-show", "Test summary 1"s, IceUtil::None, IceUtil::None, IceUtil::None, IceUtil::None) }, { - new Gentoo::Ebuild(1, 1, 1, "1.0a", "slot", "first-seen", "last-mod", IceUtil::None), - new Gentoo::Ebuild(2, 1, 1, "1.1a", "slot", "first-seen", "last-mod", IceUtil::None), - new Gentoo::Ebuild(3, 1, 1, "1.2a", "slot", "first-seen", "last-mod", IceUtil::None), - new Gentoo::Ebuild(4, 2, 1, "2.0a", "slot", "first-seen", "last-mod", IceUtil::None), - new Gentoo::Ebuild(5, 3, 1, "3.0a", "slot", "first-seen", "last-mod", IceUtil::None), - new Gentoo::Ebuild(6, 2, 1, "2.1a", "slot", "first-seen", "last-mod", IceUtil::None), - new Gentoo::Ebuild(7, 3, 1, "3.1a", "slot", "first-seen", "last-mod", IceUtil::None) + std::make_shared<Gentoo::Ebuild>(1, 1, 1, "1.0a", "slot", "first-seen", "last-mod", IceUtil::None), + std::make_shared<Gentoo::Ebuild>(2, 1, 1, "1.1a", "slot", "first-seen", "last-mod", IceUtil::None), + std::make_shared<Gentoo::Ebuild>(3, 1, 1, "1.2a", "slot", "first-seen", "last-mod", IceUtil::None), + std::make_shared<Gentoo::Ebuild>(4, 2, 1, "2.0a", "slot", "first-seen", "last-mod", IceUtil::None), + std::make_shared<Gentoo::Ebuild>(5, 3, 1, "3.0a", "slot", "first-seen", "last-mod", IceUtil::None), + std::make_shared<Gentoo::Ebuild>(6, 2, 1, "2.1a", "slot", "first-seen", "last-mod", IceUtil::None), + std::make_shared<Gentoo::Ebuild>(7, 3, 1, "3.1a", "slot", "first-seen", "last-mod", IceUtil::None) } }; auto e = n->getNews(u, nc); diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp index 81d7320..18b8114 100644 --- a/gentoobrowse-api/unittests/testPortage.cpp +++ b/gentoobrowse-api/unittests/testPortage.cpp @@ -5,6 +5,17 @@ BOOST_GLOBAL_FIXTURE( Service ); +namespace std { + template<typename T> + ostream & + operator<<(ostream & s, const Ice::optional<T> & o) + { + if (o) s << *o; + else s << "-empty optional-"; + return s; + } +} + BOOST_FIXTURE_TEST_SUITE(tp, TestClient) BOOST_AUTO_TEST_CASE( getCategoryMissing ) @@ -111,8 +122,8 @@ BOOST_AUTO_TEST_CASE( getPackage ) BOOST_REQUIRE_EQUAL("2010-05-04T00:54:45.661860", pkg->firstseen); BOOST_REQUIRE_EQUAL("A GUI for GNU Arch", pkg->description); BOOST_REQUIRE(!pkg->summary); - BOOST_REQUIRE_EQUAL("maintainer-needed@gentoo.org", pkg->maintainer); - BOOST_REQUIRE_EQUAL("Default assignee for orphaned packages", pkg->maintainername); + BOOST_REQUIRE_EQUAL("maintainer-needed@gentoo.org", *pkg->maintainer); + BOOST_REQUIRE_EQUAL("Default assignee for orphaned packages", *pkg->maintainername); } BOOST_AUTO_TEST_CASE( findPackageMissing ) @@ -190,7 +201,7 @@ BOOST_AUTO_TEST_CASE( getPackageVersions ) BOOST_REQUIRE_EQUAL("0", es.front()->slot); BOOST_REQUIRE_EQUAL("2015-08-10T18:11:55.489505", es.front()->firstseen); BOOST_REQUIRE_EQUAL("2015-12-01T15:10:49", es.front()->moddate); - BOOST_REQUIRE_EQUAL("GPL-3", es.front()->license); + BOOST_REQUIRE_EQUAL("GPL-3", *es.front()->license); BOOST_REQUIRE_EQUAL(629067, es.back()->ebuildid); } @@ -234,7 +245,7 @@ BOOST_AUTO_TEST_CASE( getPackageVersionDetails ) BOOST_REQUIRE_EQUAL("0", es.front()->slot); BOOST_REQUIRE_EQUAL("2015-08-10T18:11:55.489505", es.front()->firstseen); BOOST_REQUIRE_EQUAL("2015-12-01T15:10:49", es.front()->moddate); - BOOST_REQUIRE_EQUAL("GPL-3", es.front()->license); + BOOST_REQUIRE_EQUAL("GPL-3", *es.front()->license); BOOST_REQUIRE_EQUAL(629067, es.back()->ebuildid); BOOST_REQUIRE_EQUAL(21, es.front()->uses.size()); BOOST_REQUIRE_EQUAL(3, es.front()->archs.size()); @@ -269,7 +280,7 @@ BOOST_AUTO_TEST_CASE( getRecentAdditions ) BOOST_REQUIRE_EQUAL("0", es.front()->slot); BOOST_REQUIRE_EQUAL("2015-12-02T19:12:42.627493", es.front()->firstseen); BOOST_REQUIRE_EQUAL("2015-12-03T17:21:25", es.front()->moddate); - BOOST_REQUIRE_EQUAL("GPL-2", es.front()->license); + BOOST_REQUIRE_EQUAL("GPL-2", *es.front()->license); } BOOST_AUTO_TEST_CASE( getPackageDependencies ) @@ -331,8 +342,8 @@ BOOST_AUTO_TEST_CASE( getPackageMasks ) auto ms = p->getPackageMasks(55923); BOOST_REQUIRE_EQUAL(1, ms.size()); BOOST_REQUIRE_EQUAL(3, ms.front()->setno); - BOOST_REQUIRE_EQUAL("robbat2@gentoo.org", ms.front()->email); - BOOST_REQUIRE_EQUAL("Robin H. Johnson", ms.front()->person); + BOOST_REQUIRE_EQUAL("robbat2@gentoo.org", *ms.front()->email); + BOOST_REQUIRE_EQUAL("Robin H. Johnson", *ms.front()->person); BOOST_REQUIRE_EQUAL("2006-02-11", ms.front()->dateadded); BOOST_REQUIRE_EQUAL("zlib interaction is badly broken. See bug #124733.", ms.front()->message); BOOST_REQUIRE_EQUAL(1, ms.front()->atomspec.size()); diff --git a/gentoobrowse-api/util/update.cpp b/gentoobrowse-api/util/update.cpp index f14df6e..4c4b1dd 100644 --- a/gentoobrowse-api/util/update.cpp +++ b/gentoobrowse-api/util/update.cpp @@ -30,22 +30,19 @@ main(int c, char ** v) } auto ic = Ice::initialize(c, v); - auto m = Gentoo::MaintenancePrx::checkedCast(ic->stringToProxy("maintenance:" + endpoint)); + auto m = Ice::checkedCast<Gentoo::MaintenancePrx>(ic->stringToProxy("maintenance:" + endpoint)); m->ice_ping(); - std::set<Ice::AsyncResultPtr> jobs; - if (bugs) jobs.insert(m->begin_refreshBugs()); + std::vector<std::future<void>> jobs; + if (bugs) jobs.push_back(m->refreshBugsAsync()); if (pull) m->updateRepositories(); - if (tree) jobs.insert(m->begin_refreshPackageTree()); - - std::for_each(jobs.begin(), jobs.end(), [](const auto & j) { j->waitForSent(); }); + if (tree) jobs.push_back(m->refreshPackageTreeAsync()); int failures = 0; if (!background) { - std::for_each(jobs.begin(), jobs.end(), [&failures](const auto & j) { + std::for_each(jobs.begin(), jobs.end(), [&failures](auto & f) { try { - j->waitForCompleted(); - j->throwLocalException(); + f.get(); } catch (const std::exception & ex) { failures += 1; |