Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[projmgr] List layers: fix removal of subset configurations #1640

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4427,6 +4427,9 @@ bool ProjMgrWorker::IsConnectionSubset(const ConnectionsCollection& connectionSu
}

bool ProjMgrWorker::IsCollectionSubset(const ConnectionsCollectionVec& collectionSubset, const ConnectionsCollectionVec& collectionSuperset) {
if (collectionSubset.size() != collectionSuperset.size()) {
return false;
}
for (const auto& subset : collectionSubset) {
bool isSubset = false;
for (const auto& superset : collectionSuperset) {
Expand All @@ -4443,15 +4446,14 @@ bool ProjMgrWorker::IsCollectionSubset(const ConnectionsCollectionVec& collectio
}

void ProjMgrWorker::RemoveRedundantSubsets(std::vector<ConnectionsCollectionVec>& validConnections) {
const auto connections = validConnections;
auto it = validConnections.begin();
for (const auto& collection : connections) {
while (it < validConnections.end()) {
bool isSubset = false;
for (const auto& otherCollection : connections) {
if (&collection == &otherCollection) {
for (auto it2 = validConnections.begin(); it2 < validConnections.end(); it2++) {
if (it == it2) {
continue;
}
if (IsCollectionSubset(collection, otherCollection)) {
if (IsCollectionSubset(*it, *it2)) {
isSubset = true;
break;
}
Expand Down
25 changes: 13 additions & 12 deletions tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,18 +1256,19 @@ TEST_F(ProjMgrWorkerUnitTests, CheckDeviceLayer) {
};

TEST_F(ProjMgrWorkerUnitTests, RemoveRedundantSubsets) {
const string strA = "A";
const string strB = "B";
const string strC = "C";
ConnectionsCollection A = { strA, RteUtils::EMPTY_STRING };
ConnectionsCollection B = { strB, RteUtils::EMPTY_STRING };
ConnectionsCollection C = { strC, RteUtils::EMPTY_STRING };
ConnectionsCollectionVec vecAB = { A, B };
ConnectionsCollectionVec vecA = { A };
ConnectionsCollectionVec vecB = { B };
ConnectionsCollectionVec vecC = { C };
vector<ConnectionsCollectionVec> validConnections = { vecAB, vecA, vecB, vecC };
vector<ConnectionsCollectionVec> expected = { vecAB, vecC };
ConnectItem connect1 = { "connect1" };
ConnectItem connect2 = { "connect2" };
ConnectItem connect3 = { "connect3" };
const ConnectItem* c1 = { &connect1 };
const ConnectItem* c2 = { &connect2 };
const ConnectItem* c3 = { &connect3 };
ConnectionsCollection A = { "filenameA", RteUtils::EMPTY_STRING, {c1, c2, c3} };
ConnectionsCollection As = { "filenameA", RteUtils::EMPTY_STRING, {c3, c1} };
ConnectionsCollection B = { "filenameB", RteUtils::EMPTY_STRING, {c1, c2, c3} };
ConnectionsCollection Bs = { "filenameB", RteUtils::EMPTY_STRING, {c2} };
ConnectionsCollection C = { "filenameC", RteUtils::EMPTY_STRING };
vector<ConnectionsCollectionVec> validConnections = { { Bs }, { A, B }, { A }, { B, A }, { B }, { A, B }, { As }, { C }, { Bs } };
vector<ConnectionsCollectionVec> expected = { { A }, { B }, { A, B }, { C } };
RemoveRedundantSubsets(validConnections);
auto it = validConnections.begin();
for (const auto& expectedItem : expected) {
Expand Down
Loading