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 "vtkObject.h"
37 
38 //BTX - begin tcl exclude
39 class vtkCollectionElement //;prevents pick-up by man page generator
40 {
41  public:
42  vtkCollectionElement():Item(NULL),Next(NULL) {};
43  vtkObject *Item;
45 };
47 //ETX end tcl exclude
48 
50 
52 {
53 public:
54  vtkTypeMacro(vtkCollection,vtkObject);
55  void PrintSelf(ostream& os, vtkIndent indent);
56 
58  static vtkCollection *New();
59 
61  void AddItem(vtkObject *);
62 
66  void InsertItem(int i, vtkObject *);
67 
69  void ReplaceItem(int i, vtkObject *);
70 
76  void RemoveItem(int i);
77 
81  void RemoveItem(vtkObject *);
82 
84  void RemoveAllItems();
85 
89  int IsItemPresent(vtkObject *a);
90 
92  int GetNumberOfItems();
93 
96  void InitTraversal() { this->Current = this->Top;};
97 
98  //BTX
100 
103  cookie = static_cast<vtkCollectionSimpleIterator>(this->Top);};
104  //ETX
106 
109  vtkObject *GetNextItemAsObject();
110 
113  vtkObject *GetItemAsObject(int i);
114 
115  //BTX
117 
119  vtkObject *GetNextItemAsObject(vtkCollectionSimpleIterator &cookie);
120  //ETX
122 
124  vtkCollectionIterator* NewIterator();
125 
127 
128  virtual void Register(vtkObjectBase* o);
129  virtual void UnRegister(vtkObjectBase* o);
130 protected:
131  vtkCollection();
132  ~vtkCollection();
134 
135  virtual void DeleteElement(vtkCollectionElement *);
140 
141  //BTX
142  friend class vtkCollectionIterator;
143  //ETX
144 
145  // See vtkGarbageCollector.h:
146  virtual void ReportReferences(vtkGarbageCollector* collector);
147 private:
148  vtkCollection(const vtkCollection&); // Not implemented
149  void operator=(const vtkCollection&); // Not implemented
150 };
151 
152 
154 {
155  vtkCollectionElement *elem=this->Current;
156 
157  if ( elem != NULL )
158  {
159  this->Current = elem->Next;
160  return elem->Item;
161  }
162  else
163  {
164  return NULL;
165  }
166 }
167 
169 {
170  vtkCollectionElement *elem=static_cast<vtkCollectionElement *>(cookie);
171 
172  if ( elem != NULL )
173  {
174  cookie = static_cast<void *>(elem->Next);
175  return elem->Item;
176  }
177  else
178  {
179  return NULL;
180  }
181 }
182 
183 #endif
184 
185 
186 
187 
188 
void * vtkCollectionSimpleIterator
Definition: vtkCollection.h:46
abstract base class for most VTK objects
Definition: vtkObject.h:60
virtual void Register(vtkObjectBase *o)
void InitTraversal()
Definition: vtkCollection.h:96
vtkCollectionElement * Current
Detect and break reference loops.
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void UnRegister(vtkObjectBase *o)
a simple class to control print indentation
Definition: vtkIndent.h:37
virtual void ReportReferences(vtkGarbageCollector *)
#define VTK_COMMON_EXPORT
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
vtkCollectionElement * Bottom
iterator through a vtkCollection.
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:51
void InitTraversal(vtkCollectionSimpleIterator &cookie)
vtkCollectionElement * Next
Definition: vtkCollection.h:44
static vtkObject * New()
vtkObject * GetNextItemAsObject()
vtkCollectionElement * Top