From a98797188a48148f5d8b268bf623b15d283d6334 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Mon, 15 Dec 2014 14:00:15 +0100 Subject: finished first version of Domain.hpp, which compiles now. --- src/core/model/Domain.hpp | 79 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 14 deletions(-) (limited to 'src/core/model') diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index 9bd2982..c163254 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -85,6 +85,8 @@ #include #include +#include "Typesystem.hpp" + namespace ousia { namespace model { @@ -156,6 +158,7 @@ public: FieldDescriptor(Manager &mgr, std::string name, Handle parent, Handle primitiveType, bool optional) : Node(mgr, std::move(name), parent), + children(this), fieldType(FieldType::PRIMITIVE), primitiveType(acquire(primitiveType)), optional(optional) @@ -170,7 +173,7 @@ public: * @param name is the name of this field. * @param parent is a handle of the Descriptor node that has this * FieldDescriptor. - * @param type is the FieldType of this FieldDescriptor, either + * @param fieldType is the FieldType of this FieldDescriptor, either * TREE for the main or default structure or SUBTREE * for supporting structures. * @param optional should be set to 'false' is this field needs to be @@ -178,22 +181,22 @@ public: * Descriptor to be valid. */ FieldDescriptor(Manager &mgr, std::string name, Handle parent, - FieldType type, ManagedVector children, - bool optional) + FieldType fieldType, + ManagedVector children, bool optional) : Node(mgr, std::move(name), parent), - fieldType(type), children(children), + fieldType(fieldType), + // TODO: What would be a wise initialization of the primitiveType? optional(optional) - // TODO: What would be a wise initialization of the primitiveType? { } // TODO: Is returning a ManagedVector alright? ManagedVector &getChildren() { return children; } - FieldType getFieldType() const { return type; } + FieldType getFieldType() const { return fieldType; } - bool isPrimitive() const { return type == FieldType::PRIMITIVE; } + bool isPrimitive() const { return fieldType == FieldType::PRIMITIVE; } Rooted getPrimitiveType() const { return primitiveType; } }; @@ -255,7 +258,7 @@ public: // TODO: Implement class Cardinality { -} +}; /** * A StructuredClass specifies nodes in the StructureTree of a document that @@ -342,24 +345,72 @@ public: const bool transparent; StructuredClass(Manager &mgr, std::string name, Handle parent, - const Cardinality cardinality &, - // TODO: Wha would be a wise default value for isa? + Handle attributesDescriptor, + ManagedVector fieldDescriptors, + const Cardinality &cardinality, + // TODO: What would be a wise default value for isa? Handle isa, - ManagedVector parents) - : Node(mgr, std::move(name), parent), + ManagedVector parents, + bool transparent) + : Descriptor(mgr, std::move(name), parent, attributesDescriptor, + fieldDescriptors), cardinality(cardinality), isa(acquire(isa)), - parents(parents) + parents(parents), + transparent(transparent) { } const Cardinality &getCardinality() const { return cardinality; } - Rooted getIsA() const {return isa}; + Rooted getIsA() const {return isa;} // TODO: Is returning a ManagedVector alright? ManagedVector getParents() { return parents; } }; + +/** + * An AnnotationClass defines allowed Annotations. For more information on + * Annotations please refer to the Document.hpp. + * + * This class has no special properties and is in essence just a Descriptor. + */ +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? + */ +class Domain : public Node { +private: + ManagedVector rootStructures; + ManagedVector annotationClasses; + +public: + Domain(Manager &mgr, std::string name, + ManagedVector rootStructures, + ManagedVector annotationClasses) + // TODO: Can a domain have a parent? + : Node(mgr, std::move(name), nullptr), + rootStructures(rootStructures), + annotationClasses(annotationClasses) + { + } + + // TODO: Is returning a ManagedVector alright? + ManagedVector getRootStructures() + { + return rootStructures; + } + + ManagedVector getAnnotationClasses() + { + return annotationClasses; + } +}; } } -- cgit v1.2.3