[vcpkg] Add Util::ResourceBase, use MoveOnlyBase
MODIFY
include/vcpkg_Dependencies.h
include/vcpkg_Dependencies.h
@@ -70,16 +70,12 @@ namespace vcpkg::Dependencies
REMOVE
};
- struct RemovePlanAction
+ struct RemovePlanAction : Util::MoveOnlyBase
{
static bool compare_by_name(const RemovePlanAction* left, const RemovePlanAction* right);
RemovePlanAction();
RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type);
- RemovePlanAction(const RemovePlanAction&) = delete;
- RemovePlanAction(RemovePlanAction&&) = default;
- RemovePlanAction& operator=(const RemovePlanAction&) = delete;
- RemovePlanAction& operator=(RemovePlanAction&&) = default;
PackageSpec spec;
RemovePlanType plan_type;
@@ -102,16 +98,12 @@ namespace vcpkg::Dependencies
ALREADY_BUILT
};
- struct ExportPlanAction
+ struct ExportPlanAction : Util::MoveOnlyBase
{
static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right);
ExportPlanAction();
ExportPlanAction(const PackageSpec& spec, const AnyParagraph& any_paragraph, const RequestType& request_type);
- ExportPlanAction(const ExportPlanAction&) = delete;
- ExportPlanAction(ExportPlanAction&&) = default;
- ExportPlanAction& operator=(const ExportPlanAction&) = delete;
- ExportPlanAction& operator=(ExportPlanAction&&) = default;
PackageSpec spec;
AnyParagraph any_paragraph;
@@ -121,23 +113,19 @@ namespace vcpkg::Dependencies
__interface PortFileProvider { virtual const SourceControlFile& get_control_file(const std::string& spec) const; };
- struct MapPortFile : PortFileProvider
+ struct MapPortFile : Util::ResourceBase, PortFileProvider
{
const std::unordered_map<std::string, SourceControlFile>& ports;
explicit MapPortFile(const std::unordered_map<std::string, SourceControlFile>& map);
const SourceControlFile& get_control_file(const std::string& spec) const override;
};
- struct PathsPortFile : PortFileProvider
+ struct PathsPortFile : Util::ResourceBase, PortFileProvider
{
const VcpkgPaths& ports;
mutable std::unordered_map<std::string, SourceControlFile> cache;
explicit PathsPortFile(const VcpkgPaths& paths);
const SourceControlFile& get_control_file(const std::string& spec) const override;
-
- private:
- PathsPortFile(const PathsPortFile&) = delete;
- PathsPortFile& operator=(const PathsPortFile&) = delete;
};
std::vector<InstallPlanAction> create_install_plan(const PortFileProvider& port_file_provider,

MODIFY
include/vcpkg_Util.h
include/vcpkg_Util.h
@@ -72,4 +72,14 @@ namespace vcpkg::Util
MoveOnlyBase& operator=(const MoveOnlyBase&) = delete;
MoveOnlyBase& operator=(MoveOnlyBase&&) = default;
};
+
+ struct ResourceBase
+ {
+ ResourceBase() = default;
+ ResourceBase(const ResourceBase&) = delete;
+ ResourceBase(ResourceBase&&) = delete;
+
+ ResourceBase& operator=(const ResourceBase&) = delete;
+ ResourceBase& operator=(ResourceBase&&) = delete;
+ };
}
\ No newline at end of file

MODIFY
src/test_install_plan.cpp
src/test_install_plan.cpp
@@ -151,7 +151,7 @@ namespace UnitTest1
auto spec_b = spec_map.emplace("b", "c");
auto spec_c = spec_map.emplace("c");
- auto map_port = Dependencies::MapPortFile(spec_map.map);
+ Dependencies::MapPortFile map_port(spec_map.map);
auto install_plan =
Dependencies::create_install_plan(map_port, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
@@ -175,7 +175,7 @@ namespace UnitTest1
auto spec_g = spec_map.emplace("g");
auto spec_h = spec_map.emplace("h");
- auto map_port = Dependencies::MapPortFile(spec_map.map);
+ Dependencies::MapPortFile map_port(spec_map.map);
auto install_plan = Dependencies::create_install_plan(
map_port, {spec_a, spec_b, spec_c}, StatusParagraphs(std::move(status_paragraphs)));
@@ -268,7 +268,7 @@ namespace UnitTest1
auto spec_j = spec_map.emplace("j", "k");
auto spec_k = spec_map.emplace("k");
- auto map_port = Dependencies::MapPortFile(spec_map.map);
+ Dependencies::MapPortFile map_port(spec_map.map);
auto install_plan =
Dependencies::create_install_plan(map_port, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));

MODIFY
src/vcpkg_Dependencies.cpp
src/vcpkg_Dependencies.cpp
@@ -19,7 +19,7 @@ namespace vcpkg::Dependencies
bool plus = false;
};
- struct Cluster
+ struct Cluster : Util::MoveOnlyBase
{
std::vector<StatusParagraph*> status_paragraphs;
Optional<const SourceControlFile*> source_control_file;
@@ -30,11 +30,6 @@ namespace vcpkg::Dependencies
bool will_remove = false;
bool transient_uninstalled = true;
RequestType request_type = RequestType::AUTO_SELECTED;
- Cluster() = default;
-
- private:
- Cluster(const Cluster&) = delete;
- Cluster& operator=(const Cluster&) = delete;
};
struct ClusterPtr
@@ -64,13 +59,12 @@ namespace vcpkg::Dependencies
Graphs::Graph<ClusterPtr> install_graph;
};
- struct ClusterGraph
+ struct ClusterGraph : Util::MoveOnlyBase
{
explicit ClusterGraph(std::unordered_map<std::string, const SourceControlFile*>&& ports)
: m_ports(std::move(ports))
{
}
- ClusterGraph(ClusterGraph&&) = default;
Cluster& get(const PackageSpec& spec)
{
@@ -108,7 +102,6 @@ namespace vcpkg::Dependencies
out_cluster.source_control_file = &scf;
}
- ClusterGraph(const ClusterGraph&) = delete;
std::unordered_map<PackageSpec, Cluster> m_graph;
std::unordered_map<std::string, const SourceControlFile*> m_ports;
};

[vcpkg] Add Util::ResourceBase, use MoveOnlyBase