diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-03-03 18:23:15 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2015-03-03 18:23:15 +0100 |
commit | 4ee3c4042d267c010babb2ab86e15a6b31950849 (patch) | |
tree | c4204e0504de047cecf239f10e68e17246f99e8f /src/core/model/Document.hpp | |
parent | f6b22312127f29f71aa26ca28142ad3e5f193445 (diff) |
added a method to find the matching start anchor for some end anchor.
Diffstat (limited to 'src/core/model/Document.hpp')
-rw-r--r-- | src/core/model/Document.hpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp index dc0f73f..81e2f41 100644 --- a/src/core/model/Document.hpp +++ b/src/core/model/Document.hpp @@ -26,8 +26,8 @@ * * A Document, from top to bottom, consists of "Document" instance, * which "owns" the structural root node of the in-document graph. This might - * for example be a "book" node of the "book" ontology. That root node in turn has - * structure nodes as children, which in turn may have children. This + * for example be a "book" node of the "book" ontology. That root node in turn + * has structure nodes as children, which in turn may have children. This * constitutes a Structure Tree. Additionally annotations may be attached to * Structure Nodes, effectively resulting in a Document Graph instead of a * Document Tree (other references may introduce cycles as well). @@ -142,7 +142,7 @@ class Anchor; */ class DocumentEntity { private: - /* + /** * this is a rather dirty method that should not be used in other cases: * We store a handle to the Node instance that inherits from * DocumentEntity. This Handle is not registered and would lead to Segfaults @@ -156,6 +156,18 @@ private: void invalidateSubInstance(); + template <typename Iterator> + Rooted<Anchor> searchStartAnchorInField(Handle<AnnotationClass> desc, + const std::string &name, + Iterator begin, Iterator end); + + Rooted<Anchor> searchStartAnchorDownwards(Handle<AnnotationClass> desc, + const std::string &name); + + Rooted<Anchor> searchStartAnchorUpwards(Handle<AnnotationClass> desc, + const std::string &name, + const DocumentEntity *child); + protected: bool doValidate(Logger &logger) const; @@ -420,7 +432,7 @@ public: Rooted<StructuredEntity> createChildStructuredEntity( Handle<StructuredClass> descriptor, const size_t &fieldIdx, Variant attributes = Variant::mapType{}, std::string name = ""); - /* + /** * Creates a new DocumentPrimitive as child of this DocumentEntity. * * @param content is a Variant containing the content of this @@ -434,7 +446,7 @@ public: */ Rooted<DocumentPrimitive> createChildDocumentPrimitive( Variant content, const std::string &fieldName = DEFAULT_FIELD_NAME); - /* + /** * Creates a new DocumentPrimitive as child of this DocumentEntity. * * @param fieldIdx is the index of the field, where the newly created @@ -469,6 +481,23 @@ public: * @return the newly created Anchor. */ Rooted<Anchor> createChildAnchor(const size_t &fieldIdx); + + /** + * Does an inverse depth first search starting at this DocumentEntity to + * find a child Anchor element that matches the given seach criteria. + * The search will not cross SUBTREE to TREE field boundaries and will not + * leave AnnotationEntities upwards. If no Anchor is found a nullptr is + * returned. AnnotationEntities which already have an end Anchor won't be + * returned. + * + * @param desc is the AnnotationClass of the AnnotationEntity whose + * start Anchor you are looking for. + * @param name is the AnnotationEntities name. + * @return the start Anchor or a nullptr if no Anchor could be found. + */ + Rooted<Anchor> searchStartAnchor(size_t fieldIdx, + Handle<AnnotationClass> desc = nullptr, + const std::string &name = ""); }; /** @@ -1061,4 +1090,4 @@ extern const Rtti Anchor; } } -#endif /* _OUSIA_MODEL_DOCUMENT_HPP_ */
\ No newline at end of file +#endif /* _OUSIA_MODEL_DOCUMENT_HPP_ */ |