summaryrefslogtreecommitdiff
path: root/src/core/model/Domain.hpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2014-12-17 11:44:36 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2014-12-17 11:44:36 +0100
commit6dd18a83a1f2c89c5bca435090c80d72cb8716e3 (patch)
tree7d982490cc45f9ef6f383850a71fa3ceb1ff3650 /src/core/model/Domain.hpp
parentf1d768733c8b9166bbfb6943567b01b9d6fbcb15 (diff)
First draft of Cardinality. There are still semantic improvements to be made, though.
Diffstat (limited to 'src/core/model/Domain.hpp')
-rw-r--r--src/core/model/Domain.hpp55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp
index 50c0bb1..65b9b1d 100644
--- a/src/core/model/Domain.hpp
+++ b/src/core/model/Domain.hpp
@@ -85,6 +85,7 @@
#include <core/managed/ManagedContainer.hpp>
#include <core/Node.hpp>
+#include "Cardinality.hpp"
#include "Typesystem.hpp"
namespace ousia {
@@ -181,10 +182,9 @@ public:
* Descriptor to be valid.
*/
FieldDescriptor(Manager &mgr, std::string name, Handle<Descriptor> parent,
- FieldType fieldType,
- ManagedVector<StructuredClass> children, bool optional)
+ FieldType fieldType, bool optional)
: Node(mgr, std::move(name), parent),
- children(children),
+ children(this),
fieldType(fieldType),
// TODO: What would be a wise initialization of the primitiveType?
optional(optional)
@@ -194,6 +194,11 @@ public:
// TODO: Is returning a ManagedVector alright?
ManagedVector<StructuredClass> &getChildren() { return children; }
+ const ManagedVector<StructuredClass> &getChildren() const
+ {
+ return children;
+ }
+
FieldType getFieldType() const { return fieldType; }
bool isPrimitive() const { return fieldType == FieldType::PRIMITIVE; }
@@ -236,11 +241,10 @@ private:
public:
Descriptor(Manager &mgr, std::string name, Handle<Node> parent,
// TODO: What would be a wise default value for attributes?
- Handle<StructType> attributesDescriptor,
- ManagedVector<FieldDescriptor> fieldDescriptors)
+ Handle<StructType> attributesDescriptor)
: Node(mgr, std::move(name), parent),
attributesDescriptor(acquire(attributesDescriptor)),
- fieldDescriptors(fieldDescriptors)
+ fieldDescriptors(this)
{
}
@@ -261,10 +265,6 @@ public:
}
};
-// TODO: Implement
-class Cardinality {
-};
-
/**
* A StructuredClass specifies nodes in the StructureTree of a document that
* implements this domain. For more information on the StructureTree please
@@ -342,7 +342,7 @@ class Cardinality {
*/
class StructuredClass : public Descriptor {
private:
- const Cardinality cardinality;
+ const Cardinality& cardinality;
Owned<StructuredClass> isa;
ManagedVector<FieldDescriptor> parents;
@@ -351,16 +351,13 @@ public:
StructuredClass(Manager &mgr, std::string name, Handle<Node> parent,
Handle<StructType> attributesDescriptor,
- ManagedVector<FieldDescriptor> fieldDescriptors,
const Cardinality &cardinality,
// TODO: What would be a wise default value for isa?
- Handle<StructuredClass> isa,
- ManagedVector<FieldDescriptor> parents, bool transparent)
- : Descriptor(mgr, std::move(name), parent, attributesDescriptor,
- fieldDescriptors),
+ Handle<StructuredClass> isa, bool transparent)
+ : Descriptor(mgr, std::move(name), parent, attributesDescriptor),
cardinality(cardinality),
isa(acquire(isa)),
- parents(parents),
+ parents(this),
transparent(transparent)
{
}
@@ -370,7 +367,7 @@ public:
Rooted<StructuredClass> getIsA() const { return isa; }
// TODO: Is returning a ManagedVector alright?
- ManagedVector<FieldDescriptor>& getParents() { return parents; }
+ ManagedVector<FieldDescriptor> &getParents() { return parents; }
const ManagedVector<FieldDescriptor> &getParents() const { return parents; }
};
@@ -396,23 +393,31 @@ private:
ManagedVector<AnnotationClass> annotationClasses;
public:
- Domain(Manager &mgr, std::string name,
- ManagedVector<StructuredClass> rootStructures,
- ManagedVector<AnnotationClass> annotationClasses)
+ Domain(Manager &mgr, std::string name)
// TODO: Can a domain have a parent?
: Node(mgr, std::move(name), nullptr),
- rootStructures(rootStructures),
- annotationClasses(annotationClasses)
+ rootStructures(this),
+ annotationClasses(this)
{
}
// TODO: Is returning a ManagedVector alright?
- ManagedVector<StructuredClass> getRootStructures()
+ ManagedVector<StructuredClass> &getRootStructures()
+ {
+ return rootStructures;
+ }
+
+ const ManagedVector<StructuredClass> &getRootStructures() const
{
return rootStructures;
}
- ManagedVector<AnnotationClass> getAnnotationClasses()
+ ManagedVector<AnnotationClass> &getAnnotationClasses()
+ {
+ return annotationClasses;
+ }
+
+ const ManagedVector<AnnotationClass> &getAnnotationClasses() const
{
return annotationClasses;
}