From 496c4e527852d0fd64a24bd5ac2506e50ba0afc7 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 15 Jan 2015 12:13:18 +0100 Subject: supported more automatic registration behaviour, checked for internal name consistency regarding FieldDescriptors, AnnotationClasses and StructuredClasses and made adding methods for automatically registered references protected. --- src/core/model/Domain.hpp | 99 +++++++++++------------------------------------ 1 file changed, 23 insertions(+), 76 deletions(-) (limited to 'src/core/model/Domain.hpp') diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index 4b26917..791d563 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -292,14 +292,7 @@ public: */ FieldDescriptor(Manager &mgr, Handle parent, Handle primitiveType, std::string name = "", - bool optional = false) - : Node(mgr, std::move(name), parent), - children(this), - fieldType(FieldType::PRIMITIVE), - primitiveType(acquire(primitiveType)), - optional(optional) - { - } + bool optional = false); /** * This is the constructor for non-primitive fields. You have to provide @@ -318,13 +311,7 @@ public: */ FieldDescriptor(Manager &mgr, Handle parent, FieldType fieldType = FieldType::TREE, - std::string name = "", bool optional = false) - : Node(mgr, std::move(name), parent), - children(this), - fieldType(fieldType), - optional(optional) - { - } + std::string name = "", bool optional = false); /** * Returns a const reference to the NodeVector of StructuredClasses whose @@ -389,6 +376,9 @@ public: * */ class Descriptor : public Node { + +friend FieldDescriptor; + private: Owned attributesDescriptor; NodeVector fieldDescriptors; @@ -401,6 +391,11 @@ private: protected: void continueResolve(ResolutionState &state) override; + + /** + * Adds a FieldDescriptor and checks for name uniqueness. + */ + void addFieldDescriptor(Handle fd); public: Descriptor(Manager &mgr, std::string name, Handle domain, @@ -436,20 +431,11 @@ public: } /** - * Adds a FieldDescriptor to this Descriptor. + * Copies a FieldDescriptor that belongs to another Descriptor to this + * Descriptor. This will throw an exception if a FieldDescriptor with the + * given name already exists. */ - void addFieldDescriptor(Handle fd) - { - fieldDescriptors.push_back(fd); - } - - /** - * Adds multiple FieldDescriptors to this Descriptor. - */ - void addFieldDescriptors(const std::vector> &fds) - { - fieldDescriptors.insert(fieldDescriptors.end(), fds.begin(), fds.end()); - } + void copyFieldDescriptor(Handle fd); /** * This tries to construct the shortest possible path of this Descriptor @@ -600,18 +586,7 @@ public: Handle attributesDescriptor = nullptr, // TODO: What would be a wise default value for isa? Handle isa = nullptr, - bool transparent = false, bool root = false) - : Descriptor(mgr, std::move(name), domain, attributesDescriptor), - cardinality(cardinality), - isa(acquire(isa)), - subclasses(this), - transparent(transparent), - root(root) - { - if (!isa.isNull()) { - isa->subclasses.push_back(this); - } - } + bool transparent = false, bool root = false); /** * Returns the Cardinality of this StructuredClass (as a RangeSet). @@ -672,10 +647,7 @@ public: */ AnnotationClass(Manager &mgr, std::string name, Handle domain, // TODO: What would be a wise default value for attributes? - Handle attributesDescriptor) - : Descriptor(mgr, std::move(name), domain, attributesDescriptor) - { - } + Handle attributesDescriptor = nullptr); }; /** @@ -684,6 +656,10 @@ public: * to certain Structures? */ class Domain : public Node { + +friend StructuredClass; +friend AnnotationClass; + private: NodeVector structuredClasses; NodeVector annotationClasses; @@ -694,6 +670,9 @@ private: protected: void continueResolve(ResolutionState &state) override; + void addStructuredClass(Handle s); + void addAnnotationClass(Handle a); + public: /** * The constructor for a new domain. Note that this is an empty Domain and @@ -725,22 +704,6 @@ public: return structuredClasses; } - /** - * Adds a StructuredClass to this Domain. - */ - void addStructuredClass(Handle s) - { - structuredClasses.push_back(s); - } - - /** - * Adds multiple StructuredClasses to this Domain. - */ - void addStructuredClasses(const std::vector> &ss) - { - structuredClasses.insert(structuredClasses.end(), ss.begin(), ss.end()); - } - /** * Returns a const reference to the NodeVector of AnnotationClasses that are * part of this Domain. @@ -753,22 +716,6 @@ public: return annotationClasses; } - /** - * Adds an AnnotationClass to this Domain. - */ - void addAnnotationClass(Handle a) - { - annotationClasses.push_back(a); - } - - /** - * Adds multiple AnnotationClasses to this Domain. - */ - void addAnnotationClasses(const std::vector> &as) - { - annotationClasses.insert(annotationClasses.end(), as.begin(), as.end()); - } - /** * Returns a const reference to the NodeVector of TypeSystems that are * references in this Domain. -- cgit v1.2.3