-
Notifications
You must be signed in to change notification settings - Fork 2
Fixes to Merging algorithm #54
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
base: vara-dev
Are you sure you want to change the base?
Changes from 13 commits
2a30dcc
d3edd74
b4ac257
99f6130
5d6a33e
c17f473
096cefc
4c94e95
0eba8f7
eb6aabf
5975b52
1025d36
25a26e6
08c1ae5
c4226e5
aed93e3
ee977c9
f7e0e52
052c46f
e0f211b
c4b01e5
df1f5ea
e94701e
49c7967
aea67f2
87d82c7
5033222
d087829
2a6e2f9
7c99c0b
fb0ced9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,10 @@ class FeatureModelTransaction | |
} | ||
} | ||
|
||
void removeConstraint(Constraint &RemoveConstraint) { | ||
this->removeConstraintImpl(RemoveConstraint); | ||
} | ||
|
||
void setName(std::string Name) { return this->setNameImpl(std::move(Name)); } | ||
|
||
void setCommit(std::string Commit) { | ||
|
@@ -253,6 +257,14 @@ class FeatureModelModification { | |
return FM.addConstraint(std::move(Constraint)); | ||
} | ||
|
||
static void removeConstraint(FeatureModel &FM, Constraint *R) { | ||
vulder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
FM.removeConstraint(R); | ||
} | ||
|
||
static void removeConstraint(Feature &F, Constraint *C) { | ||
F.removeConstraintNonPreserve(C); | ||
} | ||
|
||
static void setName(FeatureModel &FM, std::string NewName) { | ||
FM.setName(std::move(NewName)); | ||
} | ||
|
@@ -304,8 +316,12 @@ class AddFeatureToModel : public FeatureModelModification { | |
return nullptr; | ||
} | ||
if (Parent) { | ||
setParent(*InsertedFeature, *Parent); | ||
addEdge(*Parent, *InsertedFeature); | ||
FeatureTreeNode *ParentNode = Parent; | ||
if (!Parent->getChildren<Relationship>(1).empty()) { | ||
ParentNode = *(Parent->getChildren<Relationship>(1).begin()); | ||
} | ||
Comment on lines
+326
to
+328
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make sure I understand this correctly: This assumes that a Feature can have exactly one (or no) relationship as child and if it has, there are no features as direct children allowed. Is this assumption validated anywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, if it's currently not possible to have multiple ones, we probably can adapt the API to make it viable. |
||
setParent(*InsertedFeature, *ParentNode); | ||
addEdge(*ParentNode, *InsertedFeature); | ||
} else if (FM.getRoot()) { | ||
setParent(*InsertedFeature, *FM.getRoot()); | ||
addEdge(*FM.getRoot(), *InsertedFeature); | ||
|
@@ -322,6 +338,39 @@ class AddFeatureToModel : public FeatureModelModification { | |
Feature *Parent; | ||
}; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// RemoveConstraintFromModel | ||
//===----------------------------------------------------------------------===// | ||
|
||
class RemoveConstraintFromModel : public FeatureModelModification { | ||
friend class FeatureModelModification; | ||
friend class RemoveFeatureFromModel; | ||
|
||
public: | ||
void exec(FeatureModel &FM) override { (*this)(FM); } | ||
|
||
void operator()(FeatureModel &FM) { | ||
assert(RemoveConstraint.getParent() == nullptr && | ||
"Subtree deletion is not supported"); | ||
UncoupleVisitor UV; | ||
RemoveConstraint.accept(UV); | ||
removeConstraint(FM, &RemoveConstraint); | ||
} | ||
|
||
private: | ||
RemoveConstraintFromModel(Constraint &RemoveConstraint) | ||
: RemoveConstraint(RemoveConstraint) {} | ||
|
||
class UncoupleVisitor : public ConstraintVisitor { | ||
public: | ||
void visit(PrimaryFeatureConstraint *C) override { | ||
removeConstraint(*C->getFeature(), C); | ||
} | ||
}; | ||
|
||
Constraint &RemoveConstraint; | ||
}; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// RemoveFeatureFromModel | ||
//===----------------------------------------------------------------------===// | ||
|
@@ -365,6 +414,15 @@ class RemoveFeatureFromModel : public FeatureModelModification { | |
} | ||
} | ||
|
||
while (!F->constraints().empty()) { | ||
padupr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Constraint *C = *(F->constraints().begin()); | ||
while (C->getParent()) { | ||
C = C->getParent(); | ||
} | ||
RemoveConstraintFromModel RCFM(*C); | ||
RCFM(FM); | ||
} | ||
|
||
removeEdge(*F->getParent(), *F); | ||
removeFeature(FM, *F); | ||
} | ||
|
@@ -803,14 +861,19 @@ class FeatureModelCopyTransactionBase { | |
} | ||
|
||
Constraint *addConstraintImpl(std::unique_ptr<Constraint> NewConstraint) { | ||
if (!FM) { | ||
return nullptr; | ||
} | ||
assert(FM && "FeatureModel is null."); | ||
vulder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return FeatureModelModification::make_modification<AddConstraintToModel>( | ||
std::move(NewConstraint))(*FM); | ||
} | ||
|
||
void removeConstraintImpl(Constraint &RemoveConstraint) { | ||
assert(FM && "FeatureModel is null."); | ||
|
||
FeatureModelModification::make_modification<RemoveConstraintFromModel>( | ||
RemoveConstraint)(*FM); | ||
} | ||
|
||
void setNameImpl(std::string Name) { | ||
assert(FM && "FeatureModel is null."); | ||
|
||
|
@@ -919,6 +982,11 @@ class FeatureModelModifyTransactionBase { | |
AddConstraintToModel>(std::move(NewConstraint))); | ||
} | ||
|
||
void removeConstraintImpl(Constraint &RemoveConstraint) { | ||
Modifications.push_back(FeatureModelModification::make_unique_modification< | ||
RemoveConstraintFromModel>(RemoveConstraint)); | ||
} | ||
|
||
void setNameImpl(std::string Name) { | ||
assert(FM && "FeatureModel is null."); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.