1*8b851043SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*8b851043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*8b851043SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*8b851043SAndrew Rist * distributed with this work for additional information
6*8b851043SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*8b851043SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*8b851043SAndrew Rist * "License"); you may not use this file except in compliance
9*8b851043SAndrew Rist * with the License. You may obtain a copy of the License at
10*8b851043SAndrew Rist *
11*8b851043SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*8b851043SAndrew Rist *
13*8b851043SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*8b851043SAndrew Rist * software distributed under the License is distributed on an
15*8b851043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*8b851043SAndrew Rist * KIND, either express or implied. See the License for the
17*8b851043SAndrew Rist * specific language governing permissions and limitations
18*8b851043SAndrew Rist * under the License.
19*8b851043SAndrew Rist *
20*8b851043SAndrew Rist *************************************************************/
21*8b851043SAndrew Rist
22*8b851043SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _IMPCONT_HXX
25cdf0e10cSrcweir #define _IMPCONT_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/tools.h>
28cdf0e10cSrcweir #include <tools/contnr.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir typedef void* PVOID;
31cdf0e10cSrcweir
32cdf0e10cSrcweir // ----------
33cdf0e10cSrcweir // - CBlock -
34cdf0e10cSrcweir // ----------
35cdf0e10cSrcweir
36cdf0e10cSrcweir class CBlock
37cdf0e10cSrcweir {
38cdf0e10cSrcweir private:
39cdf0e10cSrcweir CBlock* pPrev; // Vorheriger Block
40cdf0e10cSrcweir CBlock* pNext; // Naechster Block
41cdf0e10cSrcweir sal_uInt16 nSize; // Groesse des Blocks
42cdf0e10cSrcweir sal_uInt16 nCount; // Anzahl Pointer
43cdf0e10cSrcweir void** pNodes; // Pointer auf die Daten
44cdf0e10cSrcweir
45cdf0e10cSrcweir #if defined DBG_UTIL
46cdf0e10cSrcweir static char const * DbgCheckCBlock(void const *);
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir
49cdf0e10cSrcweir public:
50cdf0e10cSrcweir // Fuer List-Container
51cdf0e10cSrcweir CBlock( sal_uInt16 nSize, CBlock* pPrev, CBlock* pNext );
52cdf0e10cSrcweir // Fuer Array-Container
53cdf0e10cSrcweir CBlock( sal_uInt16 nSize, CBlock* pPrev );
54cdf0e10cSrcweir // Copy-Ctor
55cdf0e10cSrcweir CBlock( const CBlock& r, CBlock* pPrev );
56cdf0e10cSrcweir ~CBlock();
57cdf0e10cSrcweir
58cdf0e10cSrcweir void Insert( void* p, sal_uInt16 nIndex, sal_uInt16 nReSize );
59cdf0e10cSrcweir CBlock* Split( void* p, sal_uInt16 nIndex, sal_uInt16 nReSize );
60cdf0e10cSrcweir void* Remove( sal_uInt16 nIndex, sal_uInt16 nReSize );
61cdf0e10cSrcweir void* Replace( void* pNew, sal_uInt16 nIndex );
62cdf0e10cSrcweir
GetNodes() const63cdf0e10cSrcweir void** GetNodes() const { return pNodes; }
64cdf0e10cSrcweir void** GetObjectPtr( sal_uInt16 nIndex );
65cdf0e10cSrcweir void* GetObject( sal_uInt16 nIndex ) const;
66cdf0e10cSrcweir
67cdf0e10cSrcweir void SetSize( sal_uInt16 nNewSize );
68cdf0e10cSrcweir
GetSize() const69cdf0e10cSrcweir sal_uInt16 GetSize() const { return nCount; }
Count() const70cdf0e10cSrcweir sal_uInt16 Count() const { return nCount; }
SetPrevBlock(CBlock * p)71cdf0e10cSrcweir void SetPrevBlock( CBlock* p ) { pPrev = p; }
SetNextBlock(CBlock * p)72cdf0e10cSrcweir void SetNextBlock( CBlock* p ) { pNext = p; }
GetPrevBlock() const73cdf0e10cSrcweir CBlock* GetPrevBlock() const { return pPrev; }
GetNextBlock() const74cdf0e10cSrcweir CBlock* GetNextBlock() const { return pNext; }
Reset()75cdf0e10cSrcweir void Reset() { nCount = 0; }
76cdf0e10cSrcweir
77cdf0e10cSrcweir private:
78cdf0e10cSrcweir CBlock( const CBlock& r );
79cdf0e10cSrcweir
80cdf0e10cSrcweir friend class Container;
81cdf0e10cSrcweir };
82cdf0e10cSrcweir
83cdf0e10cSrcweir /*************************************************************************
84cdf0e10cSrcweir |*
85cdf0e10cSrcweir |* CBlock::GetObject()
86cdf0e10cSrcweir |*
87cdf0e10cSrcweir |* Beschreibung Gibt einen Pointer aus dem Block zurueck
88cdf0e10cSrcweir |* Ersterstellung TH 17.09.91
89cdf0e10cSrcweir |* Letzte Aenderung TH 17.09.91
90cdf0e10cSrcweir |*
91cdf0e10cSrcweir *************************************************************************/
92cdf0e10cSrcweir
GetObject(sal_uInt16 nIndex) const93cdf0e10cSrcweir inline void* CBlock::GetObject( sal_uInt16 nIndex ) const
94cdf0e10cSrcweir {
95cdf0e10cSrcweir return pNodes[nIndex];
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir /*************************************************************************
99cdf0e10cSrcweir |*
100cdf0e10cSrcweir |* Container::ImpGetObject()
101cdf0e10cSrcweir |*
102cdf0e10cSrcweir |* Beschreibung Wir gehen davon aus, das Pointer in der Regel
103cdf0e10cSrcweir |* sich im ersten Block befindet und schalten
104cdf0e10cSrcweir |* deshalb eine Inline-Methode davor
105cdf0e10cSrcweir |* Ersterstellung TH 02.07.93
106cdf0e10cSrcweir |* Letzte Aenderung TH 02.07.93
107cdf0e10cSrcweir |*
108cdf0e10cSrcweir *************************************************************************/
109cdf0e10cSrcweir
ImpGetObject(sal_uIntPtr nIndex) const110cdf0e10cSrcweir inline void* Container::ImpGetObject( sal_uIntPtr nIndex ) const
111cdf0e10cSrcweir {
112cdf0e10cSrcweir if ( pFirstBlock && (nIndex < pFirstBlock->Count()) )
113cdf0e10cSrcweir // Item innerhalb des gefundenen Blocks zurueckgeben
114cdf0e10cSrcweir return pFirstBlock->GetObject( (sal_uInt16)nIndex );
115cdf0e10cSrcweir else
116cdf0e10cSrcweir return GetObject( nIndex );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir /*************************************************************************
120cdf0e10cSrcweir |*
121cdf0e10cSrcweir |* Container::ImpGetOnlyNodes()
122cdf0e10cSrcweir |*
123cdf0e10cSrcweir |* Beschreibung Wenn es nur einen Block gibt, wird davon
124cdf0e10cSrcweir |* das Daten-Array zurueckgegeben
125cdf0e10cSrcweir |* Ersterstellung TH 24.01.96
126cdf0e10cSrcweir |* Letzte Aenderung TH 24.01.96
127cdf0e10cSrcweir |*
128cdf0e10cSrcweir *************************************************************************/
129cdf0e10cSrcweir
130cdf0e10cSrcweir // #i70651#: Prevent warnings on Mac OS X
131cdf0e10cSrcweir #ifdef MACOSX
132cdf0e10cSrcweir #pragma GCC system_header
133cdf0e10cSrcweir #endif
134cdf0e10cSrcweir
ImpGetOnlyNodes() const135cdf0e10cSrcweir inline void** Container::ImpGetOnlyNodes() const
136cdf0e10cSrcweir {
137cdf0e10cSrcweir if ( (pFirstBlock == pLastBlock) && pFirstBlock )
138cdf0e10cSrcweir return pFirstBlock->GetNodes();
139cdf0e10cSrcweir else
140cdf0e10cSrcweir return NULL;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir #endif // _IMPCONT_HXX
144