OCC22144 NIS performance and memory usage update
[occt.git] / src / NIS / NIS_ObjectsIterator.hxx
1 // File:      NIS_ObjectsIterator.hxx
2 // Created:   02.09.07 23:47
3 // Author:    Alexander GRIGORIEV
4 // Copyright: Open Cascade 2007
5
6
7 #ifndef NIS_ObjectsIterator_HeaderFile
8 #define NIS_ObjectsIterator_HeaderFile
9
10 #include <NCollection_Vector.hxx>
11 #include <Handle_NIS_InteractiveObject.hxx>
12
13 class Handle_NIS_InteractiveContext;
14
15 /**
16  * Iterator of objects contained in a NIS_InteractiveContext instance. The
17  * iteration is always in the ascending sense of object ID. Examples:
18  * @code
19  *    // Erase all objects in the Context
20  * NIS_ObjectsIterator anIter (myContext);
21  * for (; anIter.More(); anIter.Next())
22  *   myContext->Erase (anIter.Value(), Standard_False);
23  *
24  *    // Set object attributes to their IDs (hardly useful outside the example)
25  * anIter.Initialize (myContext);
26  * Handle(NIS_InteractiveObject) anObj;
27  * while (!(anObj = anIter.Value().IsNull())) {
28  *   anObj->SetAttribute (static_cast<void *> (anObj->ID()));
29  *   anIter.Next();
30  * }
31  * @endcode
32  */
33
34 class NIS_ObjectsIterator 
35 {
36  public:
37   // ---------- PUBLIC METHODS ----------
38
39
40   /**
41    * Empty Constructor.
42    */
43   inline NIS_ObjectsIterator    () {}
44
45   /**
46    * Constructor.
47    * @param theCtx
48    *   Interactive context that is to be iterated for all objects.
49    */
50   inline NIS_ObjectsIterator    (const Handle_NIS_InteractiveContext& theCtx)
51   { Initialize (theCtx); }
52
53   /**
54    * Reset the Iterator to start the iterations of objects.
55    * @param theCtx
56    *   Interactive context that is to be iterated for all objects.
57    */
58   Standard_EXPORT void          Initialize
59                                 (const Handle_NIS_InteractiveContext& theCtx);
60
61   /**
62    * Query if the Iterator has an object (not yet finished the iteration
63    * process).
64    */
65   inline Standard_Boolean       More    () const
66   { return myIter.More(); }
67
68   /**
69    * Returns the current object at the iteration pointer. If the iteration is
70    * over (More() == False) this method returns NULL Handle.
71    */
72   Standard_EXPORT const Handle_NIS_InteractiveObject&
73                                 Value   () const;
74
75   /**
76    * Step forward to the next valid InteractiveObject instance.
77    */
78   Standard_EXPORT void          Next    ();
79
80  protected:
81   // ---------- PROTECTED FIELDS ----------
82
83   NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator myIter;
84
85 };
86
87 #endif