summaryrefslogtreecommitdiff
path: root/src/core/model/Domain.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-12-19 15:36:41 +0100
committerAndreas Stöckel <andreas@somweyr.de>2014-12-19 15:36:41 +0100
commit2eda4f5ba1e3ed0577e3804110debf102abc9d43 (patch)
treef7f823e10d32ebc96aba8d9014a148bd6a6d3a9b /src/core/model/Domain.hpp
parent6fa81636f088654f154534fd939421a5b25d9c5c (diff)
parent3654efa59547d23b3c27715483999570daedc0b3 (diff)
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core/model/Domain.hpp')
-rw-r--r--src/core/model/Domain.hpp112
1 files changed, 78 insertions, 34 deletions
diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp
index 50c0bb1..112f2fa 100644
--- a/src/core/model/Domain.hpp
+++ b/src/core/model/Domain.hpp
@@ -84,14 +84,16 @@
#include <core/managed/ManagedContainer.hpp>
#include <core/Node.hpp>
+#include <core/RangeSet.hpp>
#include "Typesystem.hpp"
namespace ousia {
namespace model {
-class StructuredClass;
class Descriptor;
+class StructuredClass;
+class Domain;
/**
* As mentioned in the description above a FieldDescriptor specifies the
@@ -137,6 +139,12 @@ private:
FieldType fieldType;
Owned<Type> primitiveType;
+protected:
+ void doResolve(std::vector<Rooted<Managed>> &res,
+ const std::vector<std::string> &path, Filter filter,
+ void *filterData, unsigned idx,
+ VisitorSet &visited) override;
+
public:
const bool optional;
@@ -146,17 +154,18 @@ public:
* set to "PRIMITIVE".
*
* @param mgr is the global Manager instance.
- * @param name is the name of this field.
* @param parent is a handle of the Descriptor node that has this
* FieldDescriptor.
* @param primitiveType is a handle to some Type in some Typesystem of which
* one instance is allowed to fill this field.
+ * @param name is the name of this field.
* @param optional should be set to 'false' is this field needs to be
* filled in order for an instance of the parent
* Descriptor to be valid.
*/
- FieldDescriptor(Manager &mgr, std::string name, Handle<Descriptor> parent,
- Handle<Type> primitiveType, bool optional)
+ FieldDescriptor(Manager &mgr, Handle<Descriptor> parent,
+ Handle<Type> primitiveType, std::string name = "",
+ bool optional = false)
: Node(mgr, std::move(name), parent),
children(this),
fieldType(FieldType::PRIMITIVE),
@@ -170,21 +179,21 @@ public:
* children here.
*
* @param mgr is the global Manager instance.
- * @param name is the name of this field.
* @param parent is a handle of the Descriptor node that has this
* FieldDescriptor.
* @param fieldType is the FieldType of this FieldDescriptor, either
* TREE for the main or default structure or SUBTREE
* for supporting structures.
+ * @param name is the name of this field.
* @param optional should be set to 'false' is this field needs to be
* filled in order for an instance of the parent
* Descriptor to be valid.
*/
- FieldDescriptor(Manager &mgr, std::string name, Handle<Descriptor> parent,
- FieldType fieldType,
- ManagedVector<StructuredClass> children, bool optional)
+ FieldDescriptor(Manager &mgr, Handle<Descriptor> parent,
+ FieldType fieldType = FieldType::TREE,
+ std::string name = "", bool optional = false)
: 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 +203,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; }
@@ -212,7 +226,7 @@ public:
* the attribute specification of a descriptor is done by referencing an
* appropriate StructType that contains all permitted keys and value types.
*
- * TODO: What aout optional attributes?
+ * TODO: What about optional attributes?
*
* In XML terms the difference between primitive fields and attributes can be
* explained as the difference between node attributes and node children.
@@ -233,14 +247,19 @@ private:
Owned<StructType> attributesDescriptor;
ManagedVector<FieldDescriptor> fieldDescriptors;
+protected:
+ void doResolve(std::vector<Rooted<Managed>> &res,
+ const std::vector<std::string> &path, Filter filter,
+ void *filterData, unsigned idx,
+ VisitorSet &visited) override;
+
public:
- Descriptor(Manager &mgr, std::string name, Handle<Node> parent,
+ Descriptor(Manager &mgr, std::string name, Handle<Domain> domain,
// TODO: What would be a wise default value for attributes?
- Handle<StructType> attributesDescriptor,
- ManagedVector<FieldDescriptor> fieldDescriptors)
- : Node(mgr, std::move(name), parent),
+ Handle<StructType> attributesDescriptor)
+ : Node(mgr, std::move(name), domain),
attributesDescriptor(acquire(attributesDescriptor)),
- fieldDescriptors(fieldDescriptors)
+ fieldDescriptors(this)
{
}
@@ -261,9 +280,7 @@ public:
}
};
-// TODO: Implement
-class Cardinality {
-};
+typedef RangeSet<size_t> Cardinality;
/**
* A StructuredClass specifies nodes in the StructureTree of a document that
@@ -346,21 +363,25 @@ private:
Owned<StructuredClass> isa;
ManagedVector<FieldDescriptor> parents;
+protected:
+ void doResolve(std::vector<Rooted<Managed>> &res,
+ const std::vector<std::string> &path, Filter filter,
+ void *filterData, unsigned idx,
+ VisitorSet &visited) override;
+
public:
const bool transparent;
- StructuredClass(Manager &mgr, std::string name, Handle<Node> parent,
- Handle<StructType> attributesDescriptor,
- ManagedVector<FieldDescriptor> fieldDescriptors,
+ 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,
- ManagedVector<FieldDescriptor> parents, bool transparent)
- : Descriptor(mgr, std::move(name), parent, attributesDescriptor,
- fieldDescriptors),
+ Handle<StructuredClass> isa = {nullptr},
+ bool transparent = false)
+ : Descriptor(mgr, std::move(name), domain, attributesDescriptor),
cardinality(cardinality),
isa(acquire(isa)),
- parents(parents),
+ parents(this),
transparent(transparent)
{
}
@@ -370,7 +391,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; }
};
@@ -394,28 +415,51 @@ class Domain : public Node {
private:
ManagedVector<StructuredClass> rootStructures;
ManagedVector<AnnotationClass> annotationClasses;
+ ManagedVector<Typesystem> typesystems;
+
+protected:
+ void doResolve(std::vector<Rooted<Managed>> &res,
+ const std::vector<std::string> &path, Filter filter,
+ void *filterData, unsigned idx,
+ VisitorSet &visited) override;
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),
+ typesystems(this)
{
}
// TODO: Is returning a ManagedVector alright?
- ManagedVector<StructuredClass> getRootStructures()
+ ManagedVector<StructuredClass> &getRootStructures()
{
return rootStructures;
}
- ManagedVector<AnnotationClass> getAnnotationClasses()
+ const ManagedVector<StructuredClass> &getRootStructures() const
+ {
+ return rootStructures;
+ }
+
+ ManagedVector<AnnotationClass> &getAnnotationClasses()
+ {
+ return annotationClasses;
+ }
+
+ const ManagedVector<AnnotationClass> &getAnnotationClasses() const
{
return annotationClasses;
}
+
+ ManagedVector<Typesystem> &getTypesystems() { return typesystems; }
+
+ const ManagedVector<Typesystem> &getTypesystems() const
+ {
+ return typesystems;
+ }
};
}
}