summaryrefslogtreecommitdiff
path: root/src/core/model/Document.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-04-15 20:40:01 +0200
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2016-04-25 22:24:19 +0200
commit2a5b3632fb49452adb6ecedb9c678909341ef662 (patch)
tree3d54fc827e584194b36f889d789ba83261676647 /src/core/model/Document.cpp
parent1d0c7f590c8bd42d1daf81ec304b1cf013aa58f9 (diff)
Derive structure entities and annotation entities from common base class to allow resolution for both
Diffstat (limited to 'src/core/model/Document.cpp')
-rw-r--r--src/core/model/Document.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp
index 411a755..3a076c4 100644
--- a/src/core/model/Document.cpp
+++ b/src/core/model/Document.cpp
@@ -598,7 +598,7 @@ bool StructureNode::doValidate(Logger &logger) const
StructureNode::StructureNode(Manager &mgr, std::string name,
Handle<Node> parent, const std::string &fieldName)
- : Node(mgr, std::move(name), parent)
+ : DocumentNode(mgr, std::move(name), parent)
{
if (parent->isa(&RttiTypes::StructuredEntity)) {
parent.cast<StructuredEntity>()->addStructureNode(this, fieldName);
@@ -611,7 +611,7 @@ StructureNode::StructureNode(Manager &mgr, std::string name,
StructureNode::StructureNode(Manager &mgr, std::string name,
Handle<Node> parent, size_t fieldIdx)
- : Node(mgr, std::move(name), parent)
+ : DocumentNode(mgr, std::move(name), parent)
{
if (parent->isa(&RttiTypes::StructuredEntity)) {
parent.cast<StructuredEntity>()->addStructureNode(this, fieldIdx);
@@ -622,6 +622,12 @@ StructureNode::StructureNode(Manager &mgr, std::string name,
}
}
+StructureNode::StructureNode(Manager &mgr, std::string name,
+ Handle<Node> parent)
+ : DocumentNode(mgr, std::move(name), parent)
+{
+}
+
/* Class StructuredEntity */
StructuredEntity::StructuredEntity(Manager &mgr, Handle<Document> doc,
@@ -641,6 +647,13 @@ StructuredEntity::StructuredEntity(Manager &mgr, Handle<Node> parent,
{
}
+void StructuredEntity::doResolve(ResolutionState &state)
+{
+ for (const auto &field : getFields()) {
+ continueResolveComposita(field, field.getIndex(), state);
+ }
+}
+
bool StructuredEntity::doValidate(Logger &logger) const
{
bool valid = true;
@@ -732,7 +745,7 @@ AnnotationEntity::AnnotationEntity(Manager &mgr, Handle<Document> parent,
Handle<AnnotationClass> descriptor,
Handle<Anchor> start, Handle<Anchor> end,
Variant attributes, std::string name)
- : Node(mgr, std::move(name), parent),
+ : DocumentNode(mgr, std::move(name), parent),
DocumentEntity(this, descriptor, attributes)
{
if (parent != nullptr) {
@@ -742,6 +755,13 @@ AnnotationEntity::AnnotationEntity(Manager &mgr, Handle<Document> parent,
setEnd(end);
}
+void AnnotationEntity::doResolve(ResolutionState &state)
+{
+ for (const auto &field : getFields()) {
+ continueResolveComposita(field, field.getIndex(), state);
+ }
+}
+
bool AnnotationEntity::doValidate(Logger &logger) const
{
bool valid = true;
@@ -986,8 +1006,10 @@ namespace RttiTypes {
const Rtti Document = RttiBuilder<ousia::Document>("Document")
.parent(&RootNode)
.composedOf({&AnnotationEntity, &StructuredEntity});
+const Rtti DocumentNode =
+ RttiBuilder<ousia::DocumentNode>("DocumentNode").parent(&Node);
const Rtti StructureNode =
- RttiBuilder<ousia::StructureNode>("StructureNode").parent(&Node);
+ RttiBuilder<ousia::StructureNode>("StructureNode").parent(&DocumentNode);
const Rtti StructuredEntity =
RttiBuilder<ousia::StructuredEntity>("StructuredEntity")
.parent(&StructureNode)
@@ -997,7 +1019,7 @@ const Rtti DocumentPrimitive = RttiBuilder<ousia::DocumentPrimitive>(
const Rtti Anchor = RttiBuilder<ousia::Anchor>("Anchor").parent(&StructureNode);
const Rtti AnnotationEntity =
RttiBuilder<ousia::AnnotationEntity>("AnnotationEntity")
- .parent(&Node)
+ .parent(&DocumentNode)
.composedOf({&StructuredEntity, &DocumentPrimitive, &Anchor});
}
}