pleyo.com

/src/trunk2/BAL/Interfaces/DeprecatedPtrList.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  * 1. Redistributions of source code must retain the above copyright
00008  *    notice, this list of conditions and the following disclaimer.
00009  * 2. Redistributions in binary form must reproduce the above copyright
00010  *    notice, this list of conditions and the following disclaimer in the
00011  *    documentation and/or other materials provided with the distribution.
00012  *
00013  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00014  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00015  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00016  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00017  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00018  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00019  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00020  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00021  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00023  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00024  */
00025 
00026 #ifndef DeprecatedPtrList_h
00027 #define DeprecatedPtrList_h
00028 
00029 #include "DeprecatedPtrListImpl.h"
00030 
00031 namespace WebCore {
00032 
00033 template <class T> class DeprecatedPtrListIterator;
00034 
00035 template <class T> class DeprecatedPtrList {
00036 public:
00037     DeprecatedPtrList() : impl(deleteFunc), del_item(false) { }
00038     ~DeprecatedPtrList() { impl.clear(del_item); }
00039     
00040     DeprecatedPtrList(const DeprecatedPtrList& l) : impl(l.impl), del_item(false) { }
00041     DeprecatedPtrList& operator=(const DeprecatedPtrList &l) { impl.assign(l.impl, del_item); return *this; }
00042 
00043     bool isEmpty() const { return impl.isEmpty(); }
00044     unsigned count() const { return impl.count(); }
00045     void clear() { impl.clear(del_item); }
00046 
00047     T *at(unsigned n) { return (T *)impl.at(n); }
00048 
00049     bool insert(unsigned n, const T *item) { return impl.insert(n, item); }
00050     bool remove() { return impl.remove(del_item); }
00051     bool remove(unsigned n) { return impl.remove(n, del_item); }
00052     bool remove(const T *item) { return impl.removeRef(item, del_item); }
00053     bool removeFirst() { return impl.removeFirst(del_item); }
00054     bool removeLast() { return impl.removeLast(del_item); }
00055     bool removeRef(const T *item) { return impl.removeRef(item, del_item); }
00056 
00057     T *getFirst() const { return (T *)impl.getFirst(); }
00058     T *getLast() const { return (T *)impl.getLast(); }
00059     T *getNext() const { return (T *)impl.getNext(); }
00060     T *getPrev() const { return (T *)impl.getPrev(); }
00061     T *current() const { return (T *)impl.current(); }
00062     T *first() { return (T *)impl.first(); }
00063     T *last() { return (T *)impl.last(); }
00064     T *next() { return (T *)impl.next(); }
00065     T *prev() { return (T *)impl.prev(); }
00066     T *take(unsigned n) { return (T *)impl.take(n); }
00067     T *take() { return (T *)impl.take(); }
00068 
00069     void append(const T *item) { impl.append(item); }
00070     void prepend(const T *item) { impl.prepend(item); }
00071 
00072     unsigned containsRef(const T *item) const { return impl.containsRef(item); }
00073     int findRef(const T *item) { return impl.findRef(item); }
00074 
00075     typedef DeprecatedPtrListIterator<T> Iterator;
00076     typedef DeprecatedPtrListIterator<T> ConstIterator;
00077     ConstIterator begin() const { return ConstIterator(*this); }
00078     ConstIterator end() const { ConstIterator itr(*this); itr.toLast(); ++itr; return itr; }
00079 
00080     bool autoDelete() const { return del_item; }
00081     void setAutoDelete(bool autoDelete) { del_item = autoDelete; }
00082 
00083  private:
00084     static void deleteFunc(void *item) { delete (T *)item; }
00085 
00086     friend class DeprecatedPtrListIterator<T>;
00087 
00088     DeprecatedPtrListImpl impl;
00089     bool del_item;
00090 };
00091 
00092 template <class T> class DeprecatedPtrListIterator {
00093 public:
00094     DeprecatedPtrListIterator() { }
00095     DeprecatedPtrListIterator(const DeprecatedPtrList<T> &l) : impl(l.impl) { }
00096 
00097     unsigned count() const { return impl.count(); }
00098     T *toFirst() { return (T *)impl.toFirst(); }
00099     T *toLast() { return (T *)impl.toLast(); }
00100     T *current() const { return (T *)impl.current(); }
00101 
00102     operator T *() const { return (T *)impl.current(); }
00103     T *operator*() const { return (T *)impl.current(); }
00104     T *operator--() { return (T *)--impl; }
00105     T *operator++()  { return (T *)++impl; }
00106 
00107 private:
00108     DeprecatedPtrListImplIterator impl;
00109 };
00110 
00111 }
00112 
00113 #endif

Generated on Wed Nov 21 20:04:16 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com