diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-08 19:37:51 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-08 19:37:51 +0100 |
commit | 5eca67b6cab7031d8203b1403ba5cddaef833e76 (patch) | |
tree | ddb626aa00a0da75d038b08025e4c4fd7760ec5c /src/core/model/Document.hpp | |
parent | c2b9597c49abeef3f333b1bf7221a51019d53668 (diff) |
restructured the FieldDescriptor mechanism.
Diffstat (limited to 'src/core/model/Document.hpp')
-rw-r--r-- | src/core/model/Document.hpp | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp index 4be3494..b41393e 100644 --- a/src/core/model/Document.hpp +++ b/src/core/model/Document.hpp @@ -153,18 +153,8 @@ private: Variant attributes; std::vector<NodeVector<StructureNode>> fields; - int getFieldDescriptorIndex(const std::string &fieldName, - bool enforce) const; - - int getFieldDescriptorIndex(Handle<FieldDescriptor> fieldDescriptor, - bool enforce) const; - void invalidateSubInstance(); - void addStructureNode(Handle<StructureNode> s, const int &i); - - bool removeStructureNodeFromField(Handle<StructureNode> s, const int &i); - protected: bool doValidate(Logger &logger) const; @@ -218,19 +208,6 @@ public: void setAttributes(const Variant &a); /** - * This returns true if there is a FieldDescriptor in the Descriptor for - * this DocumentEntity which has the given name. - * - * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. - * @return true if this FieldDescriptor exists. - */ - bool hasField(const std::string &fieldName = DEFAULT_FIELD_NAME) const - { - return getFieldDescriptorIndex(fieldName, false) != -1; - } - - /** * This returns the vector of entities containing all members of the field * with the given name. * @@ -241,10 +218,7 @@ public: * @return a NodeVector of all StructuredEntities in that field. */ const NodeVector<StructureNode> &getField( - const std::string &fieldName = DEFAULT_FIELD_NAME) const - { - return fields[getFieldDescriptorIndex(fieldName, true)]; - } + const std::string &fieldName = DEFAULT_FIELD_NAME) const; /** * This returns the vector of entities containing all members of the field @@ -259,12 +233,21 @@ public: * field. */ const NodeVector<StructureNode> &getField( - Handle<FieldDescriptor> fieldDescriptor) const - { - return fields[getFieldDescriptorIndex(fieldDescriptor, true)]; - } + Handle<FieldDescriptor> fieldDescriptor) const; /** + * This adds a StructureNode to the field with the given index. + * + * This method also changes the parent of the newly added StructureNode if + * it is not set to this DocumentEntity already and removes it from the + * old parent. + * + * @param s is the StructureNode that shall be added. + * @param fieldIdx is the index of a field as specified in the + * FieldDescriptor in the Domain description. + */ + void addStructureNode(Handle<StructureNode> s, const int &fieldIdx); + /** * This adds a StructureNode to the field with the given name. * * If the name is unknown an exception is thrown. @@ -296,6 +279,19 @@ public: void addStructureNodes(const std::vector<Handle<StructureNode>> &ss, const std::string &fieldName = DEFAULT_FIELD_NAME); /** + * This removes a StructureNode from the field with the given index. + * + * This method also changes the parent of the removed StructureNode to null. + * + * @param s is the StructureNode that shall be removed. + * @param fieldIdx is the index of a field as specified in the + * FieldDescriptor in the Domain description. + * @return true if this StructureNode was a child here and false if + * if was not found. + */ + bool removeStructureNodeFromField(Handle<StructureNode> s, + const int &fieldIdx); + /** * This removes a StructureNode from the field with the given name. * * If the name is unknown an exception is thrown. |