Salome HOME
4da78e26712f49b1113ac59e44b9743bdfbf1065
[modules/shaper.git] / src / Model / Model_Iterator.h
1 // File:        Model_Iterator.h
2 // Created:     1 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Iterator_HeaderFile
6 #define Model_Iterator_HeaderFile
7
8 #include "Model.h"
9 #include "ModelAPI_Iterator.h"
10 #include <TDF_Label.hxx>
11 #include <TDF_ChildIDIterator.hxx>
12
13 class Model_Document;
14
15 /**\class Model_Iterator
16  * \ingroup DataModel
17  * \brief Allows to iterate features of the document. Is created by the document
18  * (see method featuresIterator).
19  */
20
21 class MODEL_EXPORT Model_Iterator : public ModelAPI_Iterator
22 {
23   std::shared_ptr<Model_Document> myDoc; ///< the document of iterated objects
24   TDF_ChildIDIterator myIter; ///< iterator of the features-labels
25 public:
26   /// Iterates to the next feature
27   virtual void next();
28   /// Returns true if the current iteration is valid and next iteration is possible
29   virtual bool more();
30   /// Returns the currently iterated feature
31   virtual std::shared_ptr<ModelAPI_Feature> current();
32   /// Returns the kind of the current feature (faster than Current()->getKind())
33   virtual std::string currentKind();
34   /// Returns the name of the current feature (faster than Current()->getName())
35   virtual std::string currentName();
36   /// Don't changes the current position of iterator. Not fast: iterates the left items.
37   /// \returns number of left iterations
38   virtual int numIterationsLeft();
39
40 protected:
41   /// Initializes iterator
42   /// \param theDoc document where the iteration is performed
43   /// \param theLab label of the features group to iterate
44   Model_Iterator(std::shared_ptr<Model_Document> theDoc, TDF_Label theLab);
45
46   friend class Model_Document;
47 };
48
49 #endif