00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Base Library 00005 * Module : ManagedList 00006 * Package : Zeus.ZeusBase.System 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef ManagedListHPP 00033 #define ManagedListHPP 00034 00035 #include <zeusbase/System/Interfaces/IZUnknown.hpp> 00036 #include <zeusbase/System/SingleLinkedList.hpp> 00037 #include <zeusbase/System/AutoPtr.hpp> 00038 00039 BEGIN_NAMESPACE_Zeus 00040 00041 #if __BCPLUSPLUS__ >= 0x0610 00042 //Hides the w8022 warning which says that methods hide the virtual functions 00043 #pragma warn - 8022 00044 #endif 00045 00046 /***************************************************************************/ 00049 /***************************************************************************/ 00050 template <class T> class TManagedList : public TSingleLinkedList<TAutoPtr<T> > 00051 { 00052 public: 00053 00054 /***********************************************************************/ 00057 /***********************************************************************/ 00058 inline TManagedList() 00059 { 00060 setEmptyItem(TAutoPtr<T>(NULL)); 00061 } 00062 00063 00064 /***********************************************************************/ 00068 /***********************************************************************/ 00069 inline TManagedList(const TManagedList& rList) : TSingleLinkedList<TAutoPtr<T> >(rList) 00070 {} 00071 00072 /***********************************************************************/ 00075 /***********************************************************************/ 00076 inline virtual Int MQUALIFIER add(const TAutoPtr<T>& rItem) 00077 { 00078 return TSingleLinkedList<TAutoPtr<T> >::add(rItem); 00079 } 00080 00081 /***********************************************************************/ 00088 /***********************************************************************/ 00089 inline virtual Int MQUALIFIER add(const T& rItem, bool bAddReference) 00090 { 00091 return TSingleLinkedList<TAutoPtr<T> >::add(TAutoPtr<T>(rItem, bAddReference)); 00092 } 00093 00094 /***********************************************************************/ 00101 /***********************************************************************/ 00102 inline virtual Int MQUALIFIER add(const T* pItem, bool bAddReference) 00103 { 00104 return TSingleLinkedList<TAutoPtr<T> >::add(TAutoPtr<T>(pItem, bAddReference)); 00105 } 00106 00107 /***********************************************************************/ 00110 /***********************************************************************/ 00111 inline virtual Int MQUALIFIER insert(Int iIndex, const TAutoPtr<T>& rItem) 00112 { 00113 return TSingleLinkedList<TAutoPtr<T> >::insert(iIndex, rItem); 00114 } 00115 00116 /***********************************************************************/ 00124 /***********************************************************************/ 00125 inline virtual Int MQUALIFIER insert(Int iIndex, const T& rItem, bool bAddReference) 00126 { 00127 return TSingleLinkedList<TAutoPtr<T> >::insert(iIndex, TAutoPtr<T>(rItem, bAddReference)); 00128 } 00129 00130 /***********************************************************************/ 00138 /***********************************************************************/ 00139 inline virtual Int MQUALIFIER insert(Int iIndex, const T* pItem, bool bAddReference) 00140 { 00141 return TSingleLinkedList<TAutoPtr<T> >::insert(iIndex, TAutoPtr<T>(pItem, bAddReference)); 00142 } 00143 00144 /***********************************************************************/ 00147 /***********************************************************************/ 00148 inline virtual Int MQUALIFIER indexOf(const T& rItem) const 00149 { 00150 return TSingleLinkedList<TAutoPtr<T> >::indexOf(TAutoPtr<T>(rItem, true)); //allways allocate 00151 } 00152 00153 /***********************************************************************/ 00156 /***********************************************************************/ 00157 inline virtual Int MQUALIFIER indexOf(const T* pItem) const 00158 { 00159 return TSingleLinkedList<TAutoPtr<T> >::indexOf(TAutoPtr<T>(pItem, true)); //allways allocate 00160 } 00161 00162 /***********************************************************************/ 00165 /***********************************************************************/ 00166 inline virtual Retval MQUALIFIER remove(const T& rItem) 00167 { 00168 return TSingleLinkedList<TAutoPtr<T> >::remove(TAutoPtr<T>(rItem, true)); //allways allocate 00169 } 00170 00171 /***********************************************************************/ 00174 /***********************************************************************/ 00175 inline virtual Retval MQUALIFIER remove(const T* pItem) 00176 { 00177 return TSingleLinkedList<TAutoPtr<T> >::remove(TAutoPtr<T>(pItem, true)); //allways allocate 00178 } 00179 00180 /***********************************************************************/ 00183 /***********************************************************************/ 00184 inline virtual bool MQUALIFIER equalsItem(Int iIndex, const T& rItem) const 00185 { 00186 return TSingleLinkedList<TAutoPtr<T> >::equalsItem(iIndex, TAutoPtr<T>(rItem, true)); //allways allocate 00187 } 00188 00189 /***********************************************************************/ 00192 /***********************************************************************/ 00193 inline virtual bool MQUALIFIER equalsItem(Int iIndex, const T* pItem) const 00194 { 00195 return TSingleLinkedList<TAutoPtr<T> >::equalsItem(iIndex, TAutoPtr<T>(pItem, true)); //allways allocate 00196 } 00197 00198 /***********************************************************************/ 00201 /***********************************************************************/ 00202 inline virtual bool MQUALIFIER hasItem(const T& rItem) const 00203 { 00204 return TSingleLinkedList<TAutoPtr<T> >::hasItem(TAutoPtr<T>(rItem, true)); //allways allocate 00205 } 00206 00207 /***********************************************************************/ 00210 /***********************************************************************/ 00211 inline virtual bool MQUALIFIER hasItem(const T* pItem) const 00212 { 00213 return TSingleLinkedList<TAutoPtr<T> >::hasItem(TAutoPtr<T>(pItem, true)); //allways allocate 00214 } 00215 00216 /***********************************************************************/ 00220 /***********************************************************************/ 00221 inline TManagedList& operator=(const TManagedList& rList) 00222 { 00223 rList.copyToList(*this); 00224 return *this; 00225 } 00226 00227 private: 00228 }; 00229 00230 #if __BCPLUSPLUS__ >= 0x0610 00231 #pragma warn . 8022 00232 #endif 00233 00234 00235 END_NAMESPACE_Zeus 00236 00237 #endif