From f1bb76dedf2d6b480b566540e811a7e0d3af9886 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Sun, 21 Dec 2014 15:13:37 +0100 Subject: First draft of book domain example and slight changes to the book domain: _all_ structuredclasses are listed in the domain now and StructuredClasses that are allowed at the root level have a root flag. --- src/core/model/Domain.cpp | 2 +- src/core/model/Domain.hpp | 55 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 44 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index 77708e6..fafe090 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -68,7 +68,7 @@ void Domain::doResolve(std::vector> &res, const std::vector &path, Filter filter, void *filterData, unsigned idx, VisitorSet &visited) { - for (auto &s : rootStructures) { + for (auto &s : structureClasses) { s->resolve(res, path, filter, filterData, idx, visited, nullptr); } for (auto &a : annotationClasses) { diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index c0946bf..e257c0d 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -212,7 +212,6 @@ public: Rooted getPrimitiveType() const { return primitiveType; } }; - /** * This is a super class for StructuredClasses and AnnotationClasses and is, * in itself, not supposed to be instantiated. It defines that both, Annotations @@ -369,18 +368,46 @@ protected: public: const bool transparent; + const bool root; + /** + * The constructor for a StructuredClass. + * + * @param mgr is the current Manager. + * @param name is the name of the StructuredClass. + * @param domain is the Domain this StructuredClass belongs + * to. + * @param cardinality specifies how often an element of this type + * may occur at a specific point in the + * StructureTree. For example: A document should + * have at least one author. + * @param attributesDescriptor references a StructType that in turn + * specifies which key-value pairs are permitted + * as attributes for this StructuredClass. The + * default value is a null-reference, meaning + * that no attributes are permitted. + * @param isa references a parent StructuredClass. Please + * look for more information on inheritance in + * the class documentation above. The default is + * a null reference, meaning no parent class. + * @param transparent specifies whether this StructuredClass is + * transparent. For more information on + * transparency please refer to the class + * documentation above. The default is false. + */ StructuredClass(Manager &mgr, std::string name, Handle domain, const Cardinality &cardinality, Handle attributesDescriptor = {nullptr}, // TODO: What would be a wise default value for isa? Handle isa = {nullptr}, - bool transparent = false) + bool transparent = false, + bool root = false) : Descriptor(mgr, std::move(name), domain, attributesDescriptor), cardinality(cardinality), isa(acquire(isa)), parents(this), - transparent(transparent) + transparent(transparent), + root(root) { } @@ -404,15 +431,16 @@ class AnnotationClass : public Descriptor { }; /** - * A Domain node specifies which StructuredClasses are allowed at the root - * level (or which Nonterminals are axioms of the grammar) and which Annotations - * are allowed globally. TODO: Do we want to be able to restrict Annotations to - * certain Structures? + * A Domain node specifies which StructuredClasses and which AnnotationClasses + * are part of this domain. TODO: Do we want to be able to restrict Annotations + * to certain Structures? */ class Domain : public Node { private: - NodeVector rootStructures; + NodeVector structureClasses; NodeVector annotationClasses; + // TODO: Is it wise to attach the type systems here? If not: What would be + // a good alternative. NodeVector typesystems; protected: @@ -425,18 +453,21 @@ public: Domain(Manager &mgr, std::string name) // TODO: Can a domain have a parent? : Node(mgr, std::move(name), nullptr), - rootStructures(this), + structureClasses(this), annotationClasses(this), typesystems(this) { } // TODO: Is returning a NodeVector alright? - NodeVector &getRootStructures() { return rootStructures; } + NodeVector &getStructureClasses() + { + return structureClasses; + } - const NodeVector &getRootStructures() const + const NodeVector &getStructureClasses() const { - return rootStructures; + return structureClasses; } NodeVector &getAnnotationClasses() -- cgit v1.2.3