From 15dd9d1aa1e0cfe8b31364fb42985ee8d5c5fc9d Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Mon, 5 Jan 2015 15:05:28 +0100 Subject: corrected RTTI for domain und document and added a reference to system type system in test domain. --- src/core/model/Document.cpp | 7 +++---- src/core/model/Domain.cpp | 6 +++--- src/core/model/Domain.hpp | 4 ++-- test/core/model/DocumentTest.cpp | 3 ++- test/core/model/DomainTest.cpp | 3 ++- test/core/model/TestDomain.hpp | 30 +++++++----------------------- test/plugins/html/DemoOutputTest.cpp | 3 ++- 7 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index c09532c..b700ba4 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -191,10 +191,9 @@ Rooted DocumentPrimitive::buildEntity( } namespace RttiTypes { -const Rtti Document{"Document", - std::unordered_set{}, - {&AnnotationEntity, &StructuredEntity}}; -const Rtti DocumentEntity{"DocumentEntity"}; +const Rtti Document{ + "Document", {&Node}, {&AnnotationEntity, &StructuredEntity}}; +const Rtti DocumentEntity{"DocumentEntity", {&Node}}; const Rtti AnnotationEntity{ "AnnotationEntity", {&DocumentEntity}, {&StructuredEntity}}; const Rtti StructuredEntity{ diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index 41f2b76..f9e2a55 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -82,14 +82,14 @@ void Domain::doResolve(std::vector> &res, /* Type registrations */ namespace RttiTypes { -const Rtti FieldDescriptor{"FieldDescriptor"}; -const Rtti Descriptor{"Descriptor"}; +const Rtti FieldDescriptor{"FieldDescriptor", {&Node}}; +const Rtti Descriptor{"Descriptor", {&Node}}; const Rtti StructuredClass{ "StructuredClass", {&Descriptor}, {&FieldDescriptor}}; const Rtti AnnotationClass{"AnnotationClass", {&Descriptor}}; const Rtti Domain{ - "Domain", std::unordered_set{}, {&StructuredClass, &AnnotationClass}}; + "Domain", {&Node}, {&StructuredClass, &AnnotationClass}}; } } diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index 7e4e9f7..6995d14 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -559,12 +559,12 @@ protected: VisitorSet &visited) override; public: - Domain(Manager &mgr, std::string name) + Domain(Manager &mgr, Handle sys, std::string name) // TODO: Can a domain have a parent? : Node(mgr, std::move(name), nullptr), structureClasses(this), annotationClasses(this), - typesystems(this) + typesystems(this, std::vector>{sys}) { } diff --git a/test/core/model/DocumentTest.cpp b/test/core/model/DocumentTest.cpp index a671d2c..c86b285 100644 --- a/test/core/model/DocumentTest.cpp +++ b/test/core/model/DocumentTest.cpp @@ -32,8 +32,9 @@ TEST(Document, testDocumentConstruction) // Construct Manager Logger logger; Manager mgr{1}; + Rooted sys{new SystemTypesystem(mgr)}; // Get the domain. - Rooted domain = constructBookDomain(mgr, logger); + Rooted domain = constructBookDomain(mgr, sys, logger); // Construct the document. Rooted doc = constructBookDocument(mgr, domain); diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp index d8ad882..f937842 100644 --- a/test/core/model/DomainTest.cpp +++ b/test/core/model/DomainTest.cpp @@ -48,8 +48,9 @@ TEST(Domain, testDomainResolving) // Construct Manager Logger logger; Manager mgr{1}; + Rooted sys{new SystemTypesystem(mgr)}; // Get the domain. - Rooted domain = constructBookDomain(mgr, logger); + Rooted domain = constructBookDomain(mgr, sys, logger); /* * Start with the "book" search keyword. This should resolve to the domain diff --git a/test/core/model/TestDomain.hpp b/test/core/model/TestDomain.hpp index f457531..54e79ee 100644 --- a/test/core/model/TestDomain.hpp +++ b/test/core/model/TestDomain.hpp @@ -25,33 +25,16 @@ namespace ousia { namespace model { -/** - * This constructs a somewhat trivial system of standard types. - * - * Currently contained: string, text (struct wrapper for string) - */ -static Rooted constructTypeSystem(Manager &mgr, Logger &logger) -{ - Rooted sys{new Typesystem(mgr, "std")}; - Rooted string{new StringType(mgr, sys)}; - sys->addType(string); - Rooted string_struct{StructType::createValidated( - mgr, "text", sys, nullptr, {new Attribute(mgr, "content", string, "", false)}, logger)}; - sys->addType(string_struct); - - return sys; -} - /** * This constructs the "book" domain for test purposes. The structure of the * domain is fairly simple and can be seen from the construction itself. */ -static Rooted constructBookDomain(Manager &mgr, Logger &logger) +static Rooted constructBookDomain(Manager &mgr, + Handle sys, + Logger &logger) { // Start with the Domain itself. - Rooted domain{new Domain(mgr, "book")}; - // The standard type system. - domain->getTypesystems().push_back(constructTypeSystem(mgr, logger)); + Rooted domain{new Domain(mgr, sys, "book")}; // Set up the cardinalities we'll need. Cardinality single; single.merge({1}); @@ -82,9 +65,10 @@ static Rooted constructBookDomain(Manager &mgr, Logger &logger) book_field->getChildren().push_back(paragraph); domain->getStructureClasses().push_back(paragraph); // And the field of it. - Rooted paragraph_field{new FieldDescriptor(mgr, paragraph)}; + Rooted paragraph_field{ + new FieldDescriptor(mgr, paragraph)}; paragraph->getFieldDescriptors().push_back(paragraph_field); - + // Finally we add the "text" node, which is transparent as well. Rooted text{new StructuredClass( mgr, "text", domain, any, {nullptr}, {nullptr}, true)}; diff --git a/test/plugins/html/DemoOutputTest.cpp b/test/plugins/html/DemoOutputTest.cpp index 2db4012..6123c79 100644 --- a/test/plugins/html/DemoOutputTest.cpp +++ b/test/plugins/html/DemoOutputTest.cpp @@ -36,8 +36,9 @@ TEST(DemoHTMLTransformer, writeHTML) // Construct Manager Logger logger; Manager mgr{1}; + Rooted sys{new model::SystemTypesystem(mgr)}; // Get the domain. - Rooted domain = model::constructBookDomain(mgr, logger); + Rooted domain = constructBookDomain(mgr, sys, logger); // Construct the document. Rooted doc = model::constructBookDocument(mgr, domain); -- cgit v1.2.3