From f77ec7ae614810bc317c23138279e115f930aa06 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Sat, 20 Dec 2014 15:14:28 +0100 Subject: Introduced global type variables for model classes and used them in the Domain resolve test, which makes it much easier to understand. --- src/core/model/Document.hpp | 38 ++++++++++++++++++++++++++++++++++++-- src/core/model/Domain.hpp | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 67 insertions(+), 14 deletions(-) (limited to 'src/core/model') diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp index a660da7..0e0a416 100644 --- a/src/core/model/Document.hpp +++ b/src/core/model/Document.hpp @@ -187,6 +187,11 @@ public: Rooted fieldDescriptor); }; +/** + * A global variable for the ManagedType of a DocumentEntity. + */ +static ManagedType DocumentEntityType{"DocumentEntity", typeid(DocumentEntity)}; + /** * A StructuredEntity is a node in the Structure Tree of a document. For more * information please refer to the header documentation above. @@ -259,6 +264,12 @@ public: Variant attributes = Variant(), std::string name = ""); }; +/** + * A global variable for the ManagedType of a StructuredEntity. + */ +static ManagedType StructuredEntityType{ + "StructuredEntity", typeid(StructuredEntity), {&DocumentEntityType}}; + /** * This is a wrapper for primitive types (Variants) inside the document graph. * The most straightforward example for this is the actual document text, e.g. @@ -292,10 +303,16 @@ public: * contain a StructuredClass with the given name. */ static Rooted buildEntity( - Handle parent, - Variant content, const std::string &fieldName = ""); + Handle parent, Variant content, + const std::string &fieldName = ""); }; +/** + * A global variable for the ManagedType of a DocumentPrimitive. + */ +static ManagedType DocumentPrimitiveType{ + "DocumentPrimitive", typeid(DocumentPrimitive), {&StructuredEntityType}}; + /** * An AnnotationEntity is a span-like instance that is not bound by the elements * of the Structure Tree. An annotation may very well overlap and cross the @@ -359,6 +376,18 @@ public: Rooted getEnd() { return end; } }; +/** + * A global variable for the ManagedType of an Anchor. + */ +static ManagedType AnchorType{ + "Anchor", typeid(AnnotationEntity::Anchor), {&StructuredEntityType}}; + +/** + * A global variable for the ManagedType of an AnnotationEntity. + */ +static ManagedType AnnotationEntityType{ + "AnnotationEntity", typeid(AnnotationEntity), {&DocumentEntityType}}; + /** * A Document is mainly a wrapper for the Root structure node of the Document * Graph. @@ -378,6 +407,11 @@ public: Rooted getRoot() const { return root; } }; + +/** + * A global variable for the ManagedType of a Document. + */ +static ManagedType DocumentType{"Document", typeid(Document)}; } } diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index d0227bd..d19558e 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -203,10 +203,7 @@ public: // TODO: Is returning a NodeVector alright? NodeVector &getChildren() { return children; } - const NodeVector &getChildren() const - { - return children; - } + const NodeVector &getChildren() const { return children; } FieldType getFieldType() const { return fieldType; } @@ -215,6 +212,12 @@ public: Rooted getPrimitiveType() const { return primitiveType; } }; +/** + * A global variable for the ManagedType of a FieldDescriptor. + */ +static ManagedType FieldDescriptorType{"FieldDescriptor", + typeid(FieldDescriptor)}; + /** * This is a super class for StructuredClasses and AnnotationClasses and is, * in itself, not supposed to be instantiated. It defines that both, Annotations @@ -280,6 +283,11 @@ public: } }; +/** + * A global variable for the ManagedType of a Descriptor. + */ +static ManagedType DescriptorType{"Descriptor", typeid(Descriptor)}; + typedef RangeSet Cardinality; /** @@ -396,6 +404,12 @@ public: const NodeVector &getParents() const { return parents; } }; +/** + * A global variable for the ManagedType of a StructuredClass. + */ +static ManagedType StructuredClassType{ + "StructuredClass", typeid(StructuredClass), {&DescriptorType}}; + /** * An AnnotationClass defines allowed Annotations. For more information on * Annotations please refer to the Document.hpp. @@ -405,6 +419,12 @@ public: class AnnotationClass : public Descriptor { }; +/** + * A global variable for the ManagedType of an AnnotationClass. + */ +static ManagedType AnnotationClassType{ + "AnnotationClass", typeid(AnnotationClass), {&DescriptorType}}; + /** * A Domain node specifies which StructuredClasses are allowed at the root * level (or which Nonterminals are axioms of the grammar) and which Annotations @@ -434,10 +454,7 @@ public: } // TODO: Is returning a NodeVector alright? - NodeVector &getRootStructures() - { - return rootStructures; - } + NodeVector &getRootStructures() { return rootStructures; } const NodeVector &getRootStructures() const { @@ -456,11 +473,13 @@ public: NodeVector &getTypesystems() { return typesystems; } - const NodeVector &getTypesystems() const - { - return typesystems; - } + const NodeVector &getTypesystems() const { return typesystems; } }; + +/** + * A global variable for the ManagedType of a Domain. + */ +static ManagedType DomainType{"Domain", typeid(Domain)}; } } -- cgit v1.2.3