summaryrefslogtreecommitdiff
path: root/src/core/model/Document.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-12 19:47:43 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-12 19:47:43 +0100
commitfa387f9bef0d1a70a4b40c28c5cf9d661c421f73 (patch)
treec1857d0d7fc0a8db8c1f3a841913b1f496d8e661 /src/core/model/Document.hpp
parent2b15fcab4b81fa8a854e724c48ee9c771fb126f8 (diff)
parent55f943ba1b31542157b984b5955b91261c280f46 (diff)
Merge branch 'master' of somweyr.de:ousia
Conflicts: application/src/core/model/Document.hpp
Diffstat (limited to 'src/core/model/Document.hpp')
-rw-r--r--src/core/model/Document.hpp72
1 files changed, 47 insertions, 25 deletions
diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp
index 7f365b7..d22196a 100644
--- a/src/core/model/Document.hpp
+++ b/src/core/model/Document.hpp
@@ -138,7 +138,7 @@ class StructureNode;
* name.
*
*/
-class DocumentEntity : public virtual Node {
+class DocumentEntity {
private:
Owned<Descriptor> descriptor;
const Variant attributes;
@@ -151,11 +151,22 @@ private:
bool enforce) const;
public:
- DocumentEntity(Manager &mgr, Handle<Node> parent,
- Handle<Descriptor> descriptor, Variant attributes = {},
- std::string name = "")
- : Node(mgr, std::move(name), parent),
- descriptor(acquire(descriptor)),
+ /**
+ * The constructor for a DocumentEntity. Node that this does not inherit
+ * from Node. Therefore we need to have a handle to the child Node instance
+ * to create NodeVectors and Owned references.
+ *
+ * @param owner is a handle to the child instance
+ * (e.g. StructuredEntity), such that the fields vectors
+ * and the descriptor reference can be obtained.
+ * @param descriptor is the Descriptor for this DocumentEntity, which will
+ * transformed to an Owned reference of the given owner.
+ * @param attributes is a Map Variant adhering to the attribute StructType
+ * in the given descriptor.
+ */
+ DocumentEntity(Handle<Node> owner, Handle<Descriptor> descriptor,
+ Variant attributes = {})
+ : descriptor(owner->acquire(descriptor)),
attributes(std::move(attributes))
{
// TODO: Validation at construction time?
@@ -163,13 +174,27 @@ public:
if (!descriptor.isNull()) {
for (size_t f = 0; f < descriptor->getFieldDescriptors().size();
f++) {
- fields.push_back(NodeVector<StructureNode>(this));
+ fields.push_back(NodeVector<StructureNode>(owner));
}
}
}
+ virtual ~DocumentEntity(){};
+
+ /**
+ * Returns the Descriptor for this DocumentEntity.
+ *
+ * @return the Descriptor for this DocumentEntity.
+ */
Rooted<Descriptor> getDescriptor() const { return descriptor; }
+ /**
+ * Returns a Map Variant adhering to the attribute StructType in the given
+ * descriptor.
+ *
+ * @return a Map Variant adhering to the attribute StructType in the given
+ * descriptor.
+ */
Variant getAttributes() const { return attributes; }
/**
@@ -303,7 +328,7 @@ public:
* A StructureNode is a Node of the StructureTree of the document. This is a
* common superclass for StructuredEntity, Anchor and DocumentPrimitive.
*/
-class StructureNode : public virtual Node {
+class StructureNode : public Node {
public:
StructureNode(Manager &mgr, std::string name, Handle<Node> parent)
: Node(mgr, std::move(name), parent)
@@ -315,15 +340,13 @@ public:
* A StructuredEntity is an instance of a StructuredClass. For more
* information please refer to the header documentation above.
*/
-class StructuredEntity : public DocumentEntity, public StructureNode {
+class StructuredEntity : public StructureNode, public DocumentEntity {
public:
StructuredEntity(Manager &mgr, Handle<Node> parent,
Handle<StructuredClass> descriptor, Variant attributes,
std::string name = "")
- : Node(mgr, std::move(name), parent),
- DocumentEntity(mgr, parent, descriptor, std::move(attributes),
- std::move(name)),
- StructureNode(mgr, std::move(name), parent)
+ : StructureNode(mgr, std::move(name), parent),
+ DocumentEntity(this, descriptor, std::move(attributes))
{
}
};
@@ -338,17 +361,17 @@ private:
Variant content;
public:
- DocumentPrimitive(Manager &mgr, Handle<DocumentEntity> parent,
- Variant content = {})
- : Node(mgr, parent),
- StructureNode(mgr, "", parent),
- content(content)
+ DocumentPrimitive(Manager &mgr, Handle<Node> parent, Variant content = {})
+ : StructureNode(mgr, "", parent), content(content)
{
}
+ /**
+ * Returns the content of this DocumentPrimitive.
+ *
+ * @return the content of this DocumentPrimitive.
+ */
Variant getContent() const { return content; }
-
- // TODO: Override such methods like "getField" to disable them?
};
/**
@@ -371,7 +394,7 @@ public:
* the two text exerpts "emphasized" and "and" separately.
*
*/
-class AnnotationEntity : public DocumentEntity {
+class AnnotationEntity : public Node, public DocumentEntity {
public:
/**
* An Anchor is an elementary StructuredEntity without any children that
@@ -387,9 +410,8 @@ public:
* not the AnnotationEntity that references this Anchor.
* @param name is the Anchor id.
*/
- Anchor(Manager &mgr, std::string name, Handle<DocumentEntity> parent)
- : Node(mgr, std::move(name), parent),
- StructureNode(mgr, std::move(name), parent)
+ Anchor(Manager &mgr, std::string name, Handle<Node> parent)
+ : StructureNode(mgr, std::move(name), parent)
{
}
};
@@ -419,7 +441,7 @@ public:
Handle<Anchor> end, Variant attributes = {},
std::string name = "")
: Node(mgr, std::move(name), parent),
- DocumentEntity(mgr, parent, descriptor, attributes, std::move(name)),
+ DocumentEntity(this, descriptor, attributes),
start(acquire(start)),
end(acquire(end))
{