diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/core/model/Domain.cpp | 2 | ||||
-rw-r--r-- | src/core/model/Domain.hpp | 55 | ||||
-rw-r--r-- | test/core/model/TestDomain.hpp | 8 |
4 files changed, 50 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 563977e..3575d7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ PKG_CHECK_MODULES(EXPAT REQUIRED expat) FIND_PACKAGE(Boost COMPONENTS system filesystem REQUIRED) # Set utf8cpp include path -SET(UTF8CPP_INCLUDE_DIR "lib/utf8") +SET(UTF8CPP_INCLUDE_DIR "lib/utf8cpp") ################################################################################ # Inclusion of doxygen # 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<Rooted<Managed>> &res, const std::vector<std::string> &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<Type> 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> domain, const Cardinality &cardinality, Handle<StructType> attributesDescriptor = {nullptr}, // TODO: What would be a wise default value for isa? Handle<StructuredClass> 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<StructuredClass> rootStructures; + NodeVector<StructuredClass> structureClasses; NodeVector<AnnotationClass> annotationClasses; + // TODO: Is it wise to attach the type systems here? If not: What would be + // a good alternative. NodeVector<Typesystem> 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<StructuredClass> &getRootStructures() { return rootStructures; } + NodeVector<StructuredClass> &getStructureClasses() + { + return structureClasses; + } - const NodeVector<StructuredClass> &getRootStructures() const + const NodeVector<StructuredClass> &getStructureClasses() const { - return rootStructures; + return structureClasses; } NodeVector<AnnotationClass> &getAnnotationClasses() diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestDomain.hpp index 41fcdef..dd58524 100644 --- a/test/core/model/TestDomain.hpp +++ b/test/core/model/TestDomain.hpp @@ -59,9 +59,9 @@ static Rooted<Domain> constructBookDomain(Manager &mgr) any.merge(Range<size_t>::typeRangeFrom(0)); // Set up the "book" node. - Rooted<StructuredClass> book{ - new StructuredClass(mgr, "book", domain, single)}; - domain->getRootStructures().push_back(book); + Rooted<StructuredClass> book{new StructuredClass( + mgr, "book", domain, single, {nullptr}, {nullptr}, false, true)}; + domain->getStructureClasses().push_back(book); // The structure field of it. Rooted<FieldDescriptor> book_field{new FieldDescriptor(mgr, book)}; book->getFieldDescriptors().push_back(book_field); @@ -70,6 +70,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr) Rooted<StructuredClass> section{ new StructuredClass(mgr, "section", domain, any)}; book_field->getChildren().push_back(section); + domain->getStructureClasses().push_back(section); // And the field of it. Rooted<FieldDescriptor> section_field{new FieldDescriptor(mgr, section)}; section->getFieldDescriptors().push_back(section_field); @@ -79,6 +80,7 @@ static Rooted<Domain> constructBookDomain(Manager &mgr) mgr, "paragraph", domain, any, {nullptr}, {nullptr}, true)}; section_field->getChildren().push_back(paragraph); book_field->getChildren().push_back(paragraph); + domain->getStructureClasses().push_back(paragraph); // ... and has a primitive field. Rooted<FieldDescriptor> paragraph_field{new FieldDescriptor( mgr, paragraph, domain->getTypesystems()[0]->getTypes()[1], "text", |