summaryrefslogtreecommitdiff
path: root/src/core/model/Document.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-17 15:26:24 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-17 15:26:24 +0100
commit8992dc8c4359964168da3e9221a31bfe9e4ffe8f (patch)
treef2176e0883c4b6ee814a96902d946979326296a6 /src/core/model/Document.cpp
parent33b5b737313e6d1409c60da77db26f1f00b91b57 (diff)
Improved validation system
Diffstat (limited to 'src/core/model/Document.cpp')
-rw-r--r--src/core/model/Document.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp
index 92791a4..0de750f 100644
--- a/src/core/model/Document.cpp
+++ b/src/core/model/Document.cpp
@@ -92,8 +92,7 @@ int DocumentEntity::getFieldDescriptorIndex(
}
}
-bool DocumentEntity::doValidate(Logger &logger,
- std::set<ManagedUid> &visited) const
+bool DocumentEntity::validate(Logger &logger) const
{
// TODO: check the validated form of Attributes
// iterate over every field
@@ -205,14 +204,7 @@ bool DocumentEntity::doValidate(Logger &logger,
// go into recursion.
for (auto &f : fields) {
for (auto &n : f) {
- if (!visited.insert(n->getUid()).second) {
- logger.error("The given document contains a cycle!");
- return false;
- }
- if (n->isValidated()) {
- continue;
- }
- if (!n->validate(logger, visited)) {
+ if (!n->validate(logger)) {
return false;
}
}
@@ -247,15 +239,14 @@ StructuredEntity::StructuredEntity(Manager &mgr, Handle<Document> doc,
doc->setRoot(this);
}
-bool StructuredEntity::doValidate(Logger &logger,
- std::set<ManagedUid> &visited) const
+bool StructuredEntity::doValidate(Logger &logger) const
{
// check if the parent is set.
if (getParent() == nullptr) {
return false;
}
// check the validity as a DocumentEntity.
- return DocumentEntity::doValidate(logger, visited);
+ return DocumentEntity::validate(logger);
}
/* Class AnnotationEntity */
@@ -272,8 +263,7 @@ AnnotationEntity::AnnotationEntity(Manager &mgr, Handle<Document> parent,
parent->annotations.push_back(this);
}
-bool AnnotationEntity::doValidate(Logger &logger,
- std::set<ManagedUid> &visited) const
+bool AnnotationEntity::doValidate(Logger &logger) const
{
// check if this AnnotationEntity is correctly registered at its document.
if (getParent() == nullptr || !getParent()->isa(RttiTypes::Document)) {
@@ -293,7 +283,7 @@ bool AnnotationEntity::doValidate(Logger &logger,
}
// check the validity as a DocumentEntity.
- if (!DocumentEntity::doValidate(logger, visited)) {
+ if (!DocumentEntity::validate(logger)) {
return false;
}
// TODO: then check if the anchors are in the correct document.