Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Common/vtkCollection.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkCollection.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00030 #ifndef __vtkCollection_h
00031 #define __vtkCollection_h
00032 
00033 #include "vtkObject.h"
00034 
00035 //BTX - begin tcl exclude
00036 class vtkCollectionElement //;prevents pick-up by man page generator
00037 {
00038  public:
00039   vtkCollectionElement():Item(NULL),Next(NULL) {};
00040   vtkObject *Item;
00041   vtkCollectionElement *Next;
00042 };
00043 //ETX end tcl exclude
00044 
00045 class vtkCollectionIterator;
00046 
00047 class VTK_COMMON_EXPORT vtkCollection : public vtkObject
00048 {
00049 public:
00050   vtkTypeRevisionMacro(vtkCollection,vtkObject);
00051   void PrintSelf(ostream& os, vtkIndent indent);
00052 
00054   static vtkCollection *New();
00055 
00057   void AddItem(vtkObject *);
00058 
00060   void ReplaceItem(int i, vtkObject *);
00061 
00067   void RemoveItem(int i);  
00068 
00072   void RemoveItem(vtkObject *);
00073 
00075   void RemoveAllItems();
00076 
00079   int  IsItemPresent(vtkObject *);
00080 
00082   int  GetNumberOfItems();
00083 
00086   void InitTraversal() { this->Current = this->Top;};
00087 
00088   //BTX
00090 
00092   void InitTraversal(void *&cookie) {cookie = static_cast<void *>(this->Top);};
00093   //ETX
00095 
00098   vtkObject *GetNextItemAsObject();  
00099 
00102   vtkObject *GetItemAsObject(int i);
00103 
00104   //BTX
00106 
00108   vtkObject *GetNextItemAsObject(void *&cookie);
00109   //ETX
00111   
00113   vtkCollectionIterator* NewIterator();
00114   
00115 protected:
00116   vtkCollection();
00117   ~vtkCollection();
00118 
00119   virtual void DeleteElement(vtkCollectionElement *); 
00120   int NumberOfItems;
00121   vtkCollectionElement *Top;
00122   vtkCollectionElement *Bottom;
00123   vtkCollectionElement *Current;
00124 
00125   //BTX
00126   friend class vtkCollectionIterator;
00127   //ETX
00128   
00129 private:
00130   vtkCollection(const vtkCollection&); // Not implemented
00131   void operator=(const vtkCollection&); // Not implemented
00132 };
00133 
00134 
00135 inline vtkObject *vtkCollection::GetNextItemAsObject()
00136 {
00137   vtkCollectionElement *elem=this->Current;
00138 
00139   if ( elem != NULL )
00140     {
00141     this->Current = elem->Next;
00142     return elem->Item;
00143     }
00144   else
00145     {
00146     return NULL;
00147     }
00148 }
00149 
00150 inline vtkObject *vtkCollection::GetNextItemAsObject(void *&cookie)
00151 {
00152   vtkCollectionElement *elem=static_cast<vtkCollectionElement *>(cookie);
00153 
00154   if ( elem != NULL )
00155     {
00156     cookie = static_cast<void *>(elem->Next);
00157     return elem->Item;
00158     }
00159   else
00160     {
00161     return NULL;
00162     }
00163 }
00164 
00165 #endif
00166 
00167 
00168 
00169 
00170