diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-22 02:47:36 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-22 02:47:36 +0100 |
commit | 4df98e9ae04dd077e47f0a5539aeb68b96c710c4 (patch) | |
tree | 918950c16bbb6f112309f7c3c8a1e6aca12d3650 /src/core/model/Domain.hpp | |
parent | f90a9bf51f300dd277071b1461d00411d7c21b89 (diff) | |
parent | 33008f1110523ae9c9b9e1d2ca24ed642637c40d (diff) |
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core/model/Domain.hpp')
-rw-r--r-- | src/core/model/Domain.hpp | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index e485171..12cb9b3 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -249,6 +249,8 @@ class Domain; * undefined state. */ class FieldDescriptor : public Node { + friend Descriptor; + public: /** * This enum class contains all possible FieldTypes, meaning either the @@ -508,33 +510,21 @@ public: /** * Adds the given FieldDescriptor to this Descriptor. This also sets the * parent of the given FieldDescriptor if it is not set to this Descriptor - * already. - * - * This should not be used if the given FieldDescriptor is a field of - * another Descriptor already. Use copyFieldDescriptor in that case. - * TODO: But this could get move semantics. + * already and removes it from the old parent Descriptor. * * @param fd is a FieldDescriptor. */ - void addFieldDescriptor(Handle<FieldDescriptor> fd) - { - invalidate(); - fieldDescriptors.push_back(fd); - if (fd->getParent() != this) { - fd->setParent(this); - } - } + void addFieldDescriptor(Handle<FieldDescriptor> fd); /** * Adds the given FieldDescriptors to this Descriptor. This also sets the * parent of each given FieldDescriptor if it is not set to this Descriptor - * already. + * already and removes it from the old parent Descriptor. * * @param fds are FieldDescriptors. */ void addFieldDescriptors(const std::vector<Handle<FieldDescriptor>> &fds) { - invalidate(); for (Handle<FieldDescriptor> fd : fds) { addFieldDescriptor(fd); } @@ -549,6 +539,16 @@ public: void copyFieldDescriptor(Handle<FieldDescriptor> fd); /** + * Removes the given FieldDescriptor from this Descriptor. This also sets + * the parent of the given FieldDescriptor to null. + * + * @param fd is a FieldDescriptor. + * @return true if the FieldDescriptor was removed and false if this + * Descriptor did not have the given FieldDescriptor as child. + */ + bool removeFieldDescriptor(Handle<FieldDescriptor> fd); + + /** * This tries to construct the shortest possible path of this Descriptor * to the given child Descriptor. As an example consider the book domain * from above. @@ -672,6 +672,8 @@ static const Cardinality AnyCardinality = createAny(); * What about the cardinality? */ class StructuredClass : public Descriptor { + friend Domain; + private: const Cardinality cardinality; Owned<StructuredClass> superclass; @@ -833,6 +835,8 @@ public: * This class has no special properties and is in essence just a Descriptor. */ class AnnotationClass : public Descriptor { + friend Domain; + public: /** * The constructor for a new AnnotationClass. Note that you have to add @@ -871,13 +875,7 @@ private: protected: void doResolve(ResolutionState &state) override; - /* - * TODO: doValidate with: - * # namecheck - * # are all structureclasses valid and have a unique name? - * # are all annotationclasses valid and have a unique name? - * # are all typesystems valid? - */ + bool doValidate(Logger &logger) const override; public: @@ -925,14 +923,24 @@ public: } /** * Adds a StructuredClass to this domain. This also sets the parent of the - * given StructuredClass if it is not set to this Domain already. - * TODO: This could have move semantics. + * given StructuredClass if it is not set to this Domain already and removes + * it from the old Domain. * * @param s is some StructuredClass. */ void addStructuredClass(Handle<StructuredClass> s); /** + * Removes a StructuredClass from this domain. This also sets the parent of + * the given StructuredClass to null. + * + * @param s is some StructuredClass. + * @return true if the given StructuredClass was removed and false if this + * Domain did not have the given StructuredClass as child. + */ + bool removeStructuredClass(Handle<StructuredClass> s); + + /** * Returns a const reference to the NodeVector of AnnotationClasses that are * part of this Domain. * @@ -945,14 +953,24 @@ public: } /** * Adds an AnnotationClass to this domain. This also sets the parent of the - * given AnnotationClass if it is not set to this Domain already. - * TODO: This could have move semantics. + * given AnnotationClass if it is not set to this Domain already and removes + * it from the old Domain. * * @param a is some AnnotationClass. */ void addAnnotationClass(Handle<AnnotationClass> a); /** + * Removes a AnnotationClass from this domain. This also sets the parent of + * the given AnnotationClass to null. + * + * @param a is some AnnotationClass. + * @return true if the given AnnotationClass was removed and false if this + * Domain did not have the given AnnotationClass as child. + */ + bool removeAnnotationClass(Handle<AnnotationClass> a); + + /** * Returns a const reference to the NodeVector of TypeSystems that are * references in this Domain. * |