Salome HOME
Implementation of features cashing and undo/redo functionality in document.
[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_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   MODEL_EXPORT virtual void next();
28   /// Returns true if the current iteration is valid and next iteration is possible
29   MODEL_EXPORT virtual bool more();
30   /// Returns the currently iterated feature
31   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> current();
32   /// Returns the kind of the current feature (faster than Current()->getKind())
33   MODEL_EXPORT virtual std::string currentKind();
34   /// Returns the name of the current feature (faster than Current()->getName())
35   MODEL_EXPORT 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   MODEL_EXPORT virtual int numIterationsLeft();
39
40   /// Compares the current feature with the given one
41   /// \returns true if given feature equals to the current one
42   MODEL_EXPORT virtual bool is(std::shared_ptr<ModelAPI_Feature> theFeature);
43
44 protected:
45   /// Creates an empty iterator that alway returns More false
46   Model_Iterator();
47   /// Initializes iterator
48   /// \param theDoc document where the iteration is performed
49   /// \param theLab label of the features group to iterate
50   Model_Iterator(std::shared_ptr<Model_Document> theDoc, TDF_Label theLab);
51
52   friend class Model_Document;
53 };
54
55 #endif