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 =========================================================================*/
33 #ifndef vtkCollection_h
34 #define vtkCollection_h
35 
36 #include "vtkCommonCoreModule.h" // For export macro
37 #include "vtkObject.h"
38 
39 //BTX - begin tcl exclude
40 class vtkCollectionElement //;prevents pick-up by man page generator
41 {
42  public:
43  vtkCollectionElement():Item(NULL),Next(NULL) {}
46 };
48 //ETX end tcl exclude
49 
51 
53 {
54 public:
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
59  static vtkCollection *New();
60 
62  void AddItem(vtkObject *);
63 
67  void InsertItem(int i, vtkObject *);
68 
70  void ReplaceItem(int i, vtkObject *);
71 
77  void RemoveItem(int i);
78 
83 
86 
91 
93  int GetNumberOfItems() { return this->NumberOfItems; }
94 
97  void InitTraversal() { this->Current = this->Top;};
98 
99  //BTX
101 
104  cookie = static_cast<vtkCollectionSimpleIterator>(this->Top);};
105  //ETX
107 
110  vtkObject *GetNextItemAsObject();
111 
115 
116  //BTX
118 
120  vtkObject *GetNextItemAsObject(vtkCollectionSimpleIterator &cookie);
121  //ETX
123 
126 
128 
129  virtual void Register(vtkObjectBase* o);
130  virtual void UnRegister(vtkObjectBase* o);
131 protected:
135 
136  virtual void RemoveElement(vtkCollectionElement *element,
143 
144  //BTX
145  friend class vtkCollectionIterator;
146  //ETX
147 
148  // See vtkGarbageCollector.h:
149  virtual void ReportReferences(vtkGarbageCollector* collector);
150 private:
151  vtkCollection(const vtkCollection&); // Not implemented
152  void operator=(const vtkCollection&); // Not implemented
153 };
154 
155 
157 {
158  vtkCollectionElement *elem=this->Current;
159 
160  if ( elem != NULL )
161  {
162  this->Current = elem->Next;
163  return elem->Item;
164  }
165  else
166  {
167  return NULL;
168  }
169 }
170 
172 {
173  vtkCollectionElement *elem=static_cast<vtkCollectionElement *>(cookie);
174 
175  if ( elem != NULL )
176  {
177  cookie = static_cast<void *>(elem->Next);
178  return elem->Item;
179  }
180  else
181  {
182  return NULL;
183  }
184 }
185 
186 #endif
187 
188 
189 
190 
191 
vtkCollection::NewIterator
vtkCollectionIterator * NewIterator()
vtkCollection::NumberOfItems
int NumberOfItems
Definition: vtkCollection.h:139
vtkCollection::Current
vtkCollectionElement * Current
Definition: vtkCollection.h:142
vtkCollection::RemoveElement
virtual void RemoveElement(vtkCollectionElement *element, vtkCollectionElement *previous)
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkCollection::New
static vtkCollection * New()
vtkCollection::DeleteElement
virtual void DeleteElement(vtkCollectionElement *)
vtkCollectionSimpleIterator
void * vtkCollectionSimpleIterator
Definition: vtkCollection.h:47
vtkCollection::Register
virtual void Register(vtkObjectBase *o)
vtkCollection::InitTraversal
void InitTraversal(vtkCollectionSimpleIterator &cookie)
Definition: vtkCollection.h:103
vtkCollection::RemoveItem
void RemoveItem(vtkObject *)
vtkCollection::vtkCollection
vtkCollection()
vtkCollection::IsItemPresent
int IsItemPresent(vtkObject *a)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkCollection::ReplaceItem
void ReplaceItem(int i, vtkObject *)
vtkCollection::UnRegister
virtual void UnRegister(vtkObjectBase *o)
vtkCollectionElement::Item
vtkObject * Item
Definition: vtkCollection.h:44
vtkCollectionElement::vtkCollectionElement
vtkCollectionElement()
Definition: vtkCollection.h:43
vtkCollection::GetNumberOfItems
int GetNumberOfItems()
Definition: vtkCollection.h:93
vtkCollection::GetNextItemAsObject
vtkObject * GetNextItemAsObject()
Definition: vtkCollection.h:156
vtkCollectionElement::Next
vtkCollectionElement * Next
Definition: vtkCollection.h:45
vtkCollection
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:53
vtkCommonCoreModule.h
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:60
vtkCollectionIterator
iterator through a vtkCollection.
Definition: vtkCollectionIterator.h:37
vtkCollection::Bottom
vtkCollectionElement * Bottom
Definition: vtkCollection.h:141
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkCollection::InsertItem
void InsertItem(int i, vtkObject *)
vtkCollection::GetItemAsObject
vtkObject * GetItemAsObject(int i)
vtkCollection::~vtkCollection
~vtkCollection()
vtkgl::a
GLboolean GLboolean GLboolean GLboolean a
Definition: vtkgl.h:12312
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:99
vtkObject.h
vtkCollection::RemoveAllItems
void RemoveAllItems()
vtkCollection::RemoveItem
void RemoveItem(int i)
vtkX3D::previous
@ previous
Definition: vtkX3D.h:449
vtkCollection::ReportReferences
virtual void ReportReferences(vtkGarbageCollector *collector)
vtkCollection::AddItem
void AddItem(vtkObject *)
vtkCollection::InitTraversal
void InitTraversal()
Definition: vtkCollection.h:97
vtkCollectionElement
Definition: vtkCollection.h:41
vtkCollection::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkCollection::Top
vtkCollectionElement * Top
Definition: vtkCollection.h:140