* limitations under the License.
*/
+#include <memory>
+
#include "logging.hh"
#include "pkg_upgrader_factory.hh"
#include "ro2rw_upgrader.hh"
// UPDATE
if (old_pkg->IsReadOnly() && new_pkg.IsReadOnly()) {
// RO to RO
- pkgs.emplace_back(new RoUpgrader(
- unique_ptr<PkgUpgrader>(new SimpleUpgrader(*old_pkg,
- PkgOperation::COMPLEX)),
- unique_ptr<PkgUpgrader>(new SimpleUpgrader(new_pkg,
- PkgOperation::UPDATE)))
- );
+ pkgs.emplace_back(std::make_unique<RoUpgrader>(
+ std::make_unique<SimpleUpgrader>(*old_pkg, PkgOperation::COMPLEX),
+ std::make_unique<SimpleUpgrader>(new_pkg, PkgOperation::UPDATE)));
} else if (!old_pkg->IsReadOnly() && !new_pkg.IsReadOnly()) {
// RW to RW
- pkgs.emplace_back(new RwUpgrader(
- unique_ptr<PkgUpgrader>(new SimpleUpgrader(*old_pkg,
- PkgOperation::COMPLEX)),
- unique_ptr<PkgUpgrader>(new SimpleUpgrader(new_pkg,
- PkgOperation::UPDATE))));
+ pkgs.emplace_back(std::make_unique<RwUpgrader>(
+ std::make_unique<SimpleUpgrader>(*old_pkg, PkgOperation::COMPLEX),
+ std::make_unique<SimpleUpgrader>(new_pkg, PkgOperation::UPDATE)));
} else if (!old_pkg->IsReadOnly() && new_pkg.IsReadOnly()) {
// RW to RO
- pkgs.emplace_back(new Rw2RoUpgrader(
- unique_ptr<RwUpgrader>(new RwUpgrader(
- nullptr,
- std::unique_ptr<PkgUpgrader>(new SimpleUpgrader(*old_pkg,
- PkgOperation::UNINSTALL_KEEP_RW_DATA))
- )
- ),
- unique_ptr<RoUpgrader>(new RoUpgrader(
- nullptr,
- std::unique_ptr<PkgUpgrader>(new SimpleUpgrader(new_pkg,
- PkgOperation::INSTALL))
- )
- ))
- );
+ pkgs.emplace_back(std::make_unique<Rw2RoUpgrader>(
+ std::make_unique<RwUpgrader>(nullptr,
+ std::make_unique<SimpleUpgrader>(*old_pkg,
+ PkgOperation::UNINSTALL_KEEP_RW_DATA)),
+ std::make_unique<RoUpgrader>(nullptr,
+ std::make_unique<SimpleUpgrader>(new_pkg,
+ PkgOperation::INSTALL))));
} else if (old_pkg->IsReadOnly() && !new_pkg.IsReadOnly()) {
// RO to RW
- pkgs.emplace_back(new Ro2RwUpgrader(
- unique_ptr<RoUpgrader>(new RoUpgrader(
- nullptr,
- std::unique_ptr<PkgUpgrader>(new SimpleUpgrader(*old_pkg,
- PkgOperation::UNINSTALL_KEEP_RW_DATA))
- )
- ),
- unique_ptr<RwUpgrader>(new RwUpgrader(
- nullptr,
- std::unique_ptr<PkgUpgrader>(new SimpleUpgrader(new_pkg,
- PkgOperation::INSTALL))
- )
- ))
- );
+ pkgs.emplace_back(std::make_unique<Ro2RwUpgrader>(
+ std::make_unique<RoUpgrader>(nullptr,
+ std::make_unique<SimpleUpgrader>(*old_pkg,
+ PkgOperation::UNINSTALL_KEEP_RW_DATA)),
+ std::make_unique<RwUpgrader>(nullptr,
+ std::make_unique<SimpleUpgrader>(new_pkg,
+ PkgOperation::INSTALL))));
}
} else {
// INSTALL
if (new_pkg.IsReadOnly()) {
// RO
- pkgs.emplace_back(new SimpleUpgrader(new_pkg, PkgOperation::INSTALL));
+ pkgs.emplace_back(std::make_unique<SimpleUpgrader>(
+ new_pkg, PkgOperation::INSTALL));
} else {
// RW
- pkgs.emplace_back(new RwUpgrader(nullptr,
- unique_ptr<PkgUpgrader>(new SimpleUpgrader(new_pkg,
- PkgOperation::INSTALL))));
+ pkgs.emplace_back(std::make_unique<RwUpgrader>(nullptr,
+ std::make_unique<SimpleUpgrader>(new_pkg, PkgOperation::INSTALL)));
}
}
}
if (new_pkg == nullptr) {
// UNINSTALL
if (old_pkg.IsReadOnly()) {
- pkgs.emplace_back(new SimpleUpgrader(old_pkg,
+ pkgs.emplace_back(std::make_unique<SimpleUpgrader>(old_pkg,
PkgOperation::UNINSTALL));
}
}