|
2
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
#ifndef __CSTACKDEPRECATED_INL__
|
|
|
20 |
#define __CSTACKDEPRECATED_INL__
|
|
|
21 |
|
|
|
22 |
// constants
|
|
|
23 |
const TInt KStackGranularity=32;
|
|
|
24 |
|
|
|
25 |
enum TCStackPanic
|
|
|
26 |
{
|
|
|
27 |
ECStackErrStackIsEmpty,
|
|
|
28 |
ECStackDeleteWhenNotOwner,
|
|
|
29 |
ECStackPopsWhenOwner
|
|
|
30 |
};
|
|
|
31 |
|
|
|
32 |
_LIT(KCStackPanicName, "CStackDeprecated");
|
|
|
33 |
|
|
|
34 |
inline void Panic(TCStackPanic aPanic)
|
|
|
35 |
{
|
|
|
36 |
User::Panic(KCStackPanicName, aPanic);
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
//
|
|
|
40 |
// CStack
|
|
|
41 |
//
|
|
|
42 |
|
|
|
43 |
template <class T, TBool StackOwnsEntry>
|
|
|
44 |
inline CStackDeprecated<T, StackOwnsEntry>::CStackDeprecated()
|
|
|
45 |
: CArrayPtrSeg<T>(KStackGranularity)
|
|
|
46 |
{
|
|
|
47 |
this->Reset();
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
template <class T, TBool StackOwnsEntry>
|
|
|
51 |
inline CStackDeprecated<T, StackOwnsEntry>::~CStackDeprecated()
|
|
|
52 |
{
|
|
|
53 |
Clear();
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
template <class T, TBool StackOwnsEntry>
|
|
|
57 |
inline void CStackDeprecated<T, StackOwnsEntry>::Clear()
|
|
|
58 |
{
|
|
|
59 |
if (StackOwnsEntry)
|
|
|
60 |
this->ResetAndDestroy();
|
|
|
61 |
else
|
|
|
62 |
this->Reset();
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
template <class T, TBool StackOwnsEntry>
|
|
|
66 |
inline TBool CStackDeprecated<T, StackOwnsEntry>::IsEmpty() const
|
|
|
67 |
{
|
|
|
68 |
return this->Count()==0;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
template <class T, TBool StackOwnsEntry>
|
|
|
72 |
inline void CStackDeprecated<T, StackOwnsEntry>::PushL(T* aItem)
|
|
|
73 |
{
|
|
|
74 |
if (StackOwnsEntry)
|
|
|
75 |
CleanupStack::PushL(aItem);
|
|
|
76 |
this->AppendL(aItem);
|
|
|
77 |
if (StackOwnsEntry)
|
|
|
78 |
CleanupStack::Pop();
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
template <class T, TBool StackOwnsEntry>
|
|
|
82 |
inline T* CStackDeprecated<T, StackOwnsEntry>::Pop()
|
|
|
83 |
{
|
|
|
84 |
__ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
|
|
|
85 |
T* item=Head();
|
|
|
86 |
this->Delete(this->Count()-1);
|
|
|
87 |
return item;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
template <class T, TBool StackOwnsEntry>
|
|
|
91 |
inline T* CStackDeprecated<T, StackOwnsEntry>::Head() const
|
|
|
92 |
{
|
|
|
93 |
__ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
|
|
|
94 |
return this->At(this->Count()-1);
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
template <class T, TBool StackOwnsEntry>
|
|
|
98 |
inline T* CStackDeprecated<T, StackOwnsEntry>::Last() const
|
|
|
99 |
{
|
|
|
100 |
__ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
|
|
|
101 |
return this->At(0);
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
#endif // __CSTACKDEPRECATED_INL__
|