summaryrefslogtreecommitdiff
path: root/src/core/model
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-15 19:24:21 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-15 19:24:21 +0100
commitc0db7f8fda037b2bfeb3f47605b9cb52205dffc8 (patch)
tree4de0221f8735cc1a50c32e8d73bc7c1fe15b6b92 /src/core/model
parent64e465dcc61754ae9303d9c48585b455ea19c32a (diff)
fixed a bug in pathTo functions.
Diffstat (limited to 'src/core/model')
-rw-r--r--src/core/model/Domain.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp
index a68f00d..698d49d 100644
--- a/src/core/model/Domain.cpp
+++ b/src/core/model/Domain.cpp
@@ -80,17 +80,26 @@ static NodeVector<Node> pathTo(const Node *start, Logger &logger,
} else {
const FieldDescriptor *field =
static_cast<const FieldDescriptor *>(start);
- // initially put every child on the queue.
+ // initially put every child and its subclasses to the queue.
for (auto c : field->getChildren()) {
// if we have found the target directly, return without search.
if (c == target) {
success = true;
return shortest;
}
- // We only allow to continue our path via transparent children.
if (c->isTransparent()) {
states.push(std::make_shared<PathState>(nullptr, c.get()));
}
+ for (auto sub : c->getSubclasses()) {
+ if (sub == target) {
+ success = true;
+ return shortest;
+ }
+ if (sub->isTransparent()) {
+ states.push(
+ std::make_shared<PathState>(nullptr, sub.get()));
+ }
+ }
}
}
// set of visited nodes.
@@ -126,27 +135,6 @@ static NodeVector<Node> pathTo(const Node *start, Logger &logger,
states.push(std::make_shared<PathState>(current, fd.get()));
}
}
-
- /*
- * Furthermore we have to consider that all subclasses of this
- * StructuredClass are allowed in place of this StructuredClass as
- * well, so we continue the search for them as well.
- */
-
- NodeVector<StructuredClass> subs = strct->getSubclasses();
- for (auto sub : subs) {
- // if we found our target, break off the search in this branch.
- if (sub == target) {
- fin = true;
- current = current->pred;
- continue;
- }
- // We only continue our path via transparent classes.
- if (sub->isTransparent()) {
- states.push(
- std::make_shared<PathState>(current->pred, sub.get()));
- }
- }
} else {
// otherwise this is a FieldDescriptor.
const FieldDescriptor *field =
@@ -162,6 +150,17 @@ static NodeVector<Node> pathTo(const Node *start, Logger &logger,
if (c->isTransparent()) {
states.push(std::make_shared<PathState>(current, c.get()));
}
+ // ... or their transparent subclasses.
+ for (auto sub : c->getSubclasses()) {
+ if (sub == target) {
+ fin = true;
+ continue;
+ }
+ if (sub->isTransparent()) {
+ states.push(
+ std::make_shared<PathState>(current, sub.get()));
+ }
+ }
}
}
// check if we are finished.