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 _QUEUE_HXX 25 #define _QUEUE_HXX 26 27 #include <tools/solar.h> 28 #include <tools/contnr.hxx> 29 30 // --------- 31 // - Queue - 32 // --------- 33 34 #define QUEUE_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND 35 36 class Queue : private Container 37 { 38 public: 39 using Container::Clear; 40 using Container::Count; 41 using Container::GetObject; 42 using Container::GetPos; 43 Queue(sal_uInt16 _nInitSize=16,sal_uInt16 _nReSize=16)44 Queue( sal_uInt16 _nInitSize = 16, sal_uInt16 _nReSize = 16 ) : 45 Container( _nReSize, _nInitSize, _nReSize ) {} Queue(const Queue & rQueue)46 Queue( const Queue& rQueue ) : Container( rQueue ) {} 47 Put(void * p)48 void Put( void* p ) { Container::Insert( p, CONTAINER_APPEND ); } Get()49 void* Get() { return Container::Remove( (sal_uIntPtr)0 ); } 50 operator =(const Queue & rQueue)51 Queue& operator =( const Queue& rQueue ) 52 { Container::operator =( rQueue ); return *this; } 53 operator ==(const Queue & rQueue) const54 sal_Bool operator ==( const Queue& rQueue ) const 55 { return Container::operator ==( rQueue ); } operator !=(const Queue & rQueue) const56 sal_Bool operator !=( const Queue& rQueue ) const 57 { return Container::operator !=( rQueue ); } 58 }; 59 60 // ----------------- 61 // - DECLARE_QUEUE - 62 // ----------------- 63 64 #define DECLARE_QUEUE( ClassName, Type ) \ 65 class ClassName : private Queue \ 66 { \ 67 public: \ 68 using Queue::Clear; \ 69 using Queue::Count; \ 70 \ 71 ClassName( sal_uInt16 _nInitSize = 16, \ 72 sal_uInt16 _nReSize = 16 ) : \ 73 Queue( _nInitSize, _nReSize ) {} \ 74 ClassName( const ClassName& rClassName ) : \ 75 Queue( rClassName ) {} \ 76 \ 77 void Put( Type p ) { Queue::Put( (void*)p ); } \ 78 Type Get() { return (Type)Queue::Get(); } \ 79 \ 80 Type GetObject( sal_uIntPtr nIndex ) const \ 81 { return (Type)Queue::GetObject( nIndex ); } \ 82 sal_uIntPtr GetPos( const Type p ) const \ 83 { return Queue::GetPos( (const void*)p ); } \ 84 sal_uIntPtr GetPos( const Type p, sal_uIntPtr nStartIndex, \ 85 sal_Bool bForward = sal_True ) const \ 86 { return Queue::GetPos( (const void*)p, \ 87 nStartIndex, \ 88 bForward ); } \ 89 \ 90 ClassName& operator =( const ClassName& rClassName ) \ 91 { Queue::operator =( rClassName ); \ 92 return *this; } \ 93 \ 94 sal_Bool operator ==( const Queue& rQueue ) const \ 95 { return Queue::operator ==( rQueue ); } \ 96 sal_Bool operator !=( const Queue& rQueue ) const \ 97 { return Queue::operator !=( rQueue ); } \ 98 }; 99 100 #endif // _QUEUE_HXX 101