• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/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 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 
00063   void InsertItem(int i, vtkObject *);
00064 
00066   void ReplaceItem(int i, vtkObject *);
00067 
00073   void RemoveItem(int i);
00074 
00078   void RemoveItem(vtkObject *);
00079 
00081   void RemoveAllItems();
00082 
00086   int IsItemPresent(vtkObject *a);
00087 
00089   int  GetNumberOfItems();
00090 
00093   void InitTraversal() { this->Current = this->Top;};
00094 
00095   //BTX
00097 
00099   void InitTraversal(vtkCollectionSimpleIterator &cookie) {
00100     cookie = static_cast<vtkCollectionSimpleIterator>(this->Top);};
00101   //ETX
00103 
00106   vtkObject *GetNextItemAsObject();  
00107 
00110   vtkObject *GetItemAsObject(int i);
00111 
00112   //BTX
00114 
00116   vtkObject *GetNextItemAsObject(vtkCollectionSimpleIterator &cookie);
00117   //ETX
00119   
00121   vtkCollectionIterator* NewIterator();
00122 
00124 
00125   virtual void Register(vtkObjectBase* o);
00126   virtual void UnRegister(vtkObjectBase* o);
00128 protected:
00129   vtkCollection();
00130   ~vtkCollection();
00131 
00132   virtual void DeleteElement(vtkCollectionElement *); 
00133   int NumberOfItems;
00134   vtkCollectionElement *Top;
00135   vtkCollectionElement *Bottom;
00136   vtkCollectionElement *Current;
00137 
00138   //BTX
00139   friend class vtkCollectionIterator;
00140   //ETX
00141 
00142   // See vtkGarbageCollector.h:
00143   virtual void ReportReferences(vtkGarbageCollector* collector);
00144 private:
00145   vtkCollection(const vtkCollection&); // Not implemented
00146   void operator=(const vtkCollection&); // Not implemented
00147 };
00148 
00149 
00150 inline vtkObject *vtkCollection::GetNextItemAsObject()
00151 {
00152   vtkCollectionElement *elem=this->Current;
00153 
00154   if ( elem != NULL )
00155     {
00156     this->Current = elem->Next;
00157     return elem->Item;
00158     }
00159   else
00160     {
00161     return NULL;
00162     }
00163 }
00164 
00165 inline vtkObject *vtkCollection::GetNextItemAsObject(void *&cookie)
00166 {
00167   vtkCollectionElement *elem=static_cast<vtkCollectionElement *>(cookie);
00168 
00169   if ( elem != NULL )
00170     {
00171     cookie = static_cast<void *>(elem->Next);
00172     return elem->Item;
00173     }
00174   else
00175     {
00176     return NULL;
00177     }
00178 }
00179 
00180 #endif
00181 
00182 
00183 
00184 
00185 

Generated by  doxygen 1.7.1