summaryrefslogtreecommitdiff
path: root/src/core/model/Document.cpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-23 00:40:51 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-23 00:40:51 +0100
commit78bdb210ad81edd0ba41a6adfc4797b1ccc62228 (patch)
tree6abf6b224f1a2d7c8a31894634d2f9f313997afd /src/core/model/Document.cpp
parent33008f1110523ae9c9b9e1d2ca24ed642637c40d (diff)
Added 'createChild'-style methods to Document and Domain classes.
Diffstat (limited to 'src/core/model/Document.cpp')
-rw-r--r--src/core/model/Document.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp
index 2ae9107..61c384d 100644
--- a/src/core/model/Document.cpp
+++ b/src/core/model/Document.cpp
@@ -383,8 +383,8 @@ void DocumentEntity::addStructureNodes(
}
}
-bool DocumentEntity::removeStructureNodeFromField(
- Handle<StructureNode> s, const std::string &fieldName)
+bool DocumentEntity::removeStructureNodeFromField(Handle<StructureNode> s,
+ const std::string &fieldName)
{
return removeStructureNodeFromField(
s, getFieldDescriptorIndex(fieldName, true));
@@ -428,6 +428,29 @@ bool DocumentEntity::removeStructureNode(Handle<StructureNode> s)
return false;
}
+Rooted<StructuredEntity> DocumentEntity::createChildStructuredEntity(
+ Handle<StructuredClass> descriptor, Variant attributes,
+ const std::string &fieldName, std::string name)
+{
+ return Rooted<StructuredEntity>{new StructuredEntity(
+ subInst->getManager(), subInst, descriptor, std::move(attributes),
+ fieldName, std::move(name))};
+}
+
+Rooted<DocumentPrimitive> DocumentEntity::createChildDocumentPrimitive(
+ Variant content, const std::string &fieldName)
+{
+ return Rooted<DocumentPrimitive>{new DocumentPrimitive(
+ subInst->getManager(), subInst, std::move(content), fieldName)};
+}
+
+Rooted<Anchor> DocumentEntity::createChildAnchor(std::string name,
+ const std::string &fieldName)
+{
+ return Rooted<Anchor>{
+ new Anchor(subInst->getManager(), std::move(name), subInst, fieldName)};
+}
+
/* Class StructureNode */
bool StructureNode::doValidate(Logger &logger) const
@@ -611,6 +634,14 @@ bool Document::doValidate(Logger &logger) const
return valid & continueValidation(annotations, logger);
}
+Rooted<StructuredEntity> Document::createRootStructuredEntity(
+ Handle<StructuredClass> descriptor, Variant attributes, std::string name)
+{
+ return Rooted<StructuredEntity>{
+ new StructuredEntity(getManager(), Handle<Document>{this}, descriptor,
+ attributes, std::move(name))};
+}
+
void Document::addAnnotation(Handle<AnnotationEntity> a)
{
// only add it if we need to.
@@ -635,8 +666,6 @@ void Document::addAnnotations(const std::vector<Handle<AnnotationEntity>> &as)
}
}
-
-
bool Document::removeAnnotation(Handle<AnnotationEntity> a)
{
auto it = annotations.find(a);
@@ -649,6 +678,15 @@ bool Document::removeAnnotation(Handle<AnnotationEntity> a)
return false;
}
+Rooted<AnnotationEntity> Document::createChildAnnotation(
+ Handle<AnnotationClass> descriptor, Handle<Anchor> start,
+ Handle<Anchor> end, Variant attributes, std::string name)
+{
+ return Rooted<AnnotationEntity>{
+ new AnnotationEntity(getManager(), this, descriptor, start, end,
+ attributes, std::move(name))};
+}
+
bool Document::hasChild(Handle<StructureNode> s) const
{
Rooted<Managed> parent = s->getParent();