summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2014-12-21 15:13:37 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2014-12-21 15:13:37 +0100
commitf1bb76dedf2d6b480b566540e811a7e0d3af9886 (patch)
treec71e4e637ee8fab349d4368af84bf67922bb234a /src
parent54d66cfa220128ae6c7cd05aa5db3354e459105b (diff)
First draft of book domain example and slight changes to the book domain: _all_ structuredclasses are listed in the domain now and StructuredClasses that are allowed at the root level have a root flag.
Diffstat (limited to 'src')
-rw-r--r--src/core/model/Domain.cpp2
-rw-r--r--src/core/model/Domain.hpp55
2 files changed, 44 insertions, 13 deletions
diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp
index 77708e6..fafe090 100644
--- a/src/core/model/Domain.cpp
+++ b/src/core/model/Domain.cpp
@@ -68,7 +68,7 @@ void Domain::doResolve(std::vector<Rooted<Managed>> &res,
const std::vector<std::string> &path, Filter filter,
void *filterData, unsigned idx, VisitorSet &visited)
{
- for (auto &s : rootStructures) {
+ for (auto &s : structureClasses) {
s->resolve(res, path, filter, filterData, idx, visited, nullptr);
}
for (auto &a : annotationClasses) {
diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp
index c0946bf..e257c0d 100644
--- a/src/core/model/Domain.hpp
+++ b/src/core/model/Domain.hpp
@@ -212,7 +212,6 @@ public:
Rooted<Type> getPrimitiveType() const { return primitiveType; }
};
-
/**
* This is a super class for StructuredClasses and AnnotationClasses and is,
* in itself, not supposed to be instantiated. It defines that both, Annotations
@@ -369,18 +368,46 @@ protected:
public:
const bool transparent;
+ const bool root;
+ /**
+ * The constructor for a StructuredClass.
+ *
+ * @param mgr is the current Manager.
+ * @param name is the name of the StructuredClass.
+ * @param domain is the Domain this StructuredClass belongs
+ * to.
+ * @param cardinality specifies how often an element of this type
+ * may occur at a specific point in the
+ * StructureTree. For example: A document should
+ * have at least one author.
+ * @param attributesDescriptor references a StructType that in turn
+ * specifies which key-value pairs are permitted
+ * as attributes for this StructuredClass. The
+ * default value is a null-reference, meaning
+ * that no attributes are permitted.
+ * @param isa references a parent StructuredClass. Please
+ * look for more information on inheritance in
+ * the class documentation above. The default is
+ * a null reference, meaning no parent class.
+ * @param transparent specifies whether this StructuredClass is
+ * transparent. For more information on
+ * transparency please refer to the class
+ * documentation above. The default is false.
+ */
StructuredClass(Manager &mgr, std::string name, Handle<Domain> domain,
const Cardinality &cardinality,
Handle<StructType> attributesDescriptor = {nullptr},
// TODO: What would be a wise default value for isa?
Handle<StructuredClass> isa = {nullptr},
- bool transparent = false)
+ bool transparent = false,
+ bool root = false)
: Descriptor(mgr, std::move(name), domain, attributesDescriptor),
cardinality(cardinality),
isa(acquire(isa)),
parents(this),
- transparent(transparent)
+ transparent(transparent),
+ root(root)
{
}
@@ -404,15 +431,16 @@ class AnnotationClass : public Descriptor {
};
/**
- * A Domain node specifies which StructuredClasses are allowed at the root
- * level (or which Nonterminals are axioms of the grammar) and which Annotations
- * are allowed globally. TODO: Do we want to be able to restrict Annotations to
- * certain Structures?
+ * A Domain node specifies which StructuredClasses and which AnnotationClasses
+ * are part of this domain. TODO: Do we want to be able to restrict Annotations
+ * to certain Structures?
*/
class Domain : public Node {
private:
- NodeVector<StructuredClass> rootStructures;
+ NodeVector<StructuredClass> structureClasses;
NodeVector<AnnotationClass> annotationClasses;
+ // TODO: Is it wise to attach the type systems here? If not: What would be
+ // a good alternative.
NodeVector<Typesystem> typesystems;
protected:
@@ -425,18 +453,21 @@ public:
Domain(Manager &mgr, std::string name)
// TODO: Can a domain have a parent?
: Node(mgr, std::move(name), nullptr),
- rootStructures(this),
+ structureClasses(this),
annotationClasses(this),
typesystems(this)
{
}
// TODO: Is returning a NodeVector alright?
- NodeVector<StructuredClass> &getRootStructures() { return rootStructures; }
+ NodeVector<StructuredClass> &getStructureClasses()
+ {
+ return structureClasses;
+ }
- const NodeVector<StructuredClass> &getRootStructures() const
+ const NodeVector<StructuredClass> &getStructureClasses() const
{
- return rootStructures;
+ return structureClasses;
}
NodeVector<AnnotationClass> &getAnnotationClasses()