1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _TOOLS_OWNLIST_HXX 25 #define _TOOLS_OWNLIST_HXX 26 27 #ifndef _TOOLS_LIST_HXX //autogen 28 #include <tools/list.hxx> 29 #endif 30 /************************************************************************* 31 *************************************************************************/ 32 33 #define PRV_SV_DECL_OWNER_LIST(ClassName,Type) \ 34 List aTypes; \ 35 public: \ 36 ClassName( sal_uInt16 nInitSize = 16, \ 37 sal_uInt16 nReSize = 16 ) \ 38 : aTypes( nInitSize, nReSize ) {} \ 39 ClassName( const ClassName & rObj ) \ 40 { *this = rObj; } \ 41 ClassName & operator = ( const ClassName & ); \ 42 ~ClassName() \ 43 { Clear(); } \ 44 void Clear(); \ 45 void Remove() \ 46 { delete (Type *)aTypes.Remove(); } \ 47 void Remove( Type * pObj ) \ 48 { delete (Type *)aTypes.Remove( pObj ); } \ 49 void Remove( sal_uIntPtr nPos ) \ 50 { delete (Type *)aTypes.Remove( nPos ); } \ 51 Type & Insert( const Type &, sal_uIntPtr nPos ); \ 52 Type & Insert( const Type & rType ) \ 53 { return Insert( rType, aTypes.GetCurPos() ); } \ 54 Type & Append( const Type & rType ) \ 55 { return Insert( rType, LIST_APPEND ); } \ 56 Type & GetObject( sal_uIntPtr nPos ) const \ 57 { return *(Type *)aTypes.GetObject( nPos ); } \ 58 Type & operator []( sal_uIntPtr nPos ) const \ 59 { return *(Type *)aTypes.GetObject( nPos ); } \ 60 sal_uIntPtr Count() const { return aTypes.Count(); } 61 62 #define PRV_SV_IMPL_OWNER_LIST(ClassName,Type) \ 63 ClassName & ClassName::operator = ( const ClassName & rObj ) \ 64 { \ 65 if( this != &rObj ) \ 66 { \ 67 Clear(); \ 68 for( sal_uIntPtr i = 0; i < rObj.Count(); i++ ) \ 69 Append( rObj.GetObject( i ) ); \ 70 } \ 71 return *this; \ 72 } \ 73 void ClassName::Clear() \ 74 { \ 75 Type * p = (Type *)aTypes.First(); \ 76 while( p ) \ 77 { \ 78 delete p; \ 79 p = (Type *)aTypes.Next(); \ 80 } \ 81 aTypes.Clear(); \ 82 } \ 83 Type & ClassName::Insert( const Type & rType, sal_uIntPtr nPos ) \ 84 { \ 85 Type * pType = new Type( rType ); \ 86 aTypes.Insert( pType, nPos ); \ 87 return *pType; \ 88 } 89 90 #endif // _TOOLS_OWNLIST_HXX 91