From 5eca67b6cab7031d8203b1403ba5cddaef833e76 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Sun, 8 Feb 2015 19:37:51 +0100 Subject: restructured the FieldDescriptor mechanism. --- src/core/model/Domain.cpp | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/core/model/Domain.cpp') diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index 55f05b3..f45bd27 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -179,13 +179,7 @@ bool Descriptor::continuePath(Handle target, std::vector> optimum; // use recursive depth-first search from the top to reach the given child // get the list of effective FieldDescriptors. - NodeVector fields; - if (isa(&RttiTypes::StructuredClass)) { - const StructuredClass *tis = static_cast(this); - fields = tis->getEffectiveFieldDescriptors(); - } else { - fields = getFieldDescriptors(); - } + NodeVector fields = getFieldDescriptors(); for (auto &fd : fields) { for (auto &c : fd->getChildren()) { @@ -234,6 +228,30 @@ bool Descriptor::continuePath(Handle target, return found; } +int Descriptor::getFieldDescriptorIndex(const std::string &name) const +{ + int f = 0; + for (auto &fd : getFieldDescriptors()) { + if (fd->getName() == name) { + return f; + } + f++; + } + return -1; +} + +int Descriptor::getFieldDescriptorIndex(Handle fd) const +{ + int f = 0; + for (auto &fd2 : getFieldDescriptors()) { + if (fd == fd2) { + return f; + } + f++; + } + return -1; +} + void Descriptor::addFieldDescriptor(Handle fd) { // only add it if we need to. @@ -444,14 +462,13 @@ const void StructuredClass::gatherFieldDescriptors( } } -NodeVector StructuredClass::getEffectiveFieldDescriptors() - const +NodeVector StructuredClass::getFieldDescriptors() const { // in this case we return a NodeVector of Rooted entries without owner. NodeVector vec; std::set overriddenFields; gatherFieldDescriptors(vec, overriddenFields); - return std::move(vec); + return vec; } /* Class AnnotationClass */ -- cgit v1.2.3