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

vtkAbstractSequence.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 * 00003 * $Id: vtkAbstractSequence.h,v 1.2 2004/06/03 18:58:28 xpxqx Exp $ 00004 * 00005 * Copyright (c) 2004 Sean McInerney 00006 * All rights reserved. 00007 * 00008 * See Copyright.txt or http://vtkextensions.sourceforge.net/Copyright.html 00009 * for details. 00010 * 00011 * This software is distributed WITHOUT ANY WARRANTY; without even 00012 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 * PURPOSE. See the above copyright notice for more information. 00014 * 00015 */ 00016 #ifndef VTK_ABSTRACT_SEQUENCE_H_ 00017 # define VTK_ABSTRACT_SEQUENCE_H_ 00018 # include "vtkContainer.h" 00019 # include "vtkAbstractSequenceIterator.h" 00020 00021 VTK_EXTENSIONS_CONTAINERS_NAMESPACE_BEGIN 00022 00036 class VTK_EXTENSIONS_CONTAINERS_EXPORT vtkAbstractSequence 00037 : public vtkContainer 00038 { 00039 public: 00040 vtkTypeRevisionMacro (vtkAbstractSequence, vtkContainer); 00041 void PrintSelf (ostream&, vtkIndent); 00042 00043 //BTX 00044 typedef int (*CompareFunction)(const vtkObjectBase* & a1, 00045 const vtkObjectBase* & a2); 00046 //ETX 00047 00052 virtual int Swap (vtkAbstractSequence* container) = 0; 00053 00058 virtual vtkIdType GetCapacity (void) const; 00059 00066 virtual int SetCapacity (vtkIdType capacity) = 0; 00067 00075 virtual vtkObjectBase* At (vtkIdType position) const; 00076 00081 virtual vtkIdType Find (const vtkObjectBase* object) const; 00082 00083 //BTX 00088 virtual vtkIdType Find (const vtkObjectBase* object, 00089 CompareFunction comparison) const; 00090 //ETX 00091 00096 virtual int IsPresent (const vtkObjectBase* object) const; 00097 00111 virtual int Insert (vtkIdType position, 00112 vtkObjectBase* object) = 0; 00113 00128 virtual int Insert (vtkIdType position, 00129 vtkAbstractSequence* sequence); 00130 00138 virtual int PushFront (vtkObjectBase* object); 00139 00147 int PopFront (void); 00148 00157 virtual int PushBack (vtkObjectBase* object) = 0; 00158 00166 int PopBack (void); 00167 00177 virtual int PushBack (vtkAbstractSequence* sequence); 00178 00183 virtual int Assign (vtkIdType position, 00184 vtkObjectBase* object) = 0; 00185 00193 virtual int Erase (vtkIdType position) = 0; 00194 00196 void DebugSequence (ostream& stream); 00197 00199 virtual vtkAbstractSequenceIterator* CreateIterator (void) = 0; 00200 00201 protected: 00202 vtkAbstractSequence (void) {} 00203 ~vtkAbstractSequence() {} 00204 00205 private: 00206 //BTX 00209 int Swap (vtkContainer* a) 00210 { return this->Swap(static_cast<vtkAbstractSequence*>(a)); } 00212 //ETX 00213 00214 private: 00220 vtkAbstractSequence (const vtkAbstractSequence&); 00221 void operator= (const vtkAbstractSequence&); 00223 }; 00224 00225 // ---------------------------------------------------------------------------- 00226 inline vtkIdType 00227 vtkAbstractSequence::GetCapacity (void) const 00228 { 00229 return 0; 00230 } 00231 00232 inline vtkObjectBase* 00233 vtkAbstractSequence::At (vtkIdType) const 00234 { 00235 return (vtkObjectBase *) 0; 00236 } 00237 00238 inline vtkIdType 00239 vtkAbstractSequence::Find (const vtkObjectBase*) const 00240 { 00241 return -1; 00242 } 00243 00244 inline vtkIdType 00245 vtkAbstractSequence::Find (const vtkObjectBase*, CompareFunction) const 00246 { 00247 return -1; 00248 } 00249 00250 // ---------------------------------------------------------------------------- 00251 inline int 00252 vtkAbstractSequence::IsPresent (const vtkObjectBase* a) const 00253 { 00254 return (this->Find(a)<0 ? VTK_FALSE : VTK_TRUE); 00255 } 00256 00257 inline int 00258 vtkAbstractSequence::Insert (vtkIdType aPosition, 00259 vtkAbstractSequence* aSequence) 00260 { 00261 for (vtkIdType i=0; i<aSequence->GetSize(); i++) 00262 { 00263 if (this->Insert(aPosition + i, aSequence->At(i)) == VTK_FALSE) 00264 { 00265 // roll back changes on error. 00266 for (vtkIdType ii=aPosition+i-1; ii>=aPosition; ii--) 00267 { 00268 (void) this->Erase(ii); // Erase errors ignored. 00269 } 00270 return VTK_FALSE; 00271 } 00272 } 00273 return VTK_TRUE; 00274 } 00275 00276 inline int 00277 vtkAbstractSequence::PushFront (vtkObjectBase* a) 00278 { 00279 return this->Insert(0, a); 00280 } 00281 00282 inline int 00283 vtkAbstractSequence::PopFront (void) 00284 { 00285 return this->Erase(0); 00286 } 00287 00288 inline int 00289 vtkAbstractSequence::PopBack (void) 00290 { 00291 return this->Erase(this->GetSize() - 1); 00292 } 00293 00294 inline int 00295 vtkAbstractSequence::PushBack (vtkAbstractSequence* aSequence) 00296 { 00297 for (vtkIdType i=0; i<aSequence->GetSize(); i++) 00298 { 00299 if (this->PushBack(aSequence->At(i)) == VTK_FALSE) 00300 { 00301 // roll back changes on error. 00302 for (vtkIdType ii=0; ii<i; ii++) 00303 { 00304 (void) this->PopBack(); // Erase errors ignored. 00305 } 00306 return VTK_FALSE; 00307 } 00308 } 00309 return VTK_TRUE; 00310 } 00311 00312 VTK_EXTENSIONS_CONTAINERS_NAMESPACE_END 00313 00314 #endif /* VTK_ABSTRACT_SEQUENCE_H_ */ 00315 /* 00316 * End of: $Id: vtkAbstractSequence.h,v 1.2 2004/06/03 18:58:28 xpxqx Exp $. 00317 * 00318 */

Generated on Tue Aug 10 03:37:04 2004 for vtkExtensions by doxygen 1.3.7