diff options
-rw-r--r-- | src/core/model/Document.cpp | 7 | ||||
-rw-r--r-- | src/core/model/Domain.cpp | 6 | ||||
-rw-r--r-- | src/core/model/Domain.hpp | 4 | ||||
-rw-r--r-- | test/core/model/DocumentTest.cpp | 3 | ||||
-rw-r--r-- | test/core/model/DomainTest.cpp | 3 | ||||
-rw-r--r-- | test/core/model/TestDomain.hpp | 30 | ||||
-rw-r--r-- | 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> DocumentPrimitive::buildEntity( } namespace RttiTypes { -const Rtti<model::Document> Document{"Document", - std::unordered_set<const RttiBase *>{}, - {&AnnotationEntity, &StructuredEntity}}; -const Rtti<model::DocumentEntity> DocumentEntity{"DocumentEntity"}; +const Rtti<model::Document> Document{ + "Document", {&Node}, {&AnnotationEntity, &StructuredEntity}}; +const Rtti<model::DocumentEntity> DocumentEntity{"DocumentEntity", {&Node}}; const Rtti<model::AnnotationEntity> AnnotationEntity{ "AnnotationEntity", {&DocumentEntity}, {&StructuredEntity}}; const Rtti<model::StructuredEntity> 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<Rooted<Managed>> &res, /* Type registrations */ namespace RttiTypes { -const Rtti<model::FieldDescriptor> FieldDescriptor{"FieldDescriptor"}; -const Rtti<model::Descriptor> Descriptor{"Descriptor"}; +const Rtti<model::FieldDescriptor> FieldDescriptor{"FieldDescriptor", {&Node}}; +const Rtti<model::Descriptor> Descriptor{"Descriptor", {&Node}}; const Rtti<model::StructuredClass> StructuredClass{ "StructuredClass", {&Descriptor}, {&FieldDescriptor}}; const Rtti<model::AnnotationClass> AnnotationClass{"AnnotationClass", {&Descriptor}}; const Rtti<model::Domain> Domain{ - "Domain", std::unordered_set<const RttiBase*>{}, {&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<SystemTypesystem> 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<Handle<Typesystem>>{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<SystemTypesystem> sys{new SystemTypesystem(mgr)}; // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, logger); + Rooted<Domain> domain = constructBookDomain(mgr, sys, logger); // Construct the document. Rooted<Document> 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<SystemTypesystem> sys{new SystemTypesystem(mgr)}; // Get the domain. - Rooted<Domain> domain = constructBookDomain(mgr, logger); + Rooted<Domain> 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 @@ -26,32 +26,15 @@ namespace ousia { namespace model { /** - * This constructs a somewhat trivial system of standard types. - * - * Currently contained: string, text (struct wrapper for string) - */ -static Rooted<Typesystem> constructTypeSystem(Manager &mgr, Logger &logger) -{ - Rooted<Typesystem> sys{new Typesystem(mgr, "std")}; - Rooted<StringType> string{new StringType(mgr, sys)}; - sys->addType(string); - Rooted<StructType> 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<Domain> constructBookDomain(Manager &mgr, Logger &logger) +static Rooted<Domain> constructBookDomain(Manager &mgr, + Handle<SystemTypesystem> sys, + Logger &logger) { // Start with the Domain itself. - Rooted<Domain> domain{new Domain(mgr, "book")}; - // The standard type system. - domain->getTypesystems().push_back(constructTypeSystem(mgr, logger)); + Rooted<Domain> domain{new Domain(mgr, sys, "book")}; // Set up the cardinalities we'll need. Cardinality single; single.merge({1}); @@ -82,9 +65,10 @@ static Rooted<Domain> constructBookDomain(Manager &mgr, Logger &logger) book_field->getChildren().push_back(paragraph); domain->getStructureClasses().push_back(paragraph); // And the field of it. - Rooted<FieldDescriptor> paragraph_field{new FieldDescriptor(mgr, paragraph)}; + Rooted<FieldDescriptor> paragraph_field{ + new FieldDescriptor(mgr, paragraph)}; paragraph->getFieldDescriptors().push_back(paragraph_field); - + // Finally we add the "text" node, which is transparent as well. Rooted<StructuredClass> 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<model::SystemTypesystem> sys{new model::SystemTypesystem(mgr)}; // Get the domain. - Rooted<model::Domain> domain = model::constructBookDomain(mgr, logger); + Rooted<model::Domain> domain = constructBookDomain(mgr, sys, logger); // Construct the document. Rooted<model::Document> doc = model::constructBookDocument(mgr, domain); |