1 /*
2  *
3  *  Copyright (C) 2016-2017, J. Riesmeier, Oldenburg, Germany
4  *  All rights reserved.  See COPYRIGHT file for details.
5  *
6  *  This software and supporting documentation are maintained by
7  *
8  *    OFFIS e.V.
9  *    R&D Division Health
10  *    Escherweg 2
11  *    D-26121 Oldenburg, Germany
12  *
13  *
14  *  Module: dcmsr
15  *
16  *  Author: Joerg Riesmeier
17  *
18  *  Purpose:
19  *    classes: DSRDocumentTreeNodeCursor
20  *
21  */
22 
23 
24 #ifndef DSRDNCSR_H
25 #define DSRDNCSR_H
26 
27 #include "dcmtk/config/osconfig.h"   /* make sure OS specific configuration is included first */
28 
29 #include "dcmtk/dcmsr/dsdefine.h"
30 #include "dcmtk/dcmsr/dsrtncsr.h"
31 #include "dcmtk/dcmsr/dsrdnflt.h"
32 
33 
34 /*-----------------------*
35  *  forward declaration  *
36  *-----------------------*/
37 
38 class DSRDocumentTreeNode;
39 
40 
41 /*---------------------*
42  *  class declaration  *
43  *---------------------*/
44 
45 /** Class implementing a document tree node cursor.
46  *  Included sub-templates are not supported by this type of cursor, i.e. the subtree
47  *  that is managed by an instance of DSRIncludedTemplateTreeNode is not iterated.
48  */
49 class DCMTK_DCMSR_EXPORT DSRDocumentTreeNodeCursor
50   : public DSRTreeNodeCursor<DSRDocumentTreeNode>
51 {
52 
53   public:
54 
55     /** default constructor
56      */
57     DSRDocumentTreeNodeCursor();
58 
59     /** copy constructor
60      ** @param  cursor  object to be copied
61      */
62     DSRDocumentTreeNodeCursor(const DSRDocumentTreeNodeCursor &cursor);
63 
64     /** copy constructor (for base class)
65      ** @param  cursor  object to be copied
66      */
67     DSRDocumentTreeNodeCursor(const DSRTreeNodeCursor<DSRDocumentTreeNode> &cursor);
68 
69     /** constructor.
70      *  See comments on DSRTreeNodeCursor<>::setCursor() method.
71      ** @param  node      pointer to tree node used to initialize the cursor
72      *  @param  position  optional pointer to position counter that should be used to
73      *                    initialize the internal counter
74      */
75     DSRDocumentTreeNodeCursor(DSRDocumentTreeNode *node,
76                               const DSRPositionCounter *position = NULL);
77 
78     /** destructor
79      */
80     virtual ~DSRDocumentTreeNodeCursor();
81 
82     /** assignment operator
83      ** @param  cursor  object to be copied
84      ** @return reference to modified cursor (this object)
85      */
86     DSRDocumentTreeNodeCursor &operator=(const DSRDocumentTreeNodeCursor &cursor);
87 
88     /** assignment operator.
89      *  See comments on DSRTreeNodeCursor<>::setCursor() method.
90      ** @param  node  node to which the cursor should be set
91      ** @return reference to modified cursor (this object)
92      */
93     DSRDocumentTreeNodeCursor &operator=(DSRDocumentTreeNode *node);
94 
95     /** set internal cursor to a matching node (starting from current position).
96      *  If more than one node exists matching the given filter, the first one will be
97      *  selected.  Use gotoNextMatchingNode() in order to go to the next matching node.
98      ** @param  filter         matching criterion based on a single or multiple filters
99      *  @param  searchIntoSub  flag indicating whether to search into sub-trees
100      *                         ("deep search") or on the current level only
101      ** @return ID of the new current node if successful, 0 otherwise
102      */
103     virtual size_t gotoMatchingNode(const DSRDocumentTreeNodeFilter &filter,
104                                     const OFBool searchIntoSub = OFTrue);
105 
106     /** set internal cursor to the next matching node.
107      *  Starts from "next" node, i.e. either the first child of the current node or the
108      *  first sibling following the current node.
109      ** @param  filter         matching criterion based on a single or multiple filters
110      *  @param  searchIntoSub  flag indicating whether to search into sub-trees
111      *                         ("deep search") or on the current level only
112      ** @return ID of the new current node if successful, 0 otherwise
113      */
114     virtual size_t gotoNextMatchingNode(const DSRDocumentTreeNodeFilter &filter,
115                                         const OFBool searchIntoSub = OFTrue);
116 };
117 
118 
119 #endif
120