aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-08-22 15:14:15 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-08-22 15:14:15 -0700
commit92dd1b77ed043da376c86874aacc1233270fedae (patch)
tree70177d807fcbfd4614b82b66f11d30f8d4c4731d
parentbee29497f9e210c2b8d33edccba0d1d95188d852 (diff)
downloadvcpkg-92dd1b77ed043da376c86874aacc1233270fedae.tar.gz
vcpkg-92dd1b77ed043da376c86874aacc1233270fedae.zip
[vcpkg] Add Util::ResourceBase, use MoveOnlyBase
-rw-r--r--toolsrc/include/vcpkg_Dependencies.h20
-rw-r--r--toolsrc/include/vcpkg_Util.h10
-rw-r--r--toolsrc/src/test_install_plan.cpp6
-rw-r--r--toolsrc/src/vcpkg_Dependencies.cpp11
4 files changed, 19 insertions, 28 deletions
diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h
index bfb452596..93719efe9 100644
--- a/toolsrc/include/vcpkg_Dependencies.h
+++ b/toolsrc/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,
diff --git a/toolsrc/include/vcpkg_Util.h b/toolsrc/include/vcpkg_Util.h
index da2f8eb69..4f45cd2c7 100644
--- a/toolsrc/include/vcpkg_Util.h
+++ b/toolsrc/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
diff --git a/toolsrc/src/test_install_plan.cpp b/toolsrc/src/test_install_plan.cpp
index 836ff09ae..6c9311264 100644
--- a/toolsrc/src/test_install_plan.cpp
+++ b/toolsrc/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)));
diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp
index 512e65e28..188b0f444 100644
--- a/toolsrc/src/vcpkg_Dependencies.cpp
+++ b/toolsrc/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;
};