summaryrefslogtreecommitdiff
path: root/src/core/model/Domain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/model/Domain.cpp')
-rw-r--r--src/core/model/Domain.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp
index 516bdde..360aa83 100644
--- a/src/core/model/Domain.cpp
+++ b/src/core/model/Domain.cpp
@@ -59,10 +59,10 @@ bool FieldDescriptor::doValidate(Logger &logger) const
bool valid = true;
// check parent type
if (getParent() == nullptr) {
- logger.error("This field has no parent!");
+ logger.error("This field has no parent!", *this);
valid = false;
} else if (!getParent()->isa(RttiTypes::Descriptor)) {
- logger.error("The parent of this field is not a descriptor!");
+ logger.error("The parent of this field is not a descriptor!", *this);
valid = false;
}
// check name
@@ -74,20 +74,20 @@ bool FieldDescriptor::doValidate(Logger &logger) const
if (children.size() > 0) {
logger.error(
"This field is supposed to be primitive but has "
- "registered child classes!");
+ "registered child classes!", *this);
valid = false;
}
if (primitiveType == nullptr) {
logger.error(
"This field is supposed to be primitive but has "
- "no primitive type!");
+ "no primitive type!", *this);
valid = false;
}
} else {
if (primitiveType != nullptr) {
logger.error(
"This field is supposed to be non-primitive but has "
- "a primitive type!");
+ "a primitive type!", *this);
valid = false;
}
}
@@ -101,7 +101,7 @@ bool FieldDescriptor::doValidate(Logger &logger) const
if (!names.insert(c->getName()).second) {
logger.error(std::string("Field \"") + getName() +
"\" had multiple children with the name \"" +
- c->getName() + "\"");
+ c->getName() + "\"", *this);
valid = false;
}
}
@@ -138,15 +138,15 @@ bool Descriptor::doValidate(Logger &logger) const
bool valid = true;
// check parent type
if (getParent() == nullptr) {
- logger.error("This Descriptor has no parent!");
+ logger.error("This Descriptor has no parent!", *this);
valid = false;
} else if (!getParent()->isa(RttiTypes::Domain)) {
- logger.error("The parent of this Descriptor is not a Domain!");
+ logger.error("The parent of this Descriptor is not a Domain!", *this);
valid = false;
}
// check name
if (getName().empty()) {
- logger.error("The name of this Descriptor is empty!");
+ logger.error("The name of this Descriptor is empty!", *this);
valid = false;
} else {
valid = valid & validateName(logger);
@@ -159,7 +159,7 @@ bool Descriptor::doValidate(Logger &logger) const
"field \"" +
fd->getName() +
"\" as child but the field does not "
- "have the Descriptor as parent.");
+ "have the Descriptor as parent.", *this);
valid = false;
}
}
@@ -305,13 +305,12 @@ Rooted<FieldDescriptor> Descriptor::createFieldDescriptor(
/* Class StructuredClass */
StructuredClass::StructuredClass(Manager &mgr, std::string name,
- Handle<Domain> domain,
- const Cardinality &cardinality,
+ Handle<Domain> domain, Variant cardinality,
Handle<StructType> attributesDescriptor,
Handle<StructuredClass> superclass,
bool transparent, bool root)
: Descriptor(mgr, std::move(name), domain, attributesDescriptor),
- cardinality(cardinality),
+ cardinality(std::move(cardinality)),
superclass(acquire(superclass)),
subclasses(this),
transparent(transparent),
@@ -333,10 +332,15 @@ bool StructuredClass::doValidate(Logger &logger) const
if (sub->getSuperclass() != this) {
logger.error(std::string("Struct \"") + sub->getName() +
"\" is registered as subclass of \"" + getName() +
- "\" but does not have it as superclass!");
+ "\" but does not have it as superclass!", *this);
valid = false;
}
}
+ // check the cardinality.
+ if(!cardinality.isCardinality()){
+ logger.error(cardinality.toString() + " is not a cardinality!", *this);
+ valid = false;
+ }
// check the validity of this superclass.
if (superclass != nullptr) {
valid = valid & superclass->validate(logger);
@@ -495,13 +499,14 @@ bool Domain::removeStructuredClass(Handle<StructuredClass> s)
}
Rooted<StructuredClass> Domain::createStructuredClass(
- std::string name, const Cardinality &cardinality,
+ std::string name, Variant cardinality,
Handle<StructType> attributesDescriptor, Handle<StructuredClass> superclass,
bool transparent, bool root)
{
return Rooted<StructuredClass>{new StructuredClass(
- getManager(), std::move(name), this, cardinality, attributesDescriptor,
- superclass, std::move(transparent), std::move(root))};
+ getManager(), std::move(name), this, std::move(cardinality),
+ attributesDescriptor, superclass, std::move(transparent),
+ std::move(root))};
}
void Domain::addAnnotationClass(Handle<AnnotationClass> a)