From 496c4e527852d0fd64a24bd5ac2506e50ba0afc7 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 15 Jan 2015 12:13:18 +0100 Subject: supported more automatic registration behaviour, checked for internal name consistency regarding FieldDescriptors, AnnotationClasses and StructuredClasses and made adding methods for automatically registered references protected. --- test/core/model/TestAdvanced.hpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'test/core/model/TestAdvanced.hpp') diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 696fbed..15a4042 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -58,11 +58,9 @@ static Rooted constructHeadingDomain(Manager &mgr, // set up heading StructuredClass. Rooted heading{new StructuredClass( mgr, "heading", domain, card, {nullptr}, {nullptr}, true)}; - // as field we actually want to refer to the field of paragraph. + // as field want to copy the field of paragraph. Rooted p = resolveDescriptor(bookDomain, "paragraph"); - heading->addFieldDescriptor(p->getFieldDescriptors()[0]); - // add the class to the domain. - domain->addStructuredClass(heading); + heading->copyFieldDescriptor(p->getFieldDescriptors()[0]); // create a new field for headings in each section type. std::vector secclasses{"book", "section", "subsection", "paragraph"}; @@ -71,7 +69,6 @@ static Rooted constructHeadingDomain(Manager &mgr, Rooted heading_field{new FieldDescriptor( mgr, desc, FieldDescriptor::FieldType::SUBTREE, "heading")}; heading_field->addChild(heading); - desc->addFieldDescriptor(heading_field); } return domain; } @@ -94,9 +91,9 @@ static Rooted constructListDomain(Manager &mgr, // set up item StructuredClass; Rooted item{new StructuredClass( mgr, "item", domain, any, {nullptr}, {nullptr}, false)}; - domain->addStructuredClass(item); - // as field we actually want to refer to the field of paragraph. - item->addFieldDescriptor(p->getFieldDescriptors()[0]); + + // as field we want to copy the field of paragraph. + item->copyFieldDescriptor(p->getFieldDescriptors()[0]); // set up list StructuredClasses. std::vector listTypes{"ol", "ul"}; for (auto &listType : listTypes) { @@ -104,8 +101,6 @@ static Rooted constructListDomain(Manager &mgr, mgr, listType, domain, any, {nullptr}, p, false)}; Rooted list_field{new FieldDescriptor(mgr, list)}; list_field->addChild(item); - list->addFieldDescriptor(list_field); - domain->addStructuredClass(list); } return domain; } @@ -121,11 +116,11 @@ static Rooted constructEmphasisDomain(Manager &mgr, Rooted domain{new Domain(mgr, sys, "emphasis")}; // create AnnotationClasses Rooted em{ - new AnnotationClass(mgr, "emphasized", domain, {nullptr})}; - domain->addAnnotationClass(em); + new AnnotationClass(mgr, "emphasized", domain)}; + Rooted strong{ - new AnnotationClass(mgr, "strong", domain, {nullptr})}; - domain->addAnnotationClass(strong); + new AnnotationClass(mgr, "strong", domain)}; + return domain; } @@ -338,4 +333,3 @@ static Rooted constructAdvancedDocument(Manager &mgr, Logger &logger, } #endif /* _TEST_DOCUMENT_HPP_ */ - -- cgit v1.2.3