VTK
vtkCollection.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkCollection.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
34#ifndef vtkCollection_h
35#define vtkCollection_h
36
37#include "vtkCommonCoreModule.h" // For export macro
38#include "vtkObject.h"
39
40class vtkCollectionElement //;prevents pick-up by man page generator
41{
42 public:
46};
48
50
51class VTKCOMMONCORE_EXPORT vtkCollection : public vtkObject
52{
53public:
54 vtkTypeMacro(vtkCollection,vtkObject);
55 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
56
60 static vtkCollection *New();
61
66
71 void InsertItem(int i, vtkObject *);
72
76 void ReplaceItem(int i, vtkObject *);
77
85 void RemoveItem(int i);
86
93
98
105
109 int GetNumberOfItems() { return this->NumberOfItems; }
110
115 void InitTraversal() { this->Current = this->Top;};
116
122 cookie = static_cast<vtkCollectionSimpleIterator>(this->Top);};
123
128 vtkObject *GetNextItemAsObject();
129
135
140 vtkObject *GetNextItemAsObject(vtkCollectionSimpleIterator &cookie);
141
146
148
151 void Register(vtkObjectBase* o) VTK_OVERRIDE;
152 void UnRegister(vtkObjectBase* o) VTK_OVERRIDE;
154
155protected:
157 ~vtkCollection() VTK_OVERRIDE;
158
159 virtual void RemoveElement(vtkCollectionElement *element,
161 virtual void DeleteElement(vtkCollectionElement *);
162 int NumberOfItems;
166
168
169 // See vtkGarbageCollector.h:
170 void ReportReferences(vtkGarbageCollector* collector) VTK_OVERRIDE;
171private:
172 vtkCollection(const vtkCollection&) VTK_DELETE_FUNCTION;
173 void operator=(const vtkCollection&) VTK_DELETE_FUNCTION;
174};
175
176
177inline vtkObject *vtkCollection::GetNextItemAsObject()
178{
179 vtkCollectionElement *elem=this->Current;
180
181 if ( elem != NULL )
182 {
183 this->Current = elem->Next;
184 return elem->Item;
185 }
186 else
187 {
188 return NULL;
189 }
190}
191
193{
194 vtkCollectionElement *elem=static_cast<vtkCollectionElement *>(cookie);
195
196 if ( elem != NULL )
197 {
198 cookie = static_cast<void *>(elem->Next);
199 return elem->Item;
200 }
201 else
202 {
203 return NULL;
204 }
205}
206
207#endif
208
209
210
211
212
vtkCollectionElement * Next
Definition: vtkCollection.h:45
iterator through a vtkCollection.
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:52
vtkObject * GetItemAsObject(int i)
Get the i'th item in the collection.
void UnRegister(vtkObjectBase *o) override
Decrease the reference count (release by another object).
void RemoveItem(int i)
Remove the i'th item in the list.
~vtkCollection() override
void ReplaceItem(int i, vtkObject *)
Replace the i'th item in the collection with a.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_NEWINSTANCE vtkCollectionIterator * NewIterator()
Get an iterator to traverse the objects in this collection.
void RemoveItem(vtkObject *)
Remove an object from the list.
void AddItem(vtkObject *)
Add an object to the list.
void InsertItem(int i, vtkObject *)
Insert item into the list after the i'th item.
void InitTraversal()
Initialize the traversal of the collection.
void Register(vtkObjectBase *o) override
Participate in garbage collection.
void RemoveAllItems()
Remove all objects from the list.
static vtkCollection * New()
Construct with empty list.
void InitTraversal(vtkCollectionSimpleIterator &cookie)
A reentrant safe way to iterate through a collection.
vtkObject * GetNextItemAsObject()
Get the next item in the collection.
int GetNumberOfItems()
Return the number of objects in the list.
int IsItemPresent(vtkObject *a)
Search for an object and return location in list.
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObjectBase.h:66
abstract base class for most VTK objects
Definition: vtkObject.h:60
@ previous
Definition: vtkX3D.h:449
void * vtkCollectionSimpleIterator
Definition: vtkCollection.h:47
#define VTK_NEWINSTANCE