From 7c64a0770a4800d80c5a53eea2243c46301f7749 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Mon, 19 Jan 2015 20:51:04 +0100 Subject: reintroduced some setters in Domain, but probably not enough yet. --- src/core/model/Domain.cpp | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) (limited to 'src/core/model/Domain.cpp') diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index e4f087c..f76c988 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -26,23 +26,6 @@ namespace ousia { namespace model { -template -static void checkUniqueName(Handle parent, NodeVector vec, - Handle child, const std::string &parentClassName, - const std::string &childClassName) -{ - std::set childNames; - for (auto &c : vec) { - childNames.insert(c->getName()); - } - if (childNames.find(child->getName()) != childNames.end()) { - // TODO: Do we really want to have an exception here? - throw OusiaException(std::string("The ") + parentClassName + " " + - parent->getName() + " already has a " + - childClassName + " with name " + child->getName()); - } -} - /* Class FieldDescriptor */ FieldDescriptor::FieldDescriptor(Manager &mgr, Handle parent, @@ -81,13 +64,6 @@ void Descriptor::doResolve(ResolutionState &state) state); } -void Descriptor::addFieldDescriptor(Handle fd) -{ - checkUniqueName(this, fieldDescriptors, fd, "Descriptor", - "FieldDescriptor"); - fieldDescriptors.push_back(fd); -} - std::vector> Descriptor::pathTo( Handle target) const { @@ -126,7 +102,7 @@ bool Descriptor::continuePath(Handle target, return true; } // look for transparent intermediate nodes. - if (c->transparent) { + if (c->isTransparent()) { // copy the path. std::vector> cPath = currentPath; cPath.push_back(fd); @@ -166,17 +142,18 @@ bool Descriptor::continuePath(Handle target, void Descriptor::copyFieldDescriptor(Handle fd) { + invalidate(); if (fd->getFieldType() == FieldDescriptor::FieldType::PRIMITIVE) { /* - *To call the "new" operation is enough here, because the + * To call the "new" operation is enough here, because the * constructor will add the newly constructed FieldDescriptor to this * Descriptor automatically. */ new FieldDescriptor(getManager(), this, fd->getPrimitiveType(), - fd->getName(), fd->optional); + fd->getName(), fd->isOptional()); } else { new FieldDescriptor(getManager(), this, fd->getFieldType(), - fd->getName(), fd->optional); + fd->getName(), fd->isOptional()); } } @@ -266,13 +243,13 @@ void Domain::doResolve(ResolutionState &state) void Domain::addStructuredClass(Handle s) { - checkUniqueName(this, structuredClasses, s, "Domain", "StructuredClass"); + invalidate(); structuredClasses.push_back(s); } void Domain::addAnnotationClass(Handle a) { - checkUniqueName(this, annotationClasses, a, "Domain", "AnnotationClass"); + invalidate(); annotationClasses.push_back(a); } } -- cgit v1.2.3