From d0b3fd56b8eef09faf7986cef5d8732df1e5ddf5 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sat, 20 Dec 2014 16:39:32 +0100 Subject: adapted model classes to new Rtti class --- src/core/model/Document.cpp | 19 +++++++++++++++---- src/core/model/Document.hpp | 34 ---------------------------------- src/core/model/Domain.cpp | 19 +++++++++++++++---- src/core/model/Domain.hpp | 27 --------------------------- src/core/model/Typesystem.cpp | 14 +++++++------- 5 files changed, 37 insertions(+), 76 deletions(-) (limited to 'src/core/model') diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index 497bb43..f6ed5de 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -25,8 +25,7 @@ namespace model { int DocumentEntity::getFieldDescriptorIndex(const std::string &fieldName) { - const NodeVector &fds = - descriptor->getFieldDescriptors(); + const NodeVector &fds = descriptor->getFieldDescriptors(); unsigned int f = 0; // look if we have an empty name. @@ -71,8 +70,7 @@ void DocumentEntity::getField(NodeVector &res, NodeVector &DocumentEntity::getField( Rooted fieldDescriptor) { - const NodeVector &fds = - descriptor->getFieldDescriptors(); + const NodeVector &fds = descriptor->getFieldDescriptors(); int f = 0; for (auto &fd : fds) { if (fd->getName() == fieldDescriptor->getName() && @@ -187,6 +185,19 @@ Rooted DocumentPrimitive::buildEntity( // and return it. return entity; } + +/* Type registrations */ + +const Rtti Document_Rtti{"Document"}; +const Rtti DocumentEntity_Rtti{"DocumentEntity"}; +const Rtti AnnotationEntity_Rtti{"AnnotationEntity", + {&DocumentEntity_Rtti}}; +const Rtti StructuredEntity_Rtti{"StructuredEntity", + {&DocumentEntity_Rtti}}; +const Rtti DocumentPrimitive_Rtti{"DocumentPrimitive", + {&StructuredEntity_Rtti}}; +const Rtti Anchor_Rtti{"Anchor", + {&StructuredEntity_Rtti}}; } } diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp index 0e0a416..5a293d3 100644 --- a/src/core/model/Document.hpp +++ b/src/core/model/Document.hpp @@ -187,11 +187,6 @@ 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. @@ -264,12 +259,6 @@ 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. @@ -307,12 +296,6 @@ public: 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 @@ -376,18 +359,6 @@ 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. @@ -407,11 +378,6 @@ 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.cpp b/src/core/model/Domain.cpp index 8eee86a..4901692 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -34,7 +34,7 @@ void FieldDescriptor::doResolve(std::vector> &res, } // TODO: better alias? -static std::string DESCRIPTOR_ATTRIBUTES_ALIAS {"attributes"}; +static std::string DESCRIPTOR_ATTRIBUTES_ALIAS{"attributes"}; void Descriptor::doResolve(std::vector> &res, const std::vector &path, Filter filter, @@ -46,8 +46,9 @@ void Descriptor::doResolve(std::vector> &res, fd->resolve(res, path, filter, filterData, idx, visited, nullptr); } // TODO: This throws a SEGFAULT for some reason. -// attributesDescriptor->resolve(res, path, filter, filterData, idx, visited, -// &DESCRIPTOR_ATTRIBUTES_ALIAS); + // attributesDescriptor->resolve(res, path, filter, filterData, idx, + // visited, + // &DESCRIPTOR_ATTRIBUTES_ALIAS); } void StructuredClass::doResolve(std::vector> &res, @@ -56,7 +57,7 @@ void StructuredClass::doResolve(std::vector> &res, VisitorSet &visited) { Descriptor::doResolve(res, path, filter, filterData, idx, visited); - if(!isa.isNull()){ + if (!isa.isNull()) { isa->doResolve(res, path, filter, filterData, idx, visited); } } @@ -75,6 +76,16 @@ void Domain::doResolve(std::vector> &res, t->resolve(res, path, filter, filterData, idx, visited, nullptr); } } + +/* Type registrations */ + +const Rtti FieldDescriptor_Rtti{"FieldDescriptor"}; +const Rtti Descriptor_Rtti{"Descriptor"}; +const Rtti StructuredClass_Rtti{"StructuredClass", + {&Descriptor_Rtti}}; +const Rtti AnnotationClass_Rtti{"AnnotationClass", + {&Descriptor_Rtti}}; +const Rtti Domain_Rtti{"Domain"}; } } diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index d19558e..c0946bf 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -212,11 +212,6 @@ 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, @@ -283,11 +278,6 @@ public: } }; -/** - * A global variable for the ManagedType of a Descriptor. - */ -static ManagedType DescriptorType{"Descriptor", typeid(Descriptor)}; - typedef RangeSet Cardinality; /** @@ -404,12 +394,6 @@ 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. @@ -419,12 +403,6 @@ static ManagedType StructuredClassType{ 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 @@ -475,11 +453,6 @@ public: const NodeVector &getTypesystems() const { return typesystems; } }; - -/** - * A global variable for the ManagedType of a Domain. - */ -static ManagedType DomainType{"Domain", typeid(Domain)}; } } diff --git a/src/core/model/Typesystem.cpp b/src/core/model/Typesystem.cpp index 724bf0e..1da45ae 100644 --- a/src/core/model/Typesystem.cpp +++ b/src/core/model/Typesystem.cpp @@ -76,13 +76,13 @@ EnumType EnumType::createValidated(Manager &mgr, std::string name, /* RTTI type registrations */ -const Rtti Type_T("Type"); -const Rtti StringType_T("StringType", {&Type_T}); -const Rtti IntType_T("IntType", {&Type_T}); -const Rtti DoubleType_T("DoubleType", {&Type_T}); -const Rtti BoolType_T("BoolType", {&Type_T}); -const Rtti EnumType_T("EnumType", {&Type_T}); -const Rtti StructType_T("StructType", {&Type_T}); +const Rtti Type_Rtti{"Type"}; +const Rtti StringType_Rtti{"StringType", {&Type_Rtti}}; +const Rtti IntType_Rtti{"IntType", {&Type_Rtti}}; +const Rtti DoubleType_Rtti{"DoubleType", {&Type_Rtti}}; +const Rtti BoolType_Rtti{"BoolType", {&Type_Rtti}}; +const Rtti EnumType_Rtti{"EnumType", {&Type_Rtti}}; +const Rtti StructType_Rtti{"StructType", {&Type_Rtti}}; } } -- cgit v1.2.3