Salome HOME
Merge branch 'BR_MULTI_BATHS' into HEAD
[modules/hydro.git] / src / HYDROData / HYDROData_Iterator.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_Iterator_HeaderFile
20 #define HYDROData_Iterator_HeaderFile
21
22 #include "HYDROData_Document.h"
23
24 #include <TDF_ChildIDIterator.hxx>
25
26 /**\class HYDROData_Iterator
27  * \brief Allows to iterate all objects by the document and kind of object.
28  *
29  * Using the document data structures, iterates through objects, filtered by 
30  * kind of this object. This class must have information about all kinds of 
31  * objects of the document: for correct iteration and creation of them.
32  */
33 class HYDROData_Iterator
34 {
35 public:
36   /**
37    * Initializes iterator by objects of the document.
38    * \param theDoc document to iterate
39    * \param theKind kind of the iterated object, can be UNKNOWN: to iterate all objects
40    */
41   HYDRODATA_EXPORT HYDROData_Iterator( const Handle(HYDROData_Document)& theDoc,
42                                        const ObjectKind theKind = KIND_UNKNOWN);
43
44   /**
45    * Iterates to the next object
46    */
47   HYDRODATA_EXPORT void Next();
48
49   /**
50    * Returns true if current object exists
51    */
52   HYDRODATA_EXPORT bool More() const;
53
54   /**
55    * Returns the current object of the iterator.
56    */
57   HYDRODATA_EXPORT Handle(HYDROData_Entity) Current();
58
59 public:
60
61   /**
62    * Creates object in the document on the given label
63    * \param theDoc document where object will be located
64    * \param theKind kind of the new object, can not be UNKNOWN
65    */
66   static HYDRODATA_EXPORT Handle(HYDROData_Entity) CreateObject(
67     TDF_Label&        theNewLabel, 
68     const ObjectKind& theObjectKind );
69
70   /**
71    * Returns object associated to the given label.
72    */
73   static HYDRODATA_EXPORT Handle(HYDROData_Entity) Object( 
74     const TDF_Label& theLabel );
75
76 protected:
77
78   friend class HYDROData_Document;
79   friend class HYDROData_Entity;
80
81   /**
82    * Creates object in the document, call HYDROData_Document method to create 
83    * objects from other packages.
84    * \param theDoc document where object will be located
85    * \param theKind kind of the new object, can not be UNKNOWN
86    */
87   static Handle(HYDROData_Entity) CreateObject(
88     const Handle(HYDROData_Document)& theDoc,
89     const ObjectKind&                 theObjectKind );
90
91   TDF_ChildIDIterator myIter; ///< iterator by the objects in the document
92 };
93
94 #endif