diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-20 16:39:32 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2014-12-20 16:39:32 +0100 |
commit | d0b3fd56b8eef09faf7986cef5d8732df1e5ddf5 (patch) | |
tree | 9974a09bb3344a4aeb88f73078c681d345d59e91 /src/core/model | |
parent | 4294735304bb89fe603a9d5f73717a09959d3c8b (diff) |
adapted model classes to new Rtti class
Diffstat (limited to 'src/core/model')
-rw-r--r-- | src/core/model/Document.cpp | 19 | ||||
-rw-r--r-- | src/core/model/Document.hpp | 34 | ||||
-rw-r--r-- | src/core/model/Domain.cpp | 19 | ||||
-rw-r--r-- | src/core/model/Domain.hpp | 27 | ||||
-rw-r--r-- | src/core/model/Typesystem.cpp | 14 |
5 files changed, 37 insertions, 76 deletions
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<FieldDescriptor> &fds = - descriptor->getFieldDescriptors(); + const NodeVector<FieldDescriptor> &fds = descriptor->getFieldDescriptors(); unsigned int f = 0; // look if we have an empty name. @@ -71,8 +70,7 @@ void DocumentEntity::getField(NodeVector<StructuredEntity> &res, NodeVector<StructuredEntity> &DocumentEntity::getField( Rooted<FieldDescriptor> fieldDescriptor) { - const NodeVector<FieldDescriptor> &fds = - descriptor->getFieldDescriptors(); + const NodeVector<FieldDescriptor> &fds = descriptor->getFieldDescriptors(); int f = 0; for (auto &fd : fds) { if (fd->getName() == fieldDescriptor->getName() && @@ -187,6 +185,19 @@ Rooted<DocumentPrimitive> DocumentPrimitive::buildEntity( // and return it. return entity; } + +/* Type registrations */ + +const Rtti<Document> Document_Rtti{"Document"}; +const Rtti<DocumentEntity> DocumentEntity_Rtti{"DocumentEntity"}; +const Rtti<AnnotationEntity> AnnotationEntity_Rtti{"AnnotationEntity", + {&DocumentEntity_Rtti}}; +const Rtti<StructuredEntity> StructuredEntity_Rtti{"StructuredEntity", + {&DocumentEntity_Rtti}}; +const Rtti<DocumentPrimitive> DocumentPrimitive_Rtti{"DocumentPrimitive", + {&StructuredEntity_Rtti}}; +const Rtti<AnnotationEntity::Anchor> 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 @@ -188,11 +188,6 @@ public: }; /** - * 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. */ @@ -265,12 +260,6 @@ public: }; /** - * 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. * inside a paragraph. In that case this would represent a mere string. @@ -308,12 +297,6 @@ public: }; /** - * 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 * limits of StructureEntities. A typical example for AnnotationEntities are @@ -377,18 +360,6 @@ public: }; /** - * 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<StructuredEntity> 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<Rooted<Managed>> &res, } // TODO: better alias? -static std::string DESCRIPTOR_ATTRIBUTES_ALIAS {"attributes"}; +static std::string DESCRIPTOR_ATTRIBUTES_ALIAS{"attributes"}; void Descriptor::doResolve(std::vector<Rooted<Managed>> &res, const std::vector<std::string> &path, Filter filter, @@ -46,8 +46,9 @@ void Descriptor::doResolve(std::vector<Rooted<Managed>> &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<Rooted<Managed>> &res, @@ -56,7 +57,7 @@ void StructuredClass::doResolve(std::vector<Rooted<Managed>> &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<Rooted<Managed>> &res, t->resolve(res, path, filter, filterData, idx, visited, nullptr); } } + +/* Type registrations */ + +const Rtti<FieldDescriptor> FieldDescriptor_Rtti{"FieldDescriptor"}; +const Rtti<Descriptor> Descriptor_Rtti{"Descriptor"}; +const Rtti<StructuredClass> StructuredClass_Rtti{"StructuredClass", + {&Descriptor_Rtti}}; +const Rtti<AnnotationClass> AnnotationClass_Rtti{"AnnotationClass", + {&Descriptor_Rtti}}; +const Rtti<Domain> 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<Type> 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<size_t> Cardinality; /** @@ -405,12 +395,6 @@ public: }; /** - * 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. * @@ -420,12 +404,6 @@ 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 * are allowed globally. TODO: Do we want to be able to restrict Annotations to @@ -475,11 +453,6 @@ public: const NodeVector<Typesystem> &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> Type_T("Type"); -const Rtti<StringType> StringType_T("StringType", {&Type_T}); -const Rtti<IntType> IntType_T("IntType", {&Type_T}); -const Rtti<DoubleType> DoubleType_T("DoubleType", {&Type_T}); -const Rtti<BoolType> BoolType_T("BoolType", {&Type_T}); -const Rtti<EnumType> EnumType_T("EnumType", {&Type_T}); -const Rtti<StructType> StructType_T("StructType", {&Type_T}); +const Rtti<Type> Type_Rtti{"Type"}; +const Rtti<StringType> StringType_Rtti{"StringType", {&Type_Rtti}}; +const Rtti<IntType> IntType_Rtti{"IntType", {&Type_Rtti}}; +const Rtti<DoubleType> DoubleType_Rtti{"DoubleType", {&Type_Rtti}}; +const Rtti<BoolType> BoolType_Rtti{"BoolType", {&Type_Rtti}}; +const Rtti<EnumType> EnumType_Rtti{"EnumType", {&Type_Rtti}}; +const Rtti<StructType> StructType_Rtti{"StructType", {&Type_Rtti}}; } } |