diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-12-17 17:11:51 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-12-17 17:11:51 +0100 |
commit | 93c065174e1aa306ee724dd523ef6b2254c1d388 (patch) | |
tree | a25f24f8905e490aab89f4437ca639ea57a430ab /src | |
parent | 3e124a41f14fa3a76febba09f4b58b3f5361efdb (diff) |
Some (slight) changes to existing structures and first attempts on a test to construct a test comain and a test document out of thin air. I am, indeed, an alchemist.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/managed/ManagedContainer.hpp | 11 | ||||
-rw-r--r-- | src/core/model/Document.hpp | 8 | ||||
-rw-r--r-- | src/core/model/Domain.hpp | 41 | ||||
-rw-r--r-- | src/core/model/Typesystem.hpp | 2 |
4 files changed, 45 insertions, 17 deletions
diff --git a/src/core/managed/ManagedContainer.hpp b/src/core/managed/ManagedContainer.hpp index 19bff3f..6bf1915 100644 --- a/src/core/managed/ManagedContainer.hpp +++ b/src/core/managed/ManagedContainer.hpp @@ -32,6 +32,7 @@ #include <unordered_set> #include <vector> #include <map> +#include <stdexcept> #include <type_traits> #include "Manager.hpp" @@ -496,6 +497,16 @@ public: } Base::c.pop_back(); } + + Rooted<T> operator[](int i) const { + for (const_iterator it = Base::cbegin(); it != Base::cend(); it++) { + if (i == 0) { + return Rooted<T>(*it); + } + i--; + } + throw std::out_of_range(std::to_string(i) + " is out of range!"); + } }; /** diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp index 3114480..a31e52f 100644 --- a/src/core/model/Document.hpp +++ b/src/core/model/Document.hpp @@ -26,9 +26,11 @@ * * A Document, from top to bottom, consists of "Document" instance, * which "owns" the structural root node of the in-document graph. This might - * for example be a "book" node, if the respective document implements the - * "book" domain. That root node in turn has structure nodes as children as well - * as annotations that refer to the content of that structure node. + * for example be a "book" node of the "book" domain. That root node in turn has + * structure nodes as children, which in turn may have children. This + * constitutes a Structure Tree. Additionally annotations may be attached to + * Structure Nodes, effectively resulting in a Document Graph instead of a + * Document Tree (other references may introduce cycles as well). * * Consider this simplified XML representation of a document (TODO: Use * non-simplified XML as soon as possible): diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index 9ae8871..e348136 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -91,8 +91,9 @@ namespace ousia { namespace model { -class StructuredClass; class Descriptor; +class StructuredClass; +class Domain; /** * As mentioned in the description above a FieldDescriptor specifies the @@ -147,17 +148,18 @@ public: * set to "PRIMITIVE". * * @param mgr is the global Manager instance. - * @param name is the name of this field. * @param parent is a handle of the Descriptor node that has this * FieldDescriptor. * @param primitiveType is a handle to some Type in some Typesystem of which * one instance is allowed to fill this field. + * @param name is the name of this field. * @param optional should be set to 'false' is this field needs to be * filled in order for an instance of the parent * Descriptor to be valid. */ - FieldDescriptor(Manager &mgr, std::string name, Handle<Descriptor> parent, - Handle<Type> primitiveType, bool optional) + FieldDescriptor(Manager &mgr, Handle<Descriptor> parent, + Handle<Type> primitiveType, std::string name = "", + bool optional = false) : Node(mgr, std::move(name), parent), children(this), fieldType(FieldType::PRIMITIVE), @@ -171,18 +173,19 @@ public: * children here. * * @param mgr is the global Manager instance. - * @param name is the name of this field. * @param parent is a handle of the Descriptor node that has this * FieldDescriptor. * @param fieldType is the FieldType of this FieldDescriptor, either * TREE for the main or default structure or SUBTREE * for supporting structures. + * @param name is the name of this field. * @param optional should be set to 'false' is this field needs to be * filled in order for an instance of the parent * Descriptor to be valid. */ - FieldDescriptor(Manager &mgr, std::string name, Handle<Descriptor> parent, - FieldType fieldType, bool optional) + FieldDescriptor(Manager &mgr, Handle<Descriptor> parent, + FieldType fieldType = FieldType::TREE, + std::string name = "", bool optional = false) : Node(mgr, std::move(name), parent), children(this), fieldType(fieldType), @@ -239,10 +242,10 @@ private: ManagedVector<FieldDescriptor> fieldDescriptors; public: - Descriptor(Manager &mgr, std::string name, Handle<Node> parent, + Descriptor(Manager &mgr, std::string name, Handle<Domain> domain, // TODO: What would be a wise default value for attributes? Handle<StructType> attributesDescriptor) - : Node(mgr, std::move(name), parent), + : Node(mgr, std::move(name), domain), attributesDescriptor(acquire(attributesDescriptor)), fieldDescriptors(this) { @@ -351,12 +354,13 @@ private: public: const bool transparent; - StructuredClass(Manager &mgr, std::string name, Handle<Node> parent, - Handle<StructType> attributesDescriptor, + 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, bool transparent) - : Descriptor(mgr, std::move(name), parent, attributesDescriptor), + Handle<StructuredClass> isa = {nullptr}, + bool transparent = false) + : Descriptor(mgr, std::move(name), domain, attributesDescriptor), cardinality(cardinality), isa(acquire(isa)), parents(this), @@ -393,13 +397,15 @@ class Domain : public Node { private: ManagedVector<StructuredClass> rootStructures; ManagedVector<AnnotationClass> annotationClasses; + ManagedVector<Typesystem> typesystems; public: Domain(Manager &mgr, std::string name) // TODO: Can a domain have a parent? : Node(mgr, std::move(name), nullptr), rootStructures(this), - annotationClasses(this) + annotationClasses(this), + typesystems(this) { } @@ -423,6 +429,13 @@ public: { return annotationClasses; } + + ManagedVector<Typesystem> &getTypesystems() { return typesystems; } + + const ManagedVector<Typesystem> &getTypesystems() const + { + return typesystems; + } }; } } diff --git a/src/core/model/Typesystem.hpp b/src/core/model/Typesystem.hpp index 347adb8..90154ce 100644 --- a/src/core/model/Typesystem.hpp +++ b/src/core/model/Typesystem.hpp @@ -372,6 +372,8 @@ public: * TODO: DOC */ void addType(Handle<Type> type) { types.push_back(type); } + + const NodeVector<Type> &getTypes() const { return types; } }; } } |