1 // File: Model_Iterator.h
3 // Author: Mikhail PONIKAROV
5 #ifndef Model_Iterator_HeaderFile
6 #define Model_Iterator_HeaderFile
9 #include "ModelAPI_Iterator.h"
10 #include <TDF_Label.hxx>
11 #include <TDF_ChildIDIterator.hxx>
15 /**\class Model_Iterator
17 * \brief Allows to iterate features of the document. Is created by the document
18 * (see method featuresIterator).
21 class Model_Iterator : public ModelAPI_Iterator
23 std::shared_ptr<Model_Document> myDoc; ///< the document of iterated objects
24 TDF_ChildIDIterator myIter; ///< iterator of the features-labels
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();
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);
45 /// Creates an empty iterator that alway returns More false
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);
52 friend class Model_Document;