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

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 typedef void * vtkCollectionSimpleIterator;
00044 //ETX end tcl exclude
00045 
00046 class vtkCollectionIterator;
00047 
00048 class VTK_COMMON_EXPORT vtkCollection : public vtkObject
00049 {
00050 public:
00051   vtkTypeRevisionMacro(vtkCollection,vtkObject);
00052   void PrintSelf(ostream& os, vtkIndent indent);
00053 
00055   static vtkCollection *New();
00056 
00058   void AddItem(vtkObject *);
00059 
00061   void ReplaceItem(int i, vtkObject *);
00062 
00068   void RemoveItem(int i);  
00069 
00073   void RemoveItem(vtkObject *);
00074 
00076   void RemoveAllItems();
00077 
00080   int  IsItemPresent(vtkObject *);
00081 
00083   int  GetNumberOfItems();
00084 
00087   void InitTraversal() { this->Current = this->Top;};
00088 
00089   //BTX
00091 
00093   void InitTraversal(vtkCollectionSimpleIterator &cookie) {
00094     cookie = static_cast<vtkCollectionSimpleIterator>(this->Top);};
00095   //ETX
00097 
00100   vtkObject *GetNextItemAsObject();  
00101 
00104   vtkObject *GetItemAsObject(int i);
00105 
00106   //BTX
00108 
00110   vtkObject *GetNextItemAsObject(vtkCollectionSimpleIterator &cookie);
00111   //ETX
00113   
00115   vtkCollectionIterator* NewIterator();
00116 
00118 
00119   virtual void Register(vtkObjectBase* o);
00120   virtual void UnRegister(vtkObjectBase* o);
00122 protected:
00123   vtkCollection();
00124   ~vtkCollection();
00125 
00126   virtual void DeleteElement(vtkCollectionElement *); 
00127   int NumberOfItems;
00128   vtkCollectionElement *Top;
00129   vtkCollectionElement *Bottom;
00130   vtkCollectionElement *Current;
00131 
00132   //BTX
00133   friend class vtkCollectionIterator;
00134   //ETX
00135 
00136   // See vtkGarbageCollector.h:
00137   virtual void ReportReferences(vtkGarbageCollector* collector);
00138 private:
00139   vtkCollection(const vtkCollection&); // Not implemented
00140   void operator=(const vtkCollection&); // Not implemented
00141 };
00142 
00143 
00144 inline vtkObject *vtkCollection::GetNextItemAsObject()
00145 {
00146   vtkCollectionElement *elem=this->Current;
00147 
00148   if ( elem != NULL )
00149     {
00150     this->Current = elem->Next;
00151     return elem->Item;
00152     }
00153   else
00154     {
00155     return NULL;
00156     }
00157 }
00158 
00159 inline vtkObject *vtkCollection::GetNextItemAsObject(void *&cookie)
00160 {
00161   vtkCollectionElement *elem=static_cast<vtkCollectionElement *>(cookie);
00162 
00163   if ( elem != NULL )
00164     {
00165     cookie = static_cast<void *>(elem->Next);
00166     return elem->Item;
00167     }
00168   else
00169     {
00170     return NULL;
00171     }
00172 }
00173 
00174 #endif
00175 
00176 
00177 
00178 
00179 

Generated on Mon Jan 21 23:07:16 2008 for VTK by  doxygen 1.4.3-20050530